Skip to content

Commit c06ba7b

Browse files
jannauChristoph Hellwig
authored andcommitted
nvme-apple: reset controller during shutdown
This is a functional revert of c76b830 ("nvme-apple: fix controller shutdown in apple_nvme_disable"). The commit broke suspend/resume since apple_nvme_reset_work() tries to disable the controller on resume. This does not work for the apple NVMe controller since register access only works while the co-processor firmware is running. Disabling the NVMe controller in the shutdown path is also required for shutting the co-processor down. The original code was appropriate for this hardware. Add a comment to prevent a similar breaking changes in the future. Fixes: c76b830 ("nvme-apple: fix controller shutdown in apple_nvme_disable") Reported-by: Janne Grunau <[email protected]> Link: https://lore.kernel.org/all/[email protected]/ Signed-off-by: Janne Grunau <[email protected]> [hch: updated with a more descriptive comment from Hector Martin] Signed-off-by: Christoph Hellwig <[email protected]>
1 parent 7746564 commit c06ba7b

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

drivers/nvme/host/apple.c

Lines changed: 17 additions & 1 deletion
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);

0 commit comments

Comments
 (0)