summaryrefslogtreecommitdiff
path: root/drivers/nvme/host/core.c
diff options
context:
space:
mode:
authorScott Bauer <scott.bauer@intel.com>2017-02-03 22:50:32 +0300
committerJens Axboe <axboe@fb.com>2017-02-06 19:44:21 +0300
commita98e58e54fbd0c80b6a46a7cac6e231eed3b3efa (patch)
treefa346839016a9667d47cf28d0744828d9db93006 /drivers/nvme/host/core.c
parent455a7b238cd6bc68c4a550cbbd37c1e22b64f71c (diff)
downloadlinux-a98e58e54fbd0c80b6a46a7cac6e231eed3b3efa.tar.xz
nvme: Add Support for Opal: Unlock from S3 & Opal Allocation/Ioctls
This patch implements the necessary logic to unlock an Opal enabled device coming back from an S3. The patch also implements the SED/Opal allocation necessary to support the opal ioctls. Signed-off-by: Scott Bauer <scott.bauer@intel.com> Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'drivers/nvme/host/core.c')
-rw-r--r--drivers/nvme/host/core.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 037ee999e759..26ae4afd3737 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -788,6 +788,8 @@ static int nvme_ioctl(struct block_device *bdev, fmode_t mode,
if (ns->ndev)
return nvme_nvm_ioctl(ns, cmd, arg);
#endif
+ if (is_sed_ioctl(cmd))
+ return sed_ioctl(&ns->ctrl->opal_dev, cmd, arg);
return -ENOTTY;
}
}
@@ -1055,6 +1057,29 @@ static const struct pr_ops nvme_pr_ops = {
.pr_clear = nvme_pr_clear,
};
+#ifdef CONFIG_BLK_SED_OPAL
+int nvme_sec_submit(struct opal_dev *dev, u16 spsp, u8 secp,
+ void *buffer, size_t len, bool send)
+{
+ 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);
+
+ return __nvme_submit_sync_cmd(ctrl->admin_q, &cmd, NULL, buffer, len,
+ ADMIN_TIMEOUT, NVME_QID_ANY, 1, 0);
+}
+EXPORT_SYMBOL_GPL(nvme_sec_submit);
+#endif /* CONFIG_BLK_SED_OPAL */
+
static const struct block_device_operations nvme_fops = {
.owner = THIS_MODULE,
.ioctl = nvme_ioctl,