Subject: libata fixes for NVME + OPAL

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


Subject: [PATCH 2/3] drivers: libata: introduce sysctl directory

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

Signed-off-by: Enrico Weigelt, metux IT consult <[email protected]>
---
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

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 <[email protected]>
---
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

Subject: [PATCH 3/3] drivers: libata: add sysctl: 'libata.allow_tpm' for self-encrypted devices

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 <[email protected]>
---
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

2019-04-25 07:54:02

by Chaitanya Kulkarni

[permalink] [raw]
Subject: Re: [PATCH 1/3] drivers: nvme: target: core: fix build break

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

Looks good.

Reviewed-by: Chaitanya Kulkarni <[email protected]>

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 <[email protected]>
> ---
> 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"
>
>

2019-04-25 08:23:22

by Minwoo Im

[permalink] [raw]
Subject: RE: [PATCH 1/3] drivers: nvme: target: core: fix build break

This looks good to me.

Reviewed-by: Minwoo Im <[email protected]>

> -----Original Message-----
> From: Linux-nvme [mailto:[email protected]] On Behalf
> Of Enrico Weigelt, metux IT consult
> Sent: Wednesday, April 24, 2019 7:35 PM
> To: [email protected]
> Cc: [email protected]; [email protected]; linux-
> [email protected]
> 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 <[email protected]>
> ---
> 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
> [email protected]
> http://lists.infradead.org/mailman/listinfo/linux-nvme

2019-04-25 14:49:23

by Christoph Hellwig

[permalink] [raw]
Subject: Re: [PATCH 1/3] drivers: nvme: target: core: fix build break

Thanks,

applied to nvme-5.2.

Subject: Re: [PATCH 1/3] drivers: nvme: target: core: fix build break

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
[email protected] -- +49-151-27565287