Skip to content

Commit bd2687f

Browse files
hreineckekeithbusch
authored andcommitted
nvme: change __nvme_submit_sync_cmd() calling conventions
Combine the two arguments 'flags' and 'at_head' from __nvme_submit_sync_cmd() into a single 'flags' argument and use function-specific values to indicate what should be set within the function. Signed-off-by: Hannes Reinecke <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Chaitanya Kulkarni <[email protected]> Reviewed-by: Sagi Grimberg <[email protected]> Signed-off-by: Keith Busch <[email protected]>
1 parent f9ddefb commit bd2687f

File tree

4 files changed

+41
-20
lines changed

4 files changed

+41
-20
lines changed

drivers/nvme/host/auth.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ static int nvme_auth_submit(struct nvme_ctrl *ctrl, int qid,
5858
void *data, size_t data_len, bool auth_send)
5959
{
6060
struct nvme_command cmd = {};
61-
blk_mq_req_flags_t flags = 0;
61+
nvme_submit_flags_t flags = 0;
6262
struct request_queue *q = ctrl->fabrics_q;
6363
int ret;
6464

6565
if (qid != 0) {
66-
flags |= BLK_MQ_REQ_NOWAIT | BLK_MQ_REQ_RESERVED;
66+
flags |= NVME_SUBMIT_NOWAIT | NVME_SUBMIT_RESERVED;
6767
q = ctrl->connect_q;
6868
}
6969

@@ -80,8 +80,7 @@ static int nvme_auth_submit(struct nvme_ctrl *ctrl, int qid,
8080
}
8181

8282
ret = __nvme_submit_sync_cmd(q, &cmd, NULL, data, data_len,
83-
qid == 0 ? NVME_QID_ANY : qid,
84-
0, flags);
83+
qid == 0 ? NVME_QID_ANY : qid, flags);
8584
if (ret > 0)
8685
dev_warn(ctrl->device,
8786
"qid %d auth_send failed with status %d\n", qid, ret);

drivers/nvme/host/core.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,15 +1051,20 @@ EXPORT_SYMBOL_NS_GPL(nvme_execute_rq, NVME_TARGET_PASSTHRU);
10511051
*/
10521052
int __nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd,
10531053
union nvme_result *result, void *buffer, unsigned bufflen,
1054-
int qid, int at_head, blk_mq_req_flags_t flags)
1054+
int qid, nvme_submit_flags_t flags)
10551055
{
10561056
struct request *req;
10571057
int ret;
1058+
blk_mq_req_flags_t blk_flags = 0;
10581059

1060+
if (flags & NVME_SUBMIT_NOWAIT)
1061+
blk_flags |= BLK_MQ_REQ_NOWAIT;
1062+
if (flags & NVME_SUBMIT_RESERVED)
1063+
blk_flags |= BLK_MQ_REQ_RESERVED;
10591064
if (qid == NVME_QID_ANY)
1060-
req = blk_mq_alloc_request(q, nvme_req_op(cmd), flags);
1065+
req = blk_mq_alloc_request(q, nvme_req_op(cmd), blk_flags);
10611066
else
1062-
req = blk_mq_alloc_request_hctx(q, nvme_req_op(cmd), flags,
1067+
req = blk_mq_alloc_request_hctx(q, nvme_req_op(cmd), blk_flags,
10631068
qid - 1);
10641069

10651070
if (IS_ERR(req))
@@ -1072,7 +1077,7 @@ int __nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd,
10721077
goto out;
10731078
}
10741079

1075-
ret = nvme_execute_rq(req, at_head);
1080+
ret = nvme_execute_rq(req, flags & NVME_SUBMIT_AT_HEAD);
10761081
if (result && ret >= 0)
10771082
*result = nvme_req(req)->result;
10781083
out:
@@ -1085,7 +1090,7 @@ int nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd,
10851090
void *buffer, unsigned bufflen)
10861091
{
10871092
return __nvme_submit_sync_cmd(q, cmd, NULL, buffer, bufflen,
1088-
NVME_QID_ANY, 0, 0);
1093+
NVME_QID_ANY, 0);
10891094
}
10901095
EXPORT_SYMBOL_GPL(nvme_submit_sync_cmd);
10911096

@@ -1560,7 +1565,7 @@ static int nvme_features(struct nvme_ctrl *dev, u8 op, unsigned int fid,
15601565
c.features.dword11 = cpu_to_le32(dword11);
15611566

15621567
ret = __nvme_submit_sync_cmd(dev->admin_q, &c, &res,
1563-
buffer, buflen, NVME_QID_ANY, 0, 0);
1568+
buffer, buflen, NVME_QID_ANY, 0);
15641569
if (ret >= 0 && result)
15651570
*result = le32_to_cpu(res.u32);
15661571
return ret;
@@ -2172,7 +2177,7 @@ static int nvme_sec_submit(void *data, u16 spsp, u8 secp, void *buffer, size_t l
21722177
cmd.common.cdw11 = cpu_to_le32(len);
21732178

21742179
return __nvme_submit_sync_cmd(ctrl->admin_q, &cmd, NULL, buffer, len,
2175-
NVME_QID_ANY, 1, 0);
2180+
NVME_QID_ANY, NVME_SUBMIT_AT_HEAD);
21762181
}
21772182

21782183
static void nvme_configure_opal(struct nvme_ctrl *ctrl, bool was_suspended)

drivers/nvme/host/fabrics.c

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

182182
ret = __nvme_submit_sync_cmd(ctrl->fabrics_q, &cmd, &res, NULL, 0,
183-
NVME_QID_ANY, 0, 0);
183+
NVME_QID_ANY, 0);
184184

185185
if (ret >= 0)
186186
*val = le64_to_cpu(res.u64);
@@ -226,7 +226,7 @@ int nvmf_reg_read64(struct nvme_ctrl *ctrl, u32 off, u64 *val)
226226
cmd.prop_get.offset = cpu_to_le32(off);
227227

228228
ret = __nvme_submit_sync_cmd(ctrl->fabrics_q, &cmd, &res, NULL, 0,
229-
NVME_QID_ANY, 0, 0);
229+
NVME_QID_ANY, 0);
230230

231231
if (ret >= 0)
232232
*val = le64_to_cpu(res.u64);
@@ -271,7 +271,7 @@ int nvmf_reg_write32(struct nvme_ctrl *ctrl, u32 off, u32 val)
271271
cmd.prop_set.value = cpu_to_le64(val);
272272

273273
ret = __nvme_submit_sync_cmd(ctrl->fabrics_q, &cmd, NULL, NULL, 0,
274-
NVME_QID_ANY, 0, 0);
274+
NVME_QID_ANY, 0);
275275
if (unlikely(ret))
276276
dev_err(ctrl->device,
277277
"Property Set error: %d, offset %#x\n",
@@ -450,8 +450,10 @@ int nvmf_connect_admin_queue(struct nvme_ctrl *ctrl)
450450
return -ENOMEM;
451451

452452
ret = __nvme_submit_sync_cmd(ctrl->fabrics_q, &cmd, &res,
453-
data, sizeof(*data), NVME_QID_ANY, 1,
454-
BLK_MQ_REQ_RESERVED | BLK_MQ_REQ_NOWAIT);
453+
data, sizeof(*data), NVME_QID_ANY,
454+
NVME_SUBMIT_AT_HEAD |
455+
NVME_SUBMIT_NOWAIT |
456+
NVME_SUBMIT_RESERVED);
455457
if (ret) {
456458
nvmf_log_connect_error(ctrl, ret, le32_to_cpu(res.u32),
457459
&cmd, data);
@@ -525,8 +527,10 @@ int nvmf_connect_io_queue(struct nvme_ctrl *ctrl, u16 qid)
525527
return -ENOMEM;
526528

527529
ret = __nvme_submit_sync_cmd(ctrl->connect_q, &cmd, &res,
528-
data, sizeof(*data), qid, 1,
529-
BLK_MQ_REQ_RESERVED | BLK_MQ_REQ_NOWAIT);
530+
data, sizeof(*data), qid,
531+
NVME_SUBMIT_AT_HEAD |
532+
NVME_SUBMIT_RESERVED |
533+
NVME_SUBMIT_NOWAIT);
530534
if (ret) {
531535
nvmf_log_connect_error(ctrl, ret, le32_to_cpu(res.u32),
532536
&cmd, data);

drivers/nvme/host/nvme.h

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -837,12 +837,25 @@ static inline bool nvme_is_unique_nsid(struct nvme_ctrl *ctrl,
837837
(ctrl->ctratt & NVME_CTRL_CTRATT_NVM_SETS);
838838
}
839839

840+
/*
841+
* Flags for __nvme_submit_sync_cmd()
842+
*/
843+
typedef __u32 __bitwise nvme_submit_flags_t;
844+
845+
enum {
846+
/* Insert request at the head of the queue */
847+
NVME_SUBMIT_AT_HEAD = (__force nvme_submit_flags_t)(1 << 0),
848+
/* Set BLK_MQ_REQ_NOWAIT when allocating request */
849+
NVME_SUBMIT_NOWAIT = (__force nvme_submit_flags_t)(1 << 1),
850+
/* Set BLK_MQ_REQ_RESERVED when allocating request */
851+
NVME_SUBMIT_RESERVED = (__force nvme_submit_flags_t)(1 << 2),
852+
};
853+
840854
int nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd,
841855
void *buf, unsigned bufflen);
842856
int __nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd,
843857
union nvme_result *result, void *buffer, unsigned bufflen,
844-
int qid, int at_head,
845-
blk_mq_req_flags_t flags);
858+
int qid, nvme_submit_flags_t flags);
846859
int nvme_set_features(struct nvme_ctrl *dev, unsigned int fid,
847860
unsigned int dword11, void *buffer, size_t buflen,
848861
u32 *result);

0 commit comments

Comments
 (0)