[PATCH] nvme-pci: handle the missed doorbell write due to passthrough req

Hou Tao houtao at huaweicloud.com
Tue Nov 17 05:07:43 PST 2026


From: Hou Tao <houtao1 at huawei.com>

Commit 1cc4cdae2a3b ("nvme-pci: fix missed admin queue sq doorbell
write") lets blk-mq invoke ->commit_rqs when nvme_queue_rq returns
failure or there are still pending requests in the dispatch list.
However, it doesn't handle the case when only passthrough reqs are
queued after the req initiated from nvme_init_ctrl_finish().
nvme_queue_rq() will return BLK_STS_OK for these passthrough reqs due to
REQ_FAILFAST_DRIVER flag, and the controller reset will fail.

Fix it by invoking nvme_commit_rqs when nvme_queue_rq() returns
BLK_STS_OK and bd->last is true.

Fixes: 1cc4cdae2a3b ("nvme-pci: fix missed admin queue sq doorbell write")
Reported-by: Xie Renfeng <xierenfeng at huawei.com>
Signed-off-by: Hou Tao <houtao1 at huawei.com>
---
 drivers/nvme/host/pci.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 18b3f1b8541c..c7f6f7989168 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -1676,8 +1676,12 @@ static blk_status_t nvme_queue_rq(struct blk_mq_hw_ctx *hctx,
 	if (unlikely(!test_bit(NVMEQ_ENABLED, &nvmeq->flags)))
 		return BLK_STS_IOERR;
 
-	if (unlikely(!nvme_check_ready(&dev->ctrl, req, true)))
-		return nvme_fail_nonready_command(&dev->ctrl, req);
+	if (unlikely(!nvme_check_ready(&dev->ctrl, req, true))) {
+		ret = nvme_fail_nonready_command(&dev->ctrl, req);
+		if (ret == BLK_STS_OK && bd->last)
+			nvme_commit_rqs(hctx);
+		return ret;
+	}
 
 	ret = nvme_prep_rq(req);
 	if (unlikely(ret))
-- 
2.29.2




More information about the Linux-nvme mailing list