* [PATCH v1] nvme-pci: shut down the controller if disabling the HMB fails on suspend
@ 2026-10-22 4:58 Yuho Choi
0 siblings, 0 replies; only message in thread
From: Yuho Choi @ 2026-10-22 4:58 UTC (permalink / raw)
To: Keith Busch, Jens Axboe, Christoph Hellwig, Sagi Grimberg
Cc: linux-nvme, linux-kernel, Yuho Choi
nvme_suspend() disables the host memory buffer before it moves the
controller to a non-operational power state, as host memory access may
not work in a system suspend state. It only treats a negative return
from nvme_set_host_mem() as a failure, though. If the controller fails
the Set Features command with an NVMe status, the HMB stays enabled and
the controller is suspended with it in use.
On resume, nvme_setup_host_mem() then tries to enable the buffer again.
If the controller rejects that, the buffer is freed while the controller
can still access it, and the reset that nvme_resume() falls back to is
not scheduled, as the controller is still LIVE.
Handle a positive status like the power state change below does: shut
the controller down, so that it no longer accesses the buffer and is
reset on resume.
Fixes: e5ad96f388b7 ("nvme-pci: disable hmb on idle suspend")
Assisted-by: LLM
Signed-off-by: Yuho Choi <oss.patchbox@gmail.com>
---
This was found by code inspection as part of ongoing, not yet
published research. It has not been reproduced on hardware.
Compile-tested only (x86_64 defconfig with BLK_DEV_NVME=y, W=1).
drivers/nvme/host/pci.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 77317e5d00f9..268d8fe0ac90 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -3997,6 +3997,14 @@ static int nvme_suspend(struct device *dev)
ret = nvme_set_host_mem(ndev, 0);
if (ret < 0)
goto unfreeze;
+ if (ret) {
+ /*
+ * The controller may still access the HMB. Shut it
+ * down instead, which forces a reset on resume.
+ */
+ ret = nvme_disable_prepare_reset(ndev, true);
+ goto unfreeze;
+ }
}
ret = nvme_get_power_state(ctrl, &ndev->last_ps);
base-commit: c03c1a14507dfaf8b856c2608f9ac216021fc222
--
2.43.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-10-22 4:58 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-22 4:58 [PATCH v1] nvme-pci: shut down the controller if disabling the HMB fails on suspend Yuho Choi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®