Skip to content

Commit 955bc12

Browse files
committed
Merge tag 'nvme-6.2-2023-01-20' of git://git.infradead.org/nvme into block-6.2
Pull NVMe fixes from Christoph: "nvme fixes for Linux 6.2 - fix controller shutdown regression in nvme-apple (Janne Grunau) - fix a polling on timeout regression in nvme-pci (Keith Busch)" * tag 'nvme-6.2-2023-01-20' of git://git.infradead.org/nvme: nvme-pci: fix timeout request state check nvme-apple: only reset the controller when RTKit is running nvme-apple: reset controller during shutdown
2 parents 7746564 + 1c58420 commit 955bc12

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

drivers/nvme/host/apple.c

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,23 @@ static void apple_nvme_disable(struct apple_nvme *anv, bool shutdown)
829829
apple_nvme_remove_cq(anv);
830830
}
831831

832-
nvme_disable_ctrl(&anv->ctrl, shutdown);
832+
/*
833+
* Always disable the NVMe controller after shutdown.
834+
* We need to do this to bring it back up later anyway, and we
835+
* can't do it while the firmware is not running (e.g. in the
836+
* resume reset path before RTKit is initialized), so for Apple
837+
* controllers it makes sense to unconditionally do it here.
838+
* Additionally, this sequence of events is reliable, while
839+
* others (like disabling after bringing back the firmware on
840+
* resume) seem to run into trouble under some circumstances.
841+
*
842+
* Both U-Boot and m1n1 also use this convention (i.e. an ANS
843+
* NVMe controller is handed off with firmware shut down, in an
844+
* NVMe disabled state, after a clean shutdown).
845+
*/
846+
if (shutdown)
847+
nvme_disable_ctrl(&anv->ctrl, shutdown);
848+
nvme_disable_ctrl(&anv->ctrl, false);
833849
}
834850

835851
WRITE_ONCE(anv->ioq.enabled, false);
@@ -985,11 +1001,11 @@ static void apple_nvme_reset_work(struct work_struct *work)
9851001
goto out;
9861002
}
9871003

988-
if (anv->ctrl.ctrl_config & NVME_CC_ENABLE)
989-
apple_nvme_disable(anv, false);
990-
9911004
/* RTKit must be shut down cleanly for the (soft)-reset to work */
9921005
if (apple_rtkit_is_running(anv->rtk)) {
1006+
/* reset the controller if it is enabled */
1007+
if (anv->ctrl.ctrl_config & NVME_CC_ENABLE)
1008+
apple_nvme_disable(anv, false);
9931009
dev_dbg(anv->dev, "Trying to shut down RTKit before reset.");
9941010
ret = apple_rtkit_shutdown(anv->rtk);
9951011
if (ret)

drivers/nvme/host/pci.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1362,7 +1362,7 @@ static enum blk_eh_timer_return nvme_timeout(struct request *req)
13621362
else
13631363
nvme_poll_irqdisable(nvmeq);
13641364

1365-
if (blk_mq_request_completed(req)) {
1365+
if (blk_mq_rq_state(req) != MQ_RQ_IN_FLIGHT) {
13661366
dev_warn(dev->ctrl.device,
13671367
"I/O %d QID %d timeout, completion polled\n",
13681368
req->tag, nvmeq->qid);

0 commit comments

Comments
 (0)