]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
nvme: Check for Security send/recv support before issuing commands.
authorScott Bauer <scott.bauer@intel.com>
Fri, 17 Feb 2017 12:59:40 +0000 (13:59 +0100)
committerJens Axboe <axboe@fb.com>
Fri, 17 Feb 2017 19:41:49 +0000 (12:41 -0700)
We need to verify that the controller supports the security
commands before actually trying to issue them.

Signed-off-by: Scott Bauer <scott.bauer@intel.com>
[hch: moved the check so that we don't call into the OPAL code if not
      supported]
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
drivers/nvme/host/core.c
drivers/nvme/host/nvme.h
drivers/nvme/host/pci.c
include/linux/nvme.h

index f6b56a12457a0442aa49faf8e8df00ff571789fe..b4e743d1c0b47bd5c5ba5835899db377947856eb 100644 (file)
@@ -1264,6 +1264,7 @@ int nvme_init_identify(struct nvme_ctrl *ctrl)
                return -EIO;
        }
 
+       ctrl->oacs = le16_to_cpu(id->oacs);
        ctrl->vid = le16_to_cpu(id->vid);
        ctrl->oncs = le16_to_cpup(&id->oncs);
        atomic_set(&ctrl->abort_limit, id->acl + 1);
index fd94c94ccbcb22fce0c6d743e5c45285713a7f0d..b0977229e219994e8e1aa1ba737d0e0b6735a6ca 100644 (file)
@@ -140,6 +140,7 @@ struct nvme_ctrl {
        u32 max_hw_sectors;
        u16 oncs;
        u16 vid;
+       u16 oacs;
        atomic_t abort_limit;
        u8 event_limit;
        u8 vwc;
index 50b070528c50d31b68161c768af5f0cb93c97efe..85896d46aebc305bbc959cc46b7d2442fff5e0b0 100644 (file)
@@ -1792,7 +1792,7 @@ static void nvme_reset_work(struct work_struct *work)
        if (result)
                goto out;
 
-       if (!dev->ctrl.opal_dev) {
+       if ((dev->ctrl.oacs & NVME_CTRL_OACS_SEC_SUPP) && !dev->ctrl.opal_dev) {
                dev->ctrl.opal_dev =
                        init_opal_dev(&dev->ctrl, &nvme_sec_submit);
        }
index 3d1c6f1b15c9bd351fa04d4e9824ff83b5c0045a..00eac863a9c7688a75c631b5f8094bcb4c2eed7b 100644 (file)
@@ -244,6 +244,7 @@ enum {
        NVME_CTRL_ONCS_DSM                      = 1 << 2,
        NVME_CTRL_ONCS_WRITE_ZEROES             = 1 << 3,
        NVME_CTRL_VWC_PRESENT                   = 1 << 0,
+       NVME_CTRL_OACS_SEC_SUPP                 = 1 << 0,
 };
 
 struct nvme_lbaf {