linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* libata fixes for NVME + OPAL
@ 2019-04-24 10:34 Enrico Weigelt, metux IT consult
  2019-04-24 10:34 ` [PATCH 1/3] drivers: nvme: target: core: fix build break Enrico Weigelt, metux IT consult
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Enrico Weigelt, metux IT consult @ 2019-04-24 10:34 UTC (permalink / raw)
  To: linux-kernel; +Cc: axboe, linux-ide, linux-nvme

Hello folks,


here're some fixes for libata to make NVME and TCG OPAL work:

* fix a little build break in nvme (forgotten include and Kconfig select)
* introduce sysctl knob for enabling tpm stuff at runtime
  (sed-util expects since several years, so it seems that piece just might
  have been forgotten when opal support was mainlined)


--mtx

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/3] drivers: nvme: target: core: fix build break
  2019-04-24 10:34 libata fixes for NVME + OPAL Enrico Weigelt, metux IT consult
@ 2019-04-24 10:34 ` Enrico Weigelt, metux IT consult
  2019-04-24 17:07   ` Sagi Grimberg
                     ` (2 more replies)
  2019-04-24 10:34 ` [PATCH 2/3] drivers: libata: introduce sysctl directory Enrico Weigelt, metux IT consult
                   ` (2 subsequent siblings)
  3 siblings, 3 replies; 9+ messages in thread
From: Enrico Weigelt, metux IT consult @ 2019-04-24 10:34 UTC (permalink / raw)
  To: linux-kernel; +Cc: axboe, linux-ide, linux-nvme

Build breaks:

    drivers/nvme/target/core.c: In function 'nvmet_req_alloc_sgl':
    drivers/nvme/target/core.c:939:12: error: implicit declaration of \
function 'sgl_alloc'; did you mean 'bio_alloc'? \
[-Werror=implicit-function-declaration]
      req->sg = sgl_alloc(req->transfer_len, GFP_KERNEL, &req->sg_cnt);
                ^~~~~~~~~
                bio_alloc
    drivers/nvme/target/core.c:939:10: warning: assignment makes pointer \
from integer without a cast [-Wint-conversion]
      req->sg = sgl_alloc(req->transfer_len, GFP_KERNEL, &req->sg_cnt);
              ^
    drivers/nvme/target/core.c: In function 'nvmet_req_free_sgl':
    drivers/nvme/target/core.c:952:3: error: implicit declaration of \
function 'sgl_free'; did you mean 'ida_free'? [-Werror=implicit-function-declaration]
       sgl_free(req->sg);
       ^~~~~~~~
       ida_free

Cause:

    1. missing include to <linux/scatterlist.h>
    2. SGL_ALLOC needs to be enabled

Therefore adding the missing include, as well as Kconfig dependency.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
---
 drivers/nvme/target/Kconfig | 1 +
 drivers/nvme/target/core.c  | 1 +
 2 files changed, 2 insertions(+)

diff --git a/drivers/nvme/target/Kconfig b/drivers/nvme/target/Kconfig
index d94f25c..3ef0a4e 100644
--- a/drivers/nvme/target/Kconfig
+++ b/drivers/nvme/target/Kconfig
@@ -3,6 +3,7 @@ config NVME_TARGET
 	tristate "NVMe Target support"
 	depends on BLOCK
 	depends on CONFIGFS_FS
+	select SGL_ALLOC
 	help
 	  This enabled target side support for the NVMe protocol, that is
 	  it allows the Linux kernel to implement NVMe subsystems and
diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c
index b3e765a..08851f5 100644
--- a/drivers/nvme/target/core.c
+++ b/drivers/nvme/target/core.c
@@ -8,6 +8,7 @@
 #include <linux/random.h>
 #include <linux/rculist.h>
 #include <linux/pci-p2pdma.h>
+#include <linux/scatterlist.h>
 
 #include "nvmet.h"
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/3] drivers: libata: introduce sysctl directory
  2019-04-24 10:34 libata fixes for NVME + OPAL Enrico Weigelt, metux IT consult
  2019-04-24 10:34 ` [PATCH 1/3] drivers: nvme: target: core: fix build break Enrico Weigelt, metux IT consult
@ 2019-04-24 10:34 ` Enrico Weigelt, metux IT consult
  2019-04-24 10:34 ` [PATCH 3/3] drivers: libata: add sysctl: 'libata.allow_tpm' for self-encrypted devices Enrico Weigelt, metux IT consult
       [not found] ` <CGME20190424103521epcas3p44a7fc17a216b5696a6feefc781136699@epcms2p8>
  3 siblings, 0 replies; 9+ messages in thread
From: Enrico Weigelt, metux IT consult @ 2019-04-24 10:34 UTC (permalink / raw)
  To: linux-kernel; +Cc: axboe, linux-ide, linux-nvme

Register a sysctl directory for libata, so upcoming knobs
can be added here.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
---
 drivers/ata/libata-core.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index adf2878..d3044c9 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -176,6 +176,21 @@ struct ata_force_ent {
 MODULE_LICENSE("GPL");
 MODULE_VERSION(DRV_VERSION);
 
+static struct ctl_table ctl_libata[] = {
+	{}
+};
+
+static struct ctl_table libata_dir_table[] = {
+	{
+		.procname	= "libata",
+		.maxlen		= 0,
+		.mode		= 0555,
+		.child		= ctl_libata,
+	},
+	{ },
+};
+
+static struct ctl_table_header *libata_sysctl_header;
 
 static bool ata_sstatus_online(u32 sstatus)
 {
@@ -7059,6 +7074,8 @@ static int __init ata_init(void)
 		goto err_out;
 	}
 
+	libata_sysctl_header = register_sysctl_table(libata_dir_table);
+
 	printk(KERN_DEBUG "libata version " DRV_VERSION " loaded.\n");
 	return 0;
 
@@ -7072,6 +7089,7 @@ static void __exit ata_exit(void)
 	libata_transport_exit();
 	ata_sff_exit();
 	kfree(ata_force_tbl);
+	unregister_sysctl_table(libata_sysctl_header);
 }
 
 subsys_initcall(ata_init);
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 3/3] drivers: libata: add sysctl: 'libata.allow_tpm' for self-encrypted devices
  2019-04-24 10:34 libata fixes for NVME + OPAL Enrico Weigelt, metux IT consult
  2019-04-24 10:34 ` [PATCH 1/3] drivers: nvme: target: core: fix build break Enrico Weigelt, metux IT consult
  2019-04-24 10:34 ` [PATCH 2/3] drivers: libata: introduce sysctl directory Enrico Weigelt, metux IT consult
@ 2019-04-24 10:34 ` Enrico Weigelt, metux IT consult
       [not found] ` <CGME20190424103521epcas3p44a7fc17a216b5696a6feefc781136699@epcms2p8>
  3 siblings, 0 replies; 9+ messages in thread
From: Enrico Weigelt, metux IT consult @ 2019-04-24 10:34 UTC (permalink / raw)
  To: linux-kernel; +Cc: axboe, linux-ide, linux-nvme

libata tpm functionality, needed for self encrypted devices (OPAL, ...),
is currently disabled per default and needs to be enabled via kernel
command line.

This patch allows enabling it via sysctl.

The implementation might look a bit 'naive', as there aren't any locks
or barriers, etc. As we're dealing just w/ a plain boolean value, that's
only checked when an tpm-related ioctl is called, we're fine w/ that.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
---
 drivers/ata/libata-core.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index d3044c9..80ba844 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -177,6 +177,13 @@ struct ata_force_ent {
 MODULE_VERSION(DRV_VERSION);
 
 static struct ctl_table ctl_libata[] = {
+	{
+		.procname	= "allow_tpm",
+		.data		= &libata_allow_tpm,
+		.maxlen		= sizeof(libata_allow_tpm),
+		.mode		= 0644,
+		.proc_handler	= proc_dointvec,
+	},
 	{}
 };
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/3] drivers: nvme: target: core: fix build break
  2019-04-24 10:34 ` [PATCH 1/3] drivers: nvme: target: core: fix build break Enrico Weigelt, metux IT consult
@ 2019-04-24 17:07   ` Sagi Grimberg
  2019-04-25  1:00   ` Chaitanya Kulkarni
  2019-04-25 14:48   ` Christoph Hellwig
  2 siblings, 0 replies; 9+ messages in thread
From: Sagi Grimberg @ 2019-04-24 17:07 UTC (permalink / raw)
  To: Enrico Weigelt, metux IT consult, linux-kernel
  Cc: axboe, linux-ide, linux-nvme

Reviewed-by: Sagi Grimberg <sagi@grimberg.me>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/3] drivers: nvme: target: core: fix build break
  2019-04-24 10:34 ` [PATCH 1/3] drivers: nvme: target: core: fix build break Enrico Weigelt, metux IT consult
  2019-04-24 17:07   ` Sagi Grimberg
@ 2019-04-25  1:00   ` Chaitanya Kulkarni
  2019-04-26 11:48     ` Enrico Weigelt, metux IT consult
  2019-04-25 14:48   ` Christoph Hellwig
  2 siblings, 1 reply; 9+ messages in thread
From: Chaitanya Kulkarni @ 2019-04-25  1:00 UTC (permalink / raw)
  To: Enrico Weigelt, metux IT consult, linux-kernel
  Cc: axboe, linux-ide, linux-nvme

Thanks for the fix Enrico. I'm still wondering on what platform
you got this error ?

Looks good.

Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>

On 04/24/2019 03:35 AM, Enrico Weigelt, metux IT consult wrote:
> Build breaks:
>
>      drivers/nvme/target/core.c: In function 'nvmet_req_alloc_sgl':
>      drivers/nvme/target/core.c:939:12: error: implicit declaration of \
> function 'sgl_alloc'; did you mean 'bio_alloc'? \
> [-Werror=implicit-function-declaration]
>        req->sg = sgl_alloc(req->transfer_len, GFP_KERNEL, &req->sg_cnt);
>                  ^~~~~~~~~
>                  bio_alloc
>      drivers/nvme/target/core.c:939:10: warning: assignment makes pointer \
> from integer without a cast [-Wint-conversion]
>        req->sg = sgl_alloc(req->transfer_len, GFP_KERNEL, &req->sg_cnt);
>                ^
>      drivers/nvme/target/core.c: In function 'nvmet_req_free_sgl':
>      drivers/nvme/target/core.c:952:3: error: implicit declaration of \
> function 'sgl_free'; did you mean 'ida_free'? [-Werror=implicit-function-declaration]
>         sgl_free(req->sg);
>         ^~~~~~~~
>         ida_free
>
> Cause:
>
>      1. missing include to <linux/scatterlist.h>
>      2. SGL_ALLOC needs to be enabled
>
> Therefore adding the missing include, as well as Kconfig dependency.
>
> Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
> ---
>   drivers/nvme/target/Kconfig | 1 +
>   drivers/nvme/target/core.c  | 1 +
>   2 files changed, 2 insertions(+)
>
> diff --git a/drivers/nvme/target/Kconfig b/drivers/nvme/target/Kconfig
> index d94f25c..3ef0a4e 100644
> --- a/drivers/nvme/target/Kconfig
> +++ b/drivers/nvme/target/Kconfig
> @@ -3,6 +3,7 @@ config NVME_TARGET
>   	tristate "NVMe Target support"
>   	depends on BLOCK
>   	depends on CONFIGFS_FS
> +	select SGL_ALLOC
>   	help
>   	  This enabled target side support for the NVMe protocol, that is
>   	  it allows the Linux kernel to implement NVMe subsystems and
> diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c
> index b3e765a..08851f5 100644
> --- a/drivers/nvme/target/core.c
> +++ b/drivers/nvme/target/core.c
> @@ -8,6 +8,7 @@
>   #include <linux/random.h>
>   #include <linux/rculist.h>
>   #include <linux/pci-p2pdma.h>
> +#include <linux/scatterlist.h>
>
>   #include "nvmet.h"
>
>


^ permalink raw reply	[flat|nested] 9+ messages in thread

* RE: [PATCH 1/3] drivers: nvme: target: core: fix build break
       [not found] ` <CGME20190424103521epcas3p44a7fc17a216b5696a6feefc781136699@epcms2p8>
@ 2019-04-25  6:36   ` Minwoo Im
  0 siblings, 0 replies; 9+ messages in thread
From: Minwoo Im @ 2019-04-25  6:36 UTC (permalink / raw)
  To: Enrico Weigelt, metux IT consult
  Cc: linux-kernel, axboe, linux-ide, linux-nvme, Minwoo Im

This looks good to me. 

Reviewed-by: Minwoo Im <minwoo.im@samsung.com>

> -----Original Message-----
> From: Linux-nvme [mailto:linux-nvme-bounces@lists.infradead.org] On Behalf
> Of Enrico Weigelt, metux IT consult
> Sent: Wednesday, April 24, 2019 7:35 PM
> To: linux-kernel@vger.kernel.org
> Cc: axboe@kernel.dk; linux-ide@vger.kernel.org; linux-
> nvme@lists.infradead.org
> Subject: [PATCH 1/3] drivers: nvme: target: core: fix build break
> 
> Build breaks:
> 
>     drivers/nvme/target/core.c: In function 'nvmet_req_alloc_sgl':
>     drivers/nvme/target/core.c:939:12: error: implicit declaration of \
> function 'sgl_alloc'; did you mean 'bio_alloc'? \
> [-Werror=implicit-function-declaration]
>       req->sg = sgl_alloc(req->transfer_len, GFP_KERNEL, &req->sg_cnt);
>                 ^~~~~~~~~
>                 bio_alloc
>     drivers/nvme/target/core.c:939:10: warning: assignment makes pointer \
> from integer without a cast [-Wint-conversion]
>       req->sg = sgl_alloc(req->transfer_len, GFP_KERNEL, &req->sg_cnt);
>               ^
>     drivers/nvme/target/core.c: In function 'nvmet_req_free_sgl':
>     drivers/nvme/target/core.c:952:3: error: implicit declaration of \
> function 'sgl_free'; did you mean 'ida_free'? [-Werror=implicit-function-
> declaration]
>        sgl_free(req->sg);
>        ^~~~~~~~
>        ida_free
> 
> Cause:
> 
>     1. missing include to <linux/scatterlist.h>
>     2. SGL_ALLOC needs to be enabled
> 
> Therefore adding the missing include, as well as Kconfig dependency.
> 
> Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
> ---
>  drivers/nvme/target/Kconfig | 1 +
>  drivers/nvme/target/core.c  | 1 +
>  2 files changed, 2 insertions(+)
> 
> diff --git a/drivers/nvme/target/Kconfig b/drivers/nvme/target/Kconfig
> index d94f25c..3ef0a4e 100644
> --- a/drivers/nvme/target/Kconfig
> +++ b/drivers/nvme/target/Kconfig
> @@ -3,6 +3,7 @@ config NVME_TARGET
>  	tristate "NVMe Target support"
>  	depends on BLOCK
>  	depends on CONFIGFS_FS
> +	select SGL_ALLOC
>  	help
>  	  This enabled target side support for the NVMe protocol, that is
>  	  it allows the Linux kernel to implement NVMe subsystems and
> diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c
> index b3e765a..08851f5 100644
> --- a/drivers/nvme/target/core.c
> +++ b/drivers/nvme/target/core.c
> @@ -8,6 +8,7 @@
>  #include <linux/random.h>
>  #include <linux/rculist.h>
>  #include <linux/pci-p2pdma.h>
> +#include <linux/scatterlist.h>
> 
>  #include "nvmet.h"
> 
> --
> 1.9.1
> 
> 
> _______________________________________________
> Linux-nvme mailing list
> Linux-nvme@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/3] drivers: nvme: target: core: fix build break
  2019-04-24 10:34 ` [PATCH 1/3] drivers: nvme: target: core: fix build break Enrico Weigelt, metux IT consult
  2019-04-24 17:07   ` Sagi Grimberg
  2019-04-25  1:00   ` Chaitanya Kulkarni
@ 2019-04-25 14:48   ` Christoph Hellwig
  2 siblings, 0 replies; 9+ messages in thread
From: Christoph Hellwig @ 2019-04-25 14:48 UTC (permalink / raw)
  To: Enrico Weigelt, metux IT consult
  Cc: linux-kernel, axboe, linux-ide, linux-nvme

Thanks,

applied to nvme-5.2.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/3] drivers: nvme: target: core: fix build break
  2019-04-25  1:00   ` Chaitanya Kulkarni
@ 2019-04-26 11:48     ` Enrico Weigelt, metux IT consult
  0 siblings, 0 replies; 9+ messages in thread
From: Enrico Weigelt, metux IT consult @ 2019-04-26 11:48 UTC (permalink / raw)
  To: Chaitanya Kulkarni, Enrico Weigelt, metux IT consult, linux-kernel
  Cc: axboe, linux-ide, linux-nvme

On 25.04.19 03:00, Chaitanya Kulkarni wrote:
> Thanks for the fix Enrico. I'm still wondering on what platform
> you got this error ?

a pretty standard x86/pc.


--mtx

-- 
Enrico Weigelt, metux IT consult
Free software and Linux embedded engineering
info@metux.net -- +49-151-27565287

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2019-04-26 11:48 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-24 10:34 libata fixes for NVME + OPAL Enrico Weigelt, metux IT consult
2019-04-24 10:34 ` [PATCH 1/3] drivers: nvme: target: core: fix build break Enrico Weigelt, metux IT consult
2019-04-24 17:07   ` Sagi Grimberg
2019-04-25  1:00   ` Chaitanya Kulkarni
2019-04-26 11:48     ` Enrico Weigelt, metux IT consult
2019-04-25 14:48   ` Christoph Hellwig
2019-04-24 10:34 ` [PATCH 2/3] drivers: libata: introduce sysctl directory Enrico Weigelt, metux IT consult
2019-04-24 10:34 ` [PATCH 3/3] drivers: libata: add sysctl: 'libata.allow_tpm' for self-encrypted devices Enrico Weigelt, metux IT consult
     [not found] ` <CGME20190424103521epcas3p44a7fc17a216b5696a6feefc781136699@epcms2p8>
2019-04-25  6:36   ` [PATCH 1/3] drivers: nvme: target: core: fix build break Minwoo Im

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).