block/sed-opal: tone down not supported warnings
Subsystems (3)
Christoph Hellwig
maintainerPATCH 1/2 block/sed-opal: tone down not supported warnings
Not having OPAL or a sub-feature supported is an entirely normal condition for many drives, so don't warn about it. Keep the messages, but tone them down to debug only.
--- block/sed-opal.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
block/sed-opal.c +4 -4
@@ -387,16 +387,16 @@ static int opal_discovery0_end(struct opal_dev *dev) }if (!supported) { -pr_err ("This device is not Opal enabled. Not Supported!\n" ); +pr_debug ("This device is not Opal enabled. Not Supported!\n" );return -EOPNOTSUPP ; }if (!single_user) -pr_warn ("Device doesn't support single user mode\n" ); +pr_debug ("Device doesn't support single user mode\n" );if (!found_com_id) { -pr_warn ("Could not find OPAL comid for device. Returning early\n" ); +pr_debug ("Could not find OPAL comid for device. Returning early\n" );return -EOPNOTSUPP ;; }
@@ -1951,7 +1951,7 @@ void init_opal_dev(struct opal_dev *opal_dev, sec_send_recv *send_recv)mutex_init (&opal_dev->dev_lock); opal_dev->send_recv = send_recv;if (check_opal_support (opal_dev) <0 ) -pr_warn ("Opal is not supported on this device\n" ); +pr_debug ("Opal is not supported on this device\n" ); opal_dev->initialized = true; }EXPORT_SYMBOL (init_opal_dev);
Signature · 1 line
2.11.0
Christoph Hellwig
maintainerPATCH 2/2 block/sed-opal: allocate struct opal_dev dynamically
Insted of bloating the containing structure with it all the time this allocates struct opal_dev dynamically. Additionally this allows moving the definition of struct opal_dev into sed-opal.c. For this a new private data field is added to it that is passed to the send/receive callback. After that a lot of internals can be made private as well.
--- block/opal_proto.h | 23 ++++++++++ block/sed-opal.c | 101 +++++++++++++++++++++++++++++++++++++---- drivers/nvme/host/core.c | 9 ++-- drivers/nvme/host/nvme.h | 14 ++---- drivers/nvme/host/pci.c | 8 +++- include/linux/sed-opal.h | 116 ++--------------------------------------------- 6 files changed, 131 insertions(+), 140 deletions(-)
block/opal_proto.h +23 -0
@@ -19,6 +19,29 @@#ifndef _OPAL_PROTO_H#define _OPAL_PROTO_H +/* +* These constant values come from: +* SPC-4 section +* 6.30 SECURITY PROTOCOL IN command / table 265. +*/ +enum { +TCG_SECP_00 =0 , +TCG_SECP_01 , +}; + +/* +* Token defs derived from: +* TCG_Storage_Architecture_Core_Spec_v2.01_r1.00 +* 3.2.2 Data Stream Encoding +*/ +enum opal_response_token { +OPAL_DTA_TOKENID_BYTESTRING =0xe0 , +OPAL_DTA_TOKENID_SINT =0xe1 , +OPAL_DTA_TOKENID_UINT =0xe2 , +OPAL_DTA_TOKENID_TOKEN =0xe3 ,/* actual token is returned */ +OPAL_DTA_TOKENID_INVALID =0X0 +}; +#define DTAERROR_NO_METHOD_STATUS 0x89#define GENERIC_HOST_SESSION_NUM 0x41
block/sed-opal.c +91 -10
133 lines not on this page · raw message
drivers/nvme/host/core.c +4 -5
@@ -811,7 +811,7 @@ static int nvme_ioctl(struct block_device *bdev, fmode_t mode,return nvme_nvm_ioctl (ns, cmd, arg);#endif if (is_sed_ioctl (cmd)) -return sed_ioctl (&ns->ctrl->opal_dev, cmd, +return sed_ioctl (ns->ctrl->opal_dev, cmd, (void __user *) arg);return -ENOTTY ; }
@@ -1085,18 +1085,17 @@ static const struct pr_ops nvme_pr_ops = { };#ifdef CONFIG_BLK_SED_OPAL -int nvme_sec_submit (struct opal_dev *dev,u16 spsp,u8 secp, -void *buffer,size_t len,bool send) +int nvme_sec_submit (void *data,u16 spsp,u8 secp,void *buffer,size_t len, +bool send) { +struct nvme_ctrl *ctrl = data;struct nvme_command cmd; -struct nvme_ctrl *ctrl =NULL ;memset (&cmd,0 ,sizeof (cmd));if (send) cmd.common.opcode = nvme_admin_security_send;else cmd.common.opcode = nvme_admin_security_recv; - ctrl = container_of(dev, struct nvme_ctrl, opal_dev); cmd.common.nsid =0 ; cmd.common.cdw10[0 ] =cpu_to_le32 (((u32 )secp) <<24 | ((u32 )spsp) <<8 ); cmd.common.cdw10[1 ] =cpu_to_le32 (len);
drivers/nvme/host/nvme.h +3 -11
@@ -126,7 +126,7 @@ struct nvme_ctrl {struct list_head node;struct ida ns_ida; -struct opal_dev opal_dev; +struct opal_dev *opal_dev;char name[12 ];char serial[20 ];
@@ -270,16 +270,8 @@ int nvme_init_identify(struct nvme_ctrl *ctrl);void nvme_queue_scan (struct nvme_ctrl *ctrl);void nvme_remove_namespaces (struct nvme_ctrl *ctrl); -#ifdef CONFIG_BLK_SED_OPAL -int nvme_sec_submit (struct opal_dev *dev,u16 spsp,u8 secp, -void *buffer,size_t len,bool send); -#else -static inline int nvme_sec_submit (struct opal_dev *dev,u16 spsp,u8 secp, -void *buffer,size_t len,bool send) -{ -return 0 ; -} -#endif /* CONFIG_BLK_DEV_SED_OPAL */ +int nvme_sec_submit (void *data,u16 spsp,u8 secp,void *buffer,size_t len, +bool send);#define NVME_NR_AERS 1 void nvme_complete_async_event(struct nvme_ctrl *ctrl, __le16 status,
drivers/nvme/host/pci.c +6 -2
@@ -1739,6 +1739,7 @@ static void nvme_pci_free_ctrl(struct nvme_ctrl *ctrl)if (dev->ctrl.admin_q)blk_put_queue (dev->ctrl.admin_q);kfree (dev->queues); +kfree (dev->ctrl.opal_dev);kfree (dev); }
@@ -1788,10 +1789,13 @@ static void nvme_reset_work(struct work_struct *work)if (result) goto out; -init_opal_dev (&dev->ctrl.opal_dev, &nvme_sec_submit); +if (!dev->ctrl.opal_dev) { + dev->ctrl.opal_dev = +init_opal_dev (&dev->ctrl, &nvme_sec_submit); + }if (was_suspend) -opal_unlock_from_suspend (&dev->ctrl.opal_dev); +opal_unlock_from_suspend (dev->ctrl.opal_dev); result =nvme_setup_io_queues (dev);if (result)
include/linux/sed-opal.h +4 -112
132 lines not on this page · raw message
Signature · 1 line
2.11.0
Re: [PATCH 2/2] block/sed-opal: allocate struct opal_dev dynamically
Quoted 7 lines · Christoph Hellwig
Insted of bloating the containing structure with it all the time this allocates struct
opal_devdynamically. Additionally this allows moving the definition of structopal_devintosed-opal.c. For this a new private data field is added to it that is passed to the send/receive callback. After that a lot of internals can be made private as well.Signed-off-by Christoph Hellwig <hch at lst.de>
Don't know if we need both but:
Re: [PATCH 2/2] block/sed-opal: allocate struct opal_dev dynamically
In reply to Christoph Hellwiginclude/linux/sed-opal.h line 61
Quoted 6 lines · Christoph Hellwig
include/linux/sed-opal.h +0
-6-enum opal_response_token { -OPAL_DTA_TOKENID_BYTESTRING =0xe0 , -OPAL_DTA_TOKENID_SINT =0xe1 , -OPAL_DTA_TOKENID_UINT =0xe2 , -OPAL_DTA_TOKENID_TOKEN =0xe3 ,/* actual token is returned */ -OPAL_DTA_TOKENID_INVALID =0X0
Nit, here's a capital 'X' that slipped in
Signature · 6 lines
Johannes Thumshirn Storage jthumshirn at suse.de +49 911 74053 689 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N?rnberg GF: Felix Imend?rffer, Jane Smithard, Graham Norton HRB 21284 (AG N?rnberg) Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
Christoph Hellwig
maintainerRe: [PATCH 2/2] block/sed-opal: allocate struct opal_dev dynamically
Quoted 9 lines · Johannes Thumshirn
include/linux/sed-opal.h line 61
Quoted 6 lines · Christoph Hellwig
include/linux/sed-opal.h +0
-6-enum opal_response_token { -OPAL_DTA_TOKENID_BYTESTRING =0xe0 , -OPAL_DTA_TOKENID_SINT =0xe1 , -OPAL_DTA_TOKENID_UINT =0xe2 , -OPAL_DTA_TOKENID_TOKEN =0xe3 ,/* actual token is returned */ -OPAL_DTA_TOKENID_INVALID =0X0 Nit, here's a capital 'X' that slipped in
I just moved the existing definition around 1:1.
Re: [PATCH 2/2] block/sed-opal: allocate struct opal_dev dynamically
Quoted 1 line · Christoph Hellwig
I just moved the existing definition around 1:1.
Just saw it's - anyways. So sorry for the noise and I'll grab another coffee
Signature · 6 lines
Johannes Thumshirn Storage jthumshirn at suse.de +49 911 74053 689 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N?rnberg GF: Felix Imend?rffer, Jane Smithard, Graham Norton HRB 21284 (AG N?rnberg) Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
Quoted 5 lines · Christoph Hellwig
Not having OPAL or a sub-feature supported is an entirely normal condition for many drives, so don't warn about it. Keep the messages, but tone them down to debug only.
Signed-off-by Christoph Hellwig <hch at lst.de>