Skip to contentSkip to conversation

nvme: lightnvm: use nvme admin queue

PATCH In review Wenwei Tao 2 participants 2 messages Nov 20, 2015 NVMe

lore
Share & tools
lore

Wenwei Tao

author
#0 lore raw

PATCH 1/1 nvme: lightnvm: use nvme admin queue

According to Open-ChannelSSDInterfaceSpecification 0.1, NVMe-NVM admin commands use vendor specific admin opcodes of NVMe, so use the NVMe admin queue to dispatch these commands

---
 drivers/nvme/host/lightnvm.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/nvme/host/lightnvm.c +7 -6
index e0b7b95..7d1981d 100644
@@ -244,6 +244,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)
 {
 	struct nvme_ns *ns = q->queuedata;
+	struct nvme_dev *dev = ns->dev;
 	struct nvme_nvm_id *nvme_nvm_id;
 	struct nvme_nvm_command c = {};
 	int ret;
@@ -256,8 +257,8 @@ static int nvme_nvm_identity(struct request_queue *q, struct nvm_id *nvm_id)
 	if (!nvme_nvm_id)
 		return -ENOMEM;
 
-	ret = nvme_submit_sync_cmd(q, (struct nvme_command *)&c, nvme_nvm_id,
-						sizeof(struct nvme_nvm_id));
+	ret = nvme_submit_sync_cmd(dev->admin_q, (struct nvme_command *)&c,
+				nvme_nvm_id, sizeof(struct nvme_nvm_id));
 	if (ret) {
 		ret = -EIO;
 		goto out;
@@ -299,8 +300,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.nlb = cpu_to_le32(cmd_nlb);
 
-		ret = nvme_submit_sync_cmd(q, (struct nvme_command *)&c,
-								entries, len);
+		ret = nvme_submit_sync_cmd(dev->admin_q,
+				(struct nvme_command *)&c, entries, len);
 		if (ret) {
 			dev_err(dev->dev, "L2P table transfer failed (%d)\n",
 									ret);
@@ -343,8 +344,8 @@ static int nvme_nvm_get_bb_tbl(struct request_queue *q, int lunid,
 
 	bitmap_zero(bb_bitmap, nr_blocks);
 
-	ret = nvme_submit_sync_cmd(q, (struct nvme_command *)&c, bb_bitmap,
-								bb_bitmap_size);
+	ret = nvme_submit_sync_cmd(dev->admin_q, (struct nvme_command *)&c,
+						bb_bitmap, bb_bitmap_size);
 	if (ret) {
 		dev_err(dev->dev, "get bad block table failed (%d)\n", ret);
 		ret = -EIO;
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 46 lines · Wenwei Tao

According to Open-ChannelSSDInterfaceSpecification 0.1, NVMe-NVM admin commands use vendor specific admin opcodes of NVMe, so use the NVMe admin queue to dispatch these commands

---
  drivers/nvme/host/lightnvm.c | 13 +++++++------
  1 file changed, 7 insertions(+), 6 deletions(-)
drivers/nvme/host/lightnvm.c +5 -4
index e0b7b95..7d1981d 100644
@@ -244,6 +244,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)
  {
  	struct nvme_ns *ns = q->queuedata;
+	struct nvme_dev *dev = ns->dev;
  	struct nvme_nvm_id *nvme_nvm_id;
  	struct nvme_nvm_command c = {};
  	int ret;
@@ -256,8 +257,8 @@ static int nvme_nvm_identity(struct request_queue *q, struct nvm_id *nvm_id)
  	if (!nvme_nvm_id)
  		return -ENOMEM;
 
-	ret = nvme_submit_sync_cmd(q, (struct nvme_command *)&c, nvme_nvm_id,
-						sizeof(struct nvme_nvm_id));
+	ret = nvme_submit_sync_cmd(dev->admin_q, (struct nvme_command *)&c,
+				nvme_nvm_id, sizeof(struct nvme_nvm_id));
  	if (ret) {
  		ret = -EIO;
  		goto out;
@@ -299,8 +300,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.nlb = cpu_to_le32(cmd_nlb);
 
-		ret = nvme_submit_sync_cmd(q, (struct nvme_command *)&c,
-								entries, len);
+		ret = nvme_submit_sync_cmd(dev->admin_q,
+				(struct nvme_command *)&c, entries, len);
  		if (ret) {
  			dev_err(dev->dev, "L2P table transfer failed (%d)\n",
  									ret);

drivers/nvme/host/lightnvm.c static int nvme_nvm_get_bb_tbl(struct request_queue *q, int lunid, · line 351

Quoted 10 lines
drivers/nvme/host/lightnvm.c +2 -2
@@ -343,8 +344,8 @@ static int nvme_nvm_get_bb_tbl(struct request_queue *q, int lunid,
 
  	bitmap_zero(bb_bitmap, nr_blocks);
 
-	ret = nvme_submit_sync_cmd(q, (struct nvme_command *)&c, bb_bitmap,
-								bb_bitmap_size);
+	ret = nvme_submit_sync_cmd(dev->admin_q, (struct nvme_command *)&c,
+						bb_bitmap, bb_bitmap_size);
  	if (ret) {
  		dev_err(dev->dev, "get bad block table failed (%d)\n", ret);
  		ret = -EIO;

Thanks Tao. I've added the bb set as well and a small fix to the l2p.