Skip to content

Commit 2bf5d3b

Browse files
lsgunthChristoph Hellwig
authored andcommitted
nvme: clear any SGL flags in passthru commands
The host driver should decide whether to use SGLs or PRPs and they currently assume the flags are cleared after the call to nvme_setup_cmd(). However, passed-through commands may erroneously set these bits; so clear them for all cases. Signed-off-by: Logan Gunthorpe <[email protected]> Reviewed-by: Keith Busch <[email protected]> Reviewed-by: Sagi Grimberg <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]>
1 parent ece0278 commit 2bf5d3b

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

drivers/nvme/host/core.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,14 @@ static void nvme_assign_write_stream(struct nvme_ctrl *ctrl,
604604
req->q->write_hints[streamid] += blk_rq_bytes(req) >> 9;
605605
}
606606

607+
static void nvme_setup_passthrough(struct request *req,
608+
struct nvme_command *cmd)
609+
{
610+
memcpy(cmd, nvme_req(req)->cmd, sizeof(*cmd));
611+
/* passthru commands should let the driver set the SGL flags */
612+
cmd->common.flags &= ~NVME_CMD_SGL_ALL;
613+
}
614+
607615
static inline void nvme_setup_flush(struct nvme_ns *ns,
608616
struct nvme_command *cmnd)
609617
{
@@ -769,7 +777,7 @@ blk_status_t nvme_setup_cmd(struct nvme_ns *ns, struct request *req,
769777
switch (req_op(req)) {
770778
case REQ_OP_DRV_IN:
771779
case REQ_OP_DRV_OUT:
772-
memcpy(cmd, nvme_req(req)->cmd, sizeof(*cmd));
780+
nvme_setup_passthrough(req, cmd);
773781
break;
774782
case REQ_OP_FLUSH:
775783
nvme_setup_flush(ns, cmd);

0 commit comments

Comments
 (0)