Skip to content

Commit be42a33

Browse files
keithbuschaxboe
authored andcommitted
nvme: use blk_execute_rq() for passthrough commands
The generic blk_execute_rq() knows how to handle polled completions. Use that instead of implementing an nvme specific handler. Signed-off-by: Keith Busch <kbusch@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com> Link: https://lore.kernel.org/r/20210610214437.641245-3-kbusch@kernel.org Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent c01b5a8 commit be42a33

8 files changed

Lines changed: 19 additions & 47 deletions

File tree

drivers/nvme/host/core.c

Lines changed: 7 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,8 @@ static inline void nvme_init_request(struct request *req,
631631
cmd->common.flags &= ~NVME_CMD_SGL_ALL;
632632

633633
req->cmd_flags |= REQ_FAILFAST_DRIVER;
634+
if (req->mq_hctx->type == HCTX_TYPE_POLL)
635+
req->cmd_flags |= REQ_HIPRI;
634636
nvme_clear_nvme_request(req);
635637
memcpy(nvme_req(req)->cmd, cmd, sizeof(*cmd));
636638
}
@@ -1029,39 +1031,14 @@ blk_status_t nvme_setup_cmd(struct nvme_ns *ns, struct request *req)
10291031
}
10301032
EXPORT_SYMBOL_GPL(nvme_setup_cmd);
10311033

1032-
static void nvme_end_sync_rq(struct request *rq, blk_status_t error)
1033-
{
1034-
struct completion *waiting = rq->end_io_data;
1035-
1036-
rq->end_io_data = NULL;
1037-
complete(waiting);
1038-
}
1039-
1040-
static void nvme_execute_rq_polled(struct request_queue *q,
1041-
struct gendisk *bd_disk, struct request *rq, int at_head)
1042-
{
1043-
DECLARE_COMPLETION_ONSTACK(wait);
1044-
1045-
WARN_ON_ONCE(!test_bit(QUEUE_FLAG_POLL, &q->queue_flags));
1046-
1047-
rq->cmd_flags |= REQ_HIPRI;
1048-
rq->end_io_data = &wait;
1049-
blk_execute_rq_nowait(bd_disk, rq, at_head, nvme_end_sync_rq);
1050-
1051-
while (!completion_done(&wait)) {
1052-
blk_poll(q, request_to_qc_t(rq->mq_hctx, rq), true);
1053-
cond_resched();
1054-
}
1055-
}
1056-
10571034
/*
10581035
* Returns 0 on success. If the result is negative, it's a Linux error code;
10591036
* if the result is positive, it's an NVM Express status code
10601037
*/
10611038
int __nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd,
10621039
union nvme_result *result, void *buffer, unsigned bufflen,
10631040
unsigned timeout, int qid, int at_head,
1064-
blk_mq_req_flags_t flags, bool poll)
1041+
blk_mq_req_flags_t flags)
10651042
{
10661043
struct request *req;
10671044
int ret;
@@ -1082,10 +1059,7 @@ int __nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd,
10821059
goto out;
10831060
}
10841061

1085-
if (poll)
1086-
nvme_execute_rq_polled(req->q, NULL, req, at_head);
1087-
else
1088-
blk_execute_rq(NULL, req, at_head);
1062+
blk_execute_rq(NULL, req, at_head);
10891063
if (result)
10901064
*result = nvme_req(req)->result;
10911065
if (nvme_req(req)->flags & NVME_REQ_CANCELLED)
@@ -1102,7 +1076,7 @@ int nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd,
11021076
void *buffer, unsigned bufflen)
11031077
{
11041078
return __nvme_submit_sync_cmd(q, cmd, NULL, buffer, bufflen, 0,
1105-
NVME_QID_ANY, 0, 0, false);
1079+
NVME_QID_ANY, 0, 0);
11061080
}
11071081
EXPORT_SYMBOL_GPL(nvme_submit_sync_cmd);
11081082

@@ -1465,7 +1439,7 @@ static int nvme_features(struct nvme_ctrl *dev, u8 op, unsigned int fid,
14651439
c.features.dword11 = cpu_to_le32(dword11);
14661440

14671441
ret = __nvme_submit_sync_cmd(dev->admin_q, &c, &res,
1468-
buffer, buflen, 0, NVME_QID_ANY, 0, 0, false);
1442+
buffer, buflen, 0, NVME_QID_ANY, 0, 0);
14691443
if (ret >= 0 && result)
14701444
*result = le32_to_cpu(res.u32);
14711445
return ret;
@@ -2047,7 +2021,7 @@ int nvme_sec_submit(void *data, u16 spsp, u8 secp, void *buffer, size_t len,
20472021
cmd.common.cdw11 = cpu_to_le32(len);
20482022

20492023
return __nvme_submit_sync_cmd(ctrl->admin_q, &cmd, NULL, buffer, len, 0,
2050-
NVME_QID_ANY, 1, 0, false);
2024+
NVME_QID_ANY, 1, 0);
20512025
}
20522026
EXPORT_SYMBOL_GPL(nvme_sec_submit);
20532027
#endif /* CONFIG_BLK_SED_OPAL */

drivers/nvme/host/fabrics.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ int nvmf_reg_read32(struct nvme_ctrl *ctrl, u32 off, u32 *val)
154154
cmd.prop_get.offset = cpu_to_le32(off);
155155

156156
ret = __nvme_submit_sync_cmd(ctrl->fabrics_q, &cmd, &res, NULL, 0, 0,
157-
NVME_QID_ANY, 0, 0, false);
157+
NVME_QID_ANY, 0, 0);
158158

159159
if (ret >= 0)
160160
*val = le64_to_cpu(res.u64);
@@ -200,7 +200,7 @@ int nvmf_reg_read64(struct nvme_ctrl *ctrl, u32 off, u64 *val)
200200
cmd.prop_get.offset = cpu_to_le32(off);
201201

202202
ret = __nvme_submit_sync_cmd(ctrl->fabrics_q, &cmd, &res, NULL, 0, 0,
203-
NVME_QID_ANY, 0, 0, false);
203+
NVME_QID_ANY, 0, 0);
204204

205205
if (ret >= 0)
206206
*val = le64_to_cpu(res.u64);
@@ -245,7 +245,7 @@ int nvmf_reg_write32(struct nvme_ctrl *ctrl, u32 off, u32 val)
245245
cmd.prop_set.value = cpu_to_le64(val);
246246

247247
ret = __nvme_submit_sync_cmd(ctrl->fabrics_q, &cmd, NULL, NULL, 0, 0,
248-
NVME_QID_ANY, 0, 0, false);
248+
NVME_QID_ANY, 0, 0);
249249
if (unlikely(ret))
250250
dev_err(ctrl->device,
251251
"Property Set error: %d, offset %#x\n",
@@ -391,7 +391,7 @@ int nvmf_connect_admin_queue(struct nvme_ctrl *ctrl)
391391

392392
ret = __nvme_submit_sync_cmd(ctrl->fabrics_q, &cmd, &res,
393393
data, sizeof(*data), 0, NVME_QID_ANY, 1,
394-
BLK_MQ_REQ_RESERVED | BLK_MQ_REQ_NOWAIT, false);
394+
BLK_MQ_REQ_RESERVED | BLK_MQ_REQ_NOWAIT);
395395
if (ret) {
396396
nvmf_log_connect_error(ctrl, ret, le32_to_cpu(res.u32),
397397
&cmd, data);
@@ -415,7 +415,6 @@ EXPORT_SYMBOL_GPL(nvmf_connect_admin_queue);
415415
* @qid: NVMe I/O queue number for the new I/O connection between
416416
* host and target (note qid == 0 is illegal as this is
417417
* the Admin queue, per NVMe standard).
418-
* @poll: Whether or not to poll for the completion of the connect cmd.
419418
*
420419
* This function issues a fabrics-protocol connection
421420
* of a NVMe I/O queue (via NVMe Fabrics "Connect" command)
@@ -427,7 +426,7 @@ EXPORT_SYMBOL_GPL(nvmf_connect_admin_queue);
427426
* > 0: NVMe error status code
428427
* < 0: Linux errno error code
429428
*/
430-
int nvmf_connect_io_queue(struct nvme_ctrl *ctrl, u16 qid, bool poll)
429+
int nvmf_connect_io_queue(struct nvme_ctrl *ctrl, u16 qid)
431430
{
432431
struct nvme_command cmd = { };
433432
struct nvmf_connect_data *data;
@@ -453,7 +452,7 @@ int nvmf_connect_io_queue(struct nvme_ctrl *ctrl, u16 qid, bool poll)
453452

454453
ret = __nvme_submit_sync_cmd(ctrl->connect_q, &cmd, &res,
455454
data, sizeof(*data), 0, qid, 1,
456-
BLK_MQ_REQ_RESERVED | BLK_MQ_REQ_NOWAIT, poll);
455+
BLK_MQ_REQ_RESERVED | BLK_MQ_REQ_NOWAIT);
457456
if (ret) {
458457
nvmf_log_connect_error(ctrl, ret, le32_to_cpu(res.u32),
459458
&cmd, data);

drivers/nvme/host/fabrics.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ int nvmf_reg_read32(struct nvme_ctrl *ctrl, u32 off, u32 *val);
182182
int nvmf_reg_read64(struct nvme_ctrl *ctrl, u32 off, u64 *val);
183183
int nvmf_reg_write32(struct nvme_ctrl *ctrl, u32 off, u32 val);
184184
int nvmf_connect_admin_queue(struct nvme_ctrl *ctrl);
185-
int nvmf_connect_io_queue(struct nvme_ctrl *ctrl, u16 qid, bool poll);
185+
int nvmf_connect_io_queue(struct nvme_ctrl *ctrl, u16 qid);
186186
int nvmf_register_transport(struct nvmf_transport_ops *ops);
187187
void nvmf_unregister_transport(struct nvmf_transport_ops *ops);
188188
void nvmf_free_options(struct nvmf_ctrl_options *opts);

drivers/nvme/host/fc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2346,7 +2346,7 @@ nvme_fc_connect_io_queues(struct nvme_fc_ctrl *ctrl, u16 qsize)
23462346
(qsize / 5));
23472347
if (ret)
23482348
break;
2349-
ret = nvmf_connect_io_queue(&ctrl->ctrl, i, false);
2349+
ret = nvmf_connect_io_queue(&ctrl->ctrl, i);
23502350
if (ret)
23512351
break;
23522352

drivers/nvme/host/nvme.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ int nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd,
658658
int __nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd,
659659
union nvme_result *result, void *buffer, unsigned bufflen,
660660
unsigned timeout, int qid, int at_head,
661-
blk_mq_req_flags_t flags, bool poll);
661+
blk_mq_req_flags_t flags);
662662
int nvme_set_features(struct nvme_ctrl *dev, unsigned int fid,
663663
unsigned int dword11, void *buffer, size_t buflen,
664664
u32 *result);

drivers/nvme/host/rdma.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -680,11 +680,10 @@ static void nvme_rdma_stop_io_queues(struct nvme_rdma_ctrl *ctrl)
680680
static int nvme_rdma_start_queue(struct nvme_rdma_ctrl *ctrl, int idx)
681681
{
682682
struct nvme_rdma_queue *queue = &ctrl->queues[idx];
683-
bool poll = nvme_rdma_poll_queue(queue);
684683
int ret;
685684

686685
if (idx)
687-
ret = nvmf_connect_io_queue(&ctrl->ctrl, idx, poll);
686+
ret = nvmf_connect_io_queue(&ctrl->ctrl, idx);
688687
else
689688
ret = nvmf_connect_admin_queue(&ctrl->ctrl);
690689

drivers/nvme/host/tcp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1574,7 +1574,7 @@ static int nvme_tcp_start_queue(struct nvme_ctrl *nctrl, int idx)
15741574
int ret;
15751575

15761576
if (idx)
1577-
ret = nvmf_connect_io_queue(nctrl, idx, false);
1577+
ret = nvmf_connect_io_queue(nctrl, idx);
15781578
else
15791579
ret = nvmf_connect_admin_queue(nctrl);
15801580

drivers/nvme/target/loop.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ static int nvme_loop_connect_io_queues(struct nvme_loop_ctrl *ctrl)
337337
int i, ret;
338338

339339
for (i = 1; i < ctrl->ctrl.queue_count; i++) {
340-
ret = nvmf_connect_io_queue(&ctrl->ctrl, i, false);
340+
ret = nvmf_connect_io_queue(&ctrl->ctrl, i);
341341
if (ret)
342342
return ret;
343343
set_bit(NVME_LOOP_Q_LIVE, &ctrl->queues[i].flags);

0 commit comments

Comments
 (0)