Skip to content

Commit d157e53

Browse files
jsmart-ghKeith Busch
authored andcommitted
nvme_fc: rework sqsize handling
Corrected four outstanding issues in the transport around sqsize. 1: Create Connection LS is sending the 1's-based sqsize, should be sending the 0's-based value. 2: allocation of hw queue is using the 0's-base size. It should be using the 1's-based value. 3: normalization of ctrl.sqsize by MQES is using MQES+1 (1's-based value). It should be MQES (0's-based value). 4: Missing clause to ensure queue_count not larger than ctrl->sqsize. Corrected by: Clean up routines that pass queue size around. The queue size value is the actual count (1's-based) value and determined from ctrl->sqsize + 1. Routines that send 0's-based value adapt from queue size. Sset ctrl->sqsize properly for MQES. Added clause to nsure queue_count not larger than ctrl->sqsize + 1. Signed-off-by: James Smart <james.smart@broadcom.com> Reviewed-by: Sagi Grimberg <sagi@grimberg.me> Signed-off-by: Keith Busch <keith.busch@intel.com>
1 parent 0475821 commit d157e53

File tree

1 file changed

+17
-10
lines changed
  • drivers/nvme/host

1 file changed

+17
-10
lines changed

drivers/nvme/host/fc.c

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,7 +1206,7 @@ nvme_fc_connect_admin_queue(struct nvme_fc_ctrl *ctrl,
12061206
sizeof(struct fcnvme_lsdesc_cr_assoc_cmd));
12071207

12081208
assoc_rqst->assoc_cmd.ersp_ratio = cpu_to_be16(ersp_ratio);
1209-
assoc_rqst->assoc_cmd.sqsize = cpu_to_be16(qsize);
1209+
assoc_rqst->assoc_cmd.sqsize = cpu_to_be16(qsize - 1);
12101210
/* Linux supports only Dynamic controllers */
12111211
assoc_rqst->assoc_cmd.cntlid = cpu_to_be16(0xffff);
12121212
uuid_copy(&assoc_rqst->assoc_cmd.hostid, &ctrl->ctrl.opts->host->id);
@@ -1321,7 +1321,7 @@ nvme_fc_connect_queue(struct nvme_fc_ctrl *ctrl, struct nvme_fc_queue *queue,
13211321
sizeof(struct fcnvme_lsdesc_cr_conn_cmd));
13221322
conn_rqst->connect_cmd.ersp_ratio = cpu_to_be16(ersp_ratio);
13231323
conn_rqst->connect_cmd.qid = cpu_to_be16(queue->qnum);
1324-
conn_rqst->connect_cmd.sqsize = cpu_to_be16(qsize);
1324+
conn_rqst->connect_cmd.sqsize = cpu_to_be16(qsize - 1);
13251325

13261326
lsop->queue = queue;
13271327
lsreq->rqstaddr = conn_rqst;
@@ -2481,11 +2481,11 @@ nvme_fc_create_io_queues(struct nvme_fc_ctrl *ctrl)
24812481
goto out_free_tag_set;
24822482
}
24832483

2484-
ret = nvme_fc_create_hw_io_queues(ctrl, ctrl->ctrl.opts->queue_size);
2484+
ret = nvme_fc_create_hw_io_queues(ctrl, ctrl->ctrl.sqsize + 1);
24852485
if (ret)
24862486
goto out_cleanup_blk_queue;
24872487

2488-
ret = nvme_fc_connect_io_queues(ctrl, ctrl->ctrl.opts->queue_size);
2488+
ret = nvme_fc_connect_io_queues(ctrl, ctrl->ctrl.sqsize + 1);
24892489
if (ret)
24902490
goto out_delete_hw_queues;
24912491

@@ -2532,11 +2532,11 @@ nvme_fc_reinit_io_queues(struct nvme_fc_ctrl *ctrl)
25322532
if (ret)
25332533
goto out_free_io_queues;
25342534

2535-
ret = nvme_fc_create_hw_io_queues(ctrl, ctrl->ctrl.opts->queue_size);
2535+
ret = nvme_fc_create_hw_io_queues(ctrl, ctrl->ctrl.sqsize + 1);
25362536
if (ret)
25372537
goto out_free_io_queues;
25382538

2539-
ret = nvme_fc_connect_io_queues(ctrl, ctrl->ctrl.opts->queue_size);
2539+
ret = nvme_fc_connect_io_queues(ctrl, ctrl->ctrl.sqsize + 1);
25402540
if (ret)
25412541
goto out_delete_hw_queues;
25422542

@@ -2632,13 +2632,12 @@ nvme_fc_create_association(struct nvme_fc_ctrl *ctrl)
26322632
nvme_fc_init_queue(ctrl, 0);
26332633

26342634
ret = __nvme_fc_create_hw_queue(ctrl, &ctrl->queues[0], 0,
2635-
NVME_AQ_BLK_MQ_DEPTH);
2635+
NVME_AQ_DEPTH);
26362636
if (ret)
26372637
goto out_free_queue;
26382638

26392639
ret = nvme_fc_connect_admin_queue(ctrl, &ctrl->queues[0],
2640-
NVME_AQ_BLK_MQ_DEPTH,
2641-
(NVME_AQ_BLK_MQ_DEPTH / 4));
2640+
NVME_AQ_DEPTH, (NVME_AQ_DEPTH / 4));
26422641
if (ret)
26432642
goto out_delete_hw_queue;
26442643

@@ -2666,7 +2665,7 @@ nvme_fc_create_association(struct nvme_fc_ctrl *ctrl)
26662665
}
26672666

26682667
ctrl->ctrl.sqsize =
2669-
min_t(int, NVME_CAP_MQES(ctrl->ctrl.cap) + 1, ctrl->ctrl.sqsize);
2668+
min_t(int, NVME_CAP_MQES(ctrl->ctrl.cap), ctrl->ctrl.sqsize);
26702669

26712670
ret = nvme_enable_ctrl(&ctrl->ctrl, ctrl->ctrl.cap);
26722671
if (ret)
@@ -2699,6 +2698,14 @@ nvme_fc_create_association(struct nvme_fc_ctrl *ctrl)
26992698
opts->queue_size = ctrl->ctrl.maxcmd;
27002699
}
27012700

2701+
if (opts->queue_size > ctrl->ctrl.sqsize + 1) {
2702+
/* warn if sqsize is lower than queue_size */
2703+
dev_warn(ctrl->ctrl.device,
2704+
"queue_size %zu > ctrl sqsize %u, clamping down\n",
2705+
opts->queue_size, ctrl->ctrl.sqsize + 1);
2706+
opts->queue_size = ctrl->ctrl.sqsize + 1;
2707+
}
2708+
27022709
ret = nvme_fc_init_aen_ops(ctrl);
27032710
if (ret)
27042711
goto out_term_aen_ops;

0 commit comments

Comments
 (0)