Skip to contentSkip to conversation

nvme/fc: use real sqsize as argument when connecting queues

PATCH In review Hannes Reinecke 5 participants 6 messages Mar 13, 2020 – Mar 26, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nvme/fc: use real sqsize as argument when connecting queues

When creating queues we should be passing in the real sqsize number, and not increasing it by one just so that the function has to substract it again.

---
 drivers/nvme/host/fc.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/nvme/host/fc.c +6 -6
index 0cbc4a703359..f76325a47578 100644
@@ -1211,7 +1211,7 @@ nvme_fc_connect_admin_queue(struct nvme_fc_ctrl *ctrl,
 				sizeof(struct fcnvme_lsdesc_cr_assoc_cmd));
 
 	assoc_rqst->assoc_cmd.ersp_ratio = cpu_to_be16(ersp_ratio);
-	assoc_rqst->assoc_cmd.sqsize = cpu_to_be16(qsize - 1);
+	assoc_rqst->assoc_cmd.sqsize = cpu_to_be16(qsize);
 	/* Linux supports only Dynamic controllers */
 	assoc_rqst->assoc_cmd.cntlid = cpu_to_be16(0xffff);
 	uuid_copy(&assoc_rqst->assoc_cmd.hostid, &ctrl->ctrl.opts->host->id);
@@ -1326,7 +1326,7 @@ nvme_fc_connect_queue(struct nvme_fc_ctrl *ctrl, struct nvme_fc_queue *queue,
 				sizeof(struct fcnvme_lsdesc_cr_conn_cmd));
 	conn_rqst->connect_cmd.ersp_ratio = cpu_to_be16(ersp_ratio);
 	conn_rqst->connect_cmd.qid  = cpu_to_be16(queue->qnum);
-	conn_rqst->connect_cmd.sqsize = cpu_to_be16(qsize - 1);
+	conn_rqst->connect_cmd.sqsize = cpu_to_be16(qsize);
 
 	lsop->queue = queue;
 	lsreq->rqstaddr = conn_rqst;
@@ -2484,11 +2484,11 @@ nvme_fc_create_io_queues(struct nvme_fc_ctrl *ctrl)
 		goto out_free_tag_set;
 	}
 
-	ret = nvme_fc_create_hw_io_queues(ctrl, ctrl->ctrl.sqsize + 1);
+	ret = nvme_fc_create_hw_io_queues(ctrl, ctrl->ctrl.sqsize);
 	if (ret)
 		goto out_cleanup_blk_queue;
 
-	ret = nvme_fc_connect_io_queues(ctrl, ctrl->ctrl.sqsize + 1);
+	ret = nvme_fc_connect_io_queues(ctrl, ctrl->ctrl.sqsize);
 	if (ret)
 		goto out_delete_hw_queues;
 
@@ -2539,11 +2539,11 @@ nvme_fc_recreate_io_queues(struct nvme_fc_ctrl *ctrl)
 	if (ctrl->ctrl.queue_count == 1)
 		return 0;
 
-	ret = nvme_fc_create_hw_io_queues(ctrl, ctrl->ctrl.sqsize + 1);
+	ret = nvme_fc_create_hw_io_queues(ctrl, ctrl->ctrl.sqsize);
 	if (ret)
 		goto out_free_io_queues;
 
-	ret = nvme_fc_connect_io_queues(ctrl, ctrl->ctrl.sqsize + 1);
+	ret = nvme_fc_connect_io_queues(ctrl, ctrl->ctrl.sqsize);
 	if (ret)
 		goto out_delete_hw_queues;
 
Signature · 7 lines
2.16.4


_______________________________________________
linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
maintainer
#1 lore raw
Quoted 3 lines · Hannes Reinecke

When creating queues we should be passing in the real sqsize number, and not increasing it by one just so that the function has to substract it again.

Kinda makes more sense to pass around actual queue size and not the zero-based version of it, isn't it?

Quoted 29 lines
---
  drivers/nvme/host/fc.c | 12 ++++++------
  1 file changed, 6 insertions(+), 6 deletions(-)
drivers/nvme/host/fc.c +2 -2
index 0cbc4a703359..f76325a47578 100644
@@ -1211,7 +1211,7 @@ nvme_fc_connect_admin_queue(struct nvme_fc_ctrl *ctrl,
  				sizeof(struct fcnvme_lsdesc_cr_assoc_cmd));
 
  	assoc_rqst->assoc_cmd.ersp_ratio = cpu_to_be16(ersp_ratio);
-	assoc_rqst->assoc_cmd.sqsize = cpu_to_be16(qsize - 1);
+	assoc_rqst->assoc_cmd.sqsize = cpu_to_be16(qsize);
  	/* Linux supports only Dynamic controllers */
  	assoc_rqst->assoc_cmd.cntlid = cpu_to_be16(0xffff);
  	uuid_copy(&assoc_rqst->assoc_cmd.hostid, &ctrl->ctrl.opts->host->id);
@@ -1326,7 +1326,7 @@ nvme_fc_connect_queue(struct nvme_fc_ctrl *ctrl, struct nvme_fc_queue *queue,
  				sizeof(struct fcnvme_lsdesc_cr_conn_cmd));
  	conn_rqst->connect_cmd.ersp_ratio = cpu_to_be16(ersp_ratio);
  	conn_rqst->connect_cmd.qid  = cpu_to_be16(queue->qnum);
-	conn_rqst->connect_cmd.sqsize = cpu_to_be16(qsize - 1);
+	conn_rqst->connect_cmd.sqsize = cpu_to_be16(qsize);
 
  	lsop->queue = queue;
  	lsreq->rqstaddr = conn_rqst;

drivers/nvme/host/fc.c nvme_fc_create_io_queues(struct nvme_fc_ctrl *ctrl) · line 2487

Quoted 5 lines
drivers/nvme/host/fc.c +1 -1
@@ -2484,11 +2484,11 @@ nvme_fc_create_io_queues(struct nvme_fc_ctrl *ctrl)
  		goto out_free_tag_set;
  	}
 
-	ret = nvme_fc_create_hw_io_queues(ctrl, ctrl->ctrl.sqsize + 1);
+	ret = nvme_fc_create_hw_io_queues(ctrl, ctrl->ctrl.sqsize);

What if the LLDD will allocate based on this argument?

Quoted 13 lines
drivers/nvme/host/fc.c +1 -1
  	if (ret)
  		goto out_cleanup_blk_queue;
 
-	ret = nvme_fc_connect_io_queues(ctrl, ctrl->ctrl.sqsize + 1);
+	ret = nvme_fc_connect_io_queues(ctrl, ctrl->ctrl.sqsize);
  	if (ret)
  		goto out_delete_hw_queues;
 
@@ -2539,11 +2539,11 @@ nvme_fc_recreate_io_queues(struct nvme_fc_ctrl *ctrl)
  	if (ctrl->ctrl.queue_count == 1)
  		return 0;
 

drivers/nvme/host/fc.c nvme_fc_recreate_io_queues(struct nvme_fc_ctrl *ctrl) · line 2549

Quoted 10 lines
drivers/nvme/host/fc.c +2 -2
-	ret = nvme_fc_create_hw_io_queues(ctrl, ctrl->ctrl.sqsize + 1);
+	ret = nvme_fc_create_hw_io_queues(ctrl, ctrl->ctrl.sqsize);
  	if (ret)
  		goto out_free_io_queues;
 
-	ret = nvme_fc_connect_io_queues(ctrl, ctrl->ctrl.sqsize + 1);
+	ret = nvme_fc_connect_io_queues(ctrl, ctrl->ctrl.sqsize);
  	if (ret)
  		goto out_delete_hw_queues;
 

_______________________________________________
linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme

#2 lore raw
Quoted 9 lines · Sagi Grimberg
Quoted 3 lines · Hannes Reinecke

When creating queues we should be passing in the real sqsize number, and not increasing it by one just so that the function has to substract it again.

Kinda makes more sense to pass around actual queue size and not the zero-based version of it, isn't it?

Oh, it would.
But then I would have expected ctrl->sqsize carrying the 'real' queue size. Which we currently don't (That why I've sent the other patch).

But calling a function with (arg + 1), just so that the function body does an 'arg - 1' internally is totally pointless.

What I'm aiming at with these patches is to keep ctrl->sqsize as the real (1-based) size, to be converted to the wire format (0-based) when actually put on the wire. And allocating the tagset with (ctrl-sqsize - 1) to cover the queue full detected as mandated by the spec.

I'll be reviewing the patches with that in mind and will be resending a new version.

Cheers,

Hannes

Signature · 9 lines
Dr. Hannes Reinecke            Teamlead Storage & Networking
[email protected]                               +49 911 74053 688
SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer

_______________________________________________
linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
maintainer Reviewed-by on v1 1/1
#3 lore raw
In reply to Hannes Reinecke
Quoted 3 lines · Hannes Reinecke

When creating queues we should be passing in the real sqsize number, and not increasing it by one just so that the function has to substract it again.

Kind of makes me wonder: why are we even passing the sq size as a parameter at all? The 'ctrl' parameter provides the same thing.

Anyway, this looks correct to me.

Quoted 57 lines
---
 drivers/nvme/host/fc.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/nvme/host/fc.c +6 -6
index 0cbc4a703359..f76325a47578 100644
@@ -1211,7 +1211,7 @@ nvme_fc_connect_admin_queue(struct nvme_fc_ctrl *ctrl,
 				sizeof(struct fcnvme_lsdesc_cr_assoc_cmd));
 
 	assoc_rqst->assoc_cmd.ersp_ratio = cpu_to_be16(ersp_ratio);
-	assoc_rqst->assoc_cmd.sqsize = cpu_to_be16(qsize - 1);
+	assoc_rqst->assoc_cmd.sqsize = cpu_to_be16(qsize);
 	/* Linux supports only Dynamic controllers */
 	assoc_rqst->assoc_cmd.cntlid = cpu_to_be16(0xffff);
 	uuid_copy(&assoc_rqst->assoc_cmd.hostid, &ctrl->ctrl.opts->host->id);
@@ -1326,7 +1326,7 @@ nvme_fc_connect_queue(struct nvme_fc_ctrl *ctrl, struct nvme_fc_queue *queue,
 				sizeof(struct fcnvme_lsdesc_cr_conn_cmd));
 	conn_rqst->connect_cmd.ersp_ratio = cpu_to_be16(ersp_ratio);
 	conn_rqst->connect_cmd.qid  = cpu_to_be16(queue->qnum);
-	conn_rqst->connect_cmd.sqsize = cpu_to_be16(qsize - 1);
+	conn_rqst->connect_cmd.sqsize = cpu_to_be16(qsize);
 
 	lsop->queue = queue;
 	lsreq->rqstaddr = conn_rqst;
@@ -2484,11 +2484,11 @@ nvme_fc_create_io_queues(struct nvme_fc_ctrl *ctrl)
 		goto out_free_tag_set;
 	}
 
-	ret = nvme_fc_create_hw_io_queues(ctrl, ctrl->ctrl.sqsize + 1);
+	ret = nvme_fc_create_hw_io_queues(ctrl, ctrl->ctrl.sqsize);
 	if (ret)
 		goto out_cleanup_blk_queue;
 
-	ret = nvme_fc_connect_io_queues(ctrl, ctrl->ctrl.sqsize + 1);
+	ret = nvme_fc_connect_io_queues(ctrl, ctrl->ctrl.sqsize);
 	if (ret)
 		goto out_delete_hw_queues;
 
@@ -2539,11 +2539,11 @@ nvme_fc_recreate_io_queues(struct nvme_fc_ctrl *ctrl)
 	if (ctrl->ctrl.queue_count == 1)
 		return 0;
 
-	ret = nvme_fc_create_hw_io_queues(ctrl, ctrl->ctrl.sqsize + 1);
+	ret = nvme_fc_create_hw_io_queues(ctrl, ctrl->ctrl.sqsize);
 	if (ret)
 		goto out_free_io_queues;
 
-	ret = nvme_fc_connect_io_queues(ctrl, ctrl->ctrl.sqsize + 1);
+	ret = nvme_fc_connect_io_queues(ctrl, ctrl->ctrl.sqsize);
 	if (ret)
 		goto out_delete_hw_queues;
 
Signature · 1 line
2.16.4

_______________________________________________
linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme

#4 lore raw
Quoted 7 lines · Keith Busch
Quoted 3 lines · Hannes Reinecke

When creating queues we should be passing in the real sqsize number, and not increasing it by one just so that the function has to substract it again.

Kind of makes me wonder: why are we even passing the sq size as a parameter at all? The 'ctrl' parameter provides the same thing.

Yes, please kill the parameter entirely instead.

_______________________________________________
linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme

Reviewed-by
#5 lore raw
In reply to Keith Busch
Quoted 67 lines · Keith Busch
Quoted 3 lines · Hannes Reinecke

When creating queues we should be passing in the real sqsize number, and not increasing it by one just so that the function has to substract it again.

Kind of makes me wonder: why are we even passing the sq size as a parameter at all? The 'ctrl' parameter provides the same thing.

Anyway, this looks correct to me.

Quoted 55 lines
---
  drivers/nvme/host/fc.c | 12 ++++++------
  1 file changed, 6 insertions(+), 6 deletions(-)
drivers/nvme/host/fc.c +6 -6
index 0cbc4a703359..f76325a47578 100644
@@ -1211,7 +1211,7 @@ nvme_fc_connect_admin_queue(struct nvme_fc_ctrl *ctrl,
  				sizeof(struct fcnvme_lsdesc_cr_assoc_cmd));
 
  	assoc_rqst->assoc_cmd.ersp_ratio = cpu_to_be16(ersp_ratio);
-	assoc_rqst->assoc_cmd.sqsize = cpu_to_be16(qsize - 1);
+	assoc_rqst->assoc_cmd.sqsize = cpu_to_be16(qsize);
  	/* Linux supports only Dynamic controllers */
  	assoc_rqst->assoc_cmd.cntlid = cpu_to_be16(0xffff);
  	uuid_copy(&assoc_rqst->assoc_cmd.hostid, &ctrl->ctrl.opts->host->id);
@@ -1326,7 +1326,7 @@ nvme_fc_connect_queue(struct nvme_fc_ctrl *ctrl, struct nvme_fc_queue *queue,
  				sizeof(struct fcnvme_lsdesc_cr_conn_cmd));
  	conn_rqst->connect_cmd.ersp_ratio = cpu_to_be16(ersp_ratio);
  	conn_rqst->connect_cmd.qid  = cpu_to_be16(queue->qnum);
-	conn_rqst->connect_cmd.sqsize = cpu_to_be16(qsize - 1);
+	conn_rqst->connect_cmd.sqsize = cpu_to_be16(qsize);
 
  	lsop->queue = queue;
  	lsreq->rqstaddr = conn_rqst;
@@ -2484,11 +2484,11 @@ nvme_fc_create_io_queues(struct nvme_fc_ctrl *ctrl)
  		goto out_free_tag_set;
  	}
 
-	ret = nvme_fc_create_hw_io_queues(ctrl, ctrl->ctrl.sqsize + 1);
+	ret = nvme_fc_create_hw_io_queues(ctrl, ctrl->ctrl.sqsize);
  	if (ret)
  		goto out_cleanup_blk_queue;
 
-	ret = nvme_fc_connect_io_queues(ctrl, ctrl->ctrl.sqsize + 1);
+	ret = nvme_fc_connect_io_queues(ctrl, ctrl->ctrl.sqsize);
  	if (ret)
  		goto out_delete_hw_queues;
 
@@ -2539,11 +2539,11 @@ nvme_fc_recreate_io_queues(struct nvme_fc_ctrl *ctrl)
  	if (ctrl->ctrl.queue_count == 1)
  		return 0;
 
-	ret = nvme_fc_create_hw_io_queues(ctrl, ctrl->ctrl.sqsize + 1);
+	ret = nvme_fc_create_hw_io_queues(ctrl, ctrl->ctrl.sqsize);
  	if (ret)
  		goto out_free_io_queues;
 
-	ret = nvme_fc_connect_io_queues(ctrl, ctrl->ctrl.sqsize + 1);
+	ret = nvme_fc_connect_io_queues(ctrl, ctrl->ctrl.sqsize);
  	if (ret)
  		goto out_delete_hw_queues;
 
Quoted 8 lines
Quoted 2 lines
Signature · 1 line
2.16.4

_______________________________________________
linux-nvme mailing list
[email protected]
https://urldefense.com/v3/__http://lists.infradead.org/mailman/listinfo/linux-nvme__;!!GqivPVa7Brio!Nq4LNDhkMZWjyk8xoSpCsvNM0d4IkwCW8FvAYtlC0EdnTSGaTFWKMr5Bo6B9vK2VAUxX$

I lost track of original patch email. if its not too late.

_______________________________________________
linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme