Commit 47b3115a authored by Wenwei Tao's avatar Wenwei Tao Committed by Jens Axboe

nvme: lightnvm: use admin queues for admin cmds

According to the Open-Channel SSD Specification, the NVMe-NVM admin
commands use vendor specific opcodes of NVMe, so use the NVMe admin
queue to dispatch these commands.
Signed-off-by: default avatarWenwei Tao <ww.tao0320@gmail.com>
Updated by me to include set bad block table as well and also use
the admin queue for l2p len calculation.
Signed-off-by: default avatarMatias Bjørling <m@bjorling.me>
Signed-off-by: default avatarJens Axboe <axboe@fb.com>
parent 93e70c1f
...@@ -276,6 +276,7 @@ static int init_grps(struct nvm_id *nvm_id, struct nvme_nvm_id *nvme_nvm_id) ...@@ -276,6 +276,7 @@ static int init_grps(struct nvm_id *nvm_id, struct nvme_nvm_id *nvme_nvm_id)
static int nvme_nvm_identity(struct request_queue *q, struct nvm_id *nvm_id) static int nvme_nvm_identity(struct request_queue *q, struct nvm_id *nvm_id)
{ {
struct nvme_ns *ns = q->queuedata; struct nvme_ns *ns = q->queuedata;
struct nvme_dev *dev = ns->dev;
struct nvme_nvm_id *nvme_nvm_id; struct nvme_nvm_id *nvme_nvm_id;
struct nvme_nvm_command c = {}; struct nvme_nvm_command c = {};
int ret; int ret;
...@@ -288,8 +289,8 @@ static int nvme_nvm_identity(struct request_queue *q, struct nvm_id *nvm_id) ...@@ -288,8 +289,8 @@ static int nvme_nvm_identity(struct request_queue *q, struct nvm_id *nvm_id)
if (!nvme_nvm_id) if (!nvme_nvm_id)
return -ENOMEM; return -ENOMEM;
ret = nvme_submit_sync_cmd(q, (struct nvme_command *)&c, nvme_nvm_id, ret = nvme_submit_sync_cmd(dev->admin_q, (struct nvme_command *)&c,
sizeof(struct nvme_nvm_id)); nvme_nvm_id, sizeof(struct nvme_nvm_id));
if (ret) { if (ret) {
ret = -EIO; ret = -EIO;
goto out; goto out;
...@@ -315,7 +316,7 @@ static int nvme_nvm_get_l2p_tbl(struct request_queue *q, u64 slba, u32 nlb, ...@@ -315,7 +316,7 @@ static int nvme_nvm_get_l2p_tbl(struct request_queue *q, u64 slba, u32 nlb,
struct nvme_ns *ns = q->queuedata; struct nvme_ns *ns = q->queuedata;
struct nvme_dev *dev = ns->dev; struct nvme_dev *dev = ns->dev;
struct nvme_nvm_command c = {}; struct nvme_nvm_command c = {};
u32 len = queue_max_hw_sectors(q) << 9; u32 len = queue_max_hw_sectors(dev->admin_q) << 9;
u32 nlb_pr_rq = len / sizeof(u64); u32 nlb_pr_rq = len / sizeof(u64);
u64 cmd_slba = slba; u64 cmd_slba = slba;
void *entries; void *entries;
...@@ -333,8 +334,8 @@ static int nvme_nvm_get_l2p_tbl(struct request_queue *q, u64 slba, u32 nlb, ...@@ -333,8 +334,8 @@ static int nvme_nvm_get_l2p_tbl(struct request_queue *q, u64 slba, u32 nlb,
c.l2p.slba = cpu_to_le64(cmd_slba); c.l2p.slba = cpu_to_le64(cmd_slba);
c.l2p.nlb = cpu_to_le32(cmd_nlb); c.l2p.nlb = cpu_to_le32(cmd_nlb);
ret = nvme_submit_sync_cmd(q, (struct nvme_command *)&c, ret = nvme_submit_sync_cmd(dev->admin_q,
entries, len); (struct nvme_command *)&c, entries, len);
if (ret) { if (ret) {
dev_err(dev->dev, "L2P table transfer failed (%d)\n", dev_err(dev->dev, "L2P table transfer failed (%d)\n",
ret); ret);
...@@ -375,7 +376,8 @@ static int nvme_nvm_get_bb_tbl(struct request_queue *q, struct ppa_addr ppa, ...@@ -375,7 +376,8 @@ static int nvme_nvm_get_bb_tbl(struct request_queue *q, struct ppa_addr ppa,
if (!bb_tbl) if (!bb_tbl)
return -ENOMEM; return -ENOMEM;
ret = nvme_submit_sync_cmd(q, (struct nvme_command *)&c, bb_tbl, tblsz); ret = nvme_submit_sync_cmd(dev->admin_q, (struct nvme_command *)&c,
bb_tbl, tblsz);
if (ret) { if (ret) {
dev_err(dev->dev, "get bad block table failed (%d)\n", ret); dev_err(dev->dev, "get bad block table failed (%d)\n", ret);
ret = -EIO; ret = -EIO;
...@@ -427,7 +429,8 @@ static int nvme_nvm_set_bb_tbl(struct request_queue *q, struct nvm_rq *rqd, ...@@ -427,7 +429,8 @@ static int nvme_nvm_set_bb_tbl(struct request_queue *q, struct nvm_rq *rqd,
c.set_bb.nlb = cpu_to_le16(rqd->nr_pages - 1); c.set_bb.nlb = cpu_to_le16(rqd->nr_pages - 1);
c.set_bb.value = type; c.set_bb.value = type;
ret = nvme_submit_sync_cmd(q, (struct nvme_command *)&c, NULL, 0); ret = nvme_submit_sync_cmd(dev->admin_q, (struct nvme_command *)&c,
NULL, 0);
if (ret) if (ret)
dev_err(dev->dev, "set bad block table failed (%d)\n", ret); dev_err(dev->dev, "set bad block table failed (%d)\n", ret);
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment