aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWenwei Tao <ww.tao0320@gmail.com>2015-11-20 07:47:55 -0500
committerJens Axboe <axboe@fb.com>2015-11-20 10:33:18 -0500
commit47b3115ae7b799be8b77b0f024215ad4f68d6460 (patch)
treebee158866a8553c1652412e58130086183c95372
parent93e70c1f2883f2db2d6a1f339d0e26f00b138e4e (diff)
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: Wenwei 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: Matias Bjørling <m@bjorling.me> Signed-off-by: Jens Axboe <axboe@fb.com>
-rw-r--r--drivers/nvme/host/lightnvm.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/drivers/nvme/host/lightnvm.c b/drivers/nvme/host/lightnvm.c
index 7e82fe33d6f8..9202d1a468d0 100644
--- a/drivers/nvme/host/lightnvm.c
+++ b/drivers/nvme/host/lightnvm.c
@@ -276,6 +276,7 @@ static int init_grps(struct nvm_id *nvm_id, struct nvme_nvm_id *nvme_nvm_id)
276static int nvme_nvm_identity(struct request_queue *q, struct nvm_id *nvm_id) 276static int nvme_nvm_identity(struct request_queue *q, struct nvm_id *nvm_id)
277{ 277{
278 struct nvme_ns *ns = q->queuedata; 278 struct nvme_ns *ns = q->queuedata;
279 struct nvme_dev *dev = ns->dev;
279 struct nvme_nvm_id *nvme_nvm_id; 280 struct nvme_nvm_id *nvme_nvm_id;
280 struct nvme_nvm_command c = {}; 281 struct nvme_nvm_command c = {};
281 int ret; 282 int ret;
@@ -288,8 +289,8 @@ static int nvme_nvm_identity(struct request_queue *q, struct nvm_id *nvm_id)
288 if (!nvme_nvm_id) 289 if (!nvme_nvm_id)
289 return -ENOMEM; 290 return -ENOMEM;
290 291
291 ret = nvme_submit_sync_cmd(q, (struct nvme_command *)&c, nvme_nvm_id, 292 ret = nvme_submit_sync_cmd(dev->admin_q, (struct nvme_command *)&c,
292 sizeof(struct nvme_nvm_id)); 293 nvme_nvm_id, sizeof(struct nvme_nvm_id));
293 if (ret) { 294 if (ret) {
294 ret = -EIO; 295 ret = -EIO;
295 goto out; 296 goto out;
@@ -315,7 +316,7 @@ static int nvme_nvm_get_l2p_tbl(struct request_queue *q, u64 slba, u32 nlb,
315 struct nvme_ns *ns = q->queuedata; 316 struct nvme_ns *ns = q->queuedata;
316 struct nvme_dev *dev = ns->dev; 317 struct nvme_dev *dev = ns->dev;
317 struct nvme_nvm_command c = {}; 318 struct nvme_nvm_command c = {};
318 u32 len = queue_max_hw_sectors(q) << 9; 319 u32 len = queue_max_hw_sectors(dev->admin_q) << 9;
319 u32 nlb_pr_rq = len / sizeof(u64); 320 u32 nlb_pr_rq = len / sizeof(u64);
320 u64 cmd_slba = slba; 321 u64 cmd_slba = slba;
321 void *entries; 322 void *entries;
@@ -333,8 +334,8 @@ static int nvme_nvm_get_l2p_tbl(struct request_queue *q, u64 slba, u32 nlb,
333 c.l2p.slba = cpu_to_le64(cmd_slba); 334 c.l2p.slba = cpu_to_le64(cmd_slba);
334 c.l2p.nlb = cpu_to_le32(cmd_nlb); 335 c.l2p.nlb = cpu_to_le32(cmd_nlb);
335 336
336 ret = nvme_submit_sync_cmd(q, (struct nvme_command *)&c, 337 ret = nvme_submit_sync_cmd(dev->admin_q,
337 entries, len); 338 (struct nvme_command *)&c, entries, len);
338 if (ret) { 339 if (ret) {
339 dev_err(dev->dev, "L2P table transfer failed (%d)\n", 340 dev_err(dev->dev, "L2P table transfer failed (%d)\n",
340 ret); 341 ret);
@@ -375,7 +376,8 @@ static int nvme_nvm_get_bb_tbl(struct request_queue *q, struct ppa_addr ppa,
375 if (!bb_tbl) 376 if (!bb_tbl)
376 return -ENOMEM; 377 return -ENOMEM;
377 378
378 ret = nvme_submit_sync_cmd(q, (struct nvme_command *)&c, bb_tbl, tblsz); 379 ret = nvme_submit_sync_cmd(dev->admin_q, (struct nvme_command *)&c,
380 bb_tbl, tblsz);
379 if (ret) { 381 if (ret) {
380 dev_err(dev->dev, "get bad block table failed (%d)\n", ret); 382 dev_err(dev->dev, "get bad block table failed (%d)\n", ret);
381 ret = -EIO; 383 ret = -EIO;
@@ -427,7 +429,8 @@ static int nvme_nvm_set_bb_tbl(struct request_queue *q, struct nvm_rq *rqd,
427 c.set_bb.nlb = cpu_to_le16(rqd->nr_pages - 1); 429 c.set_bb.nlb = cpu_to_le16(rqd->nr_pages - 1);
428 c.set_bb.value = type; 430 c.set_bb.value = type;
429 431
430 ret = nvme_submit_sync_cmd(q, (struct nvme_command *)&c, NULL, 0); 432 ret = nvme_submit_sync_cmd(dev->admin_q, (struct nvme_command *)&c,
433 NULL, 0);
431 if (ret) 434 if (ret)
432 dev_err(dev->dev, "set bad block table failed (%d)\n", ret); 435 dev_err(dev->dev, "set bad block table failed (%d)\n", ret);
433 return ret; 436 return ret;