From: Yuho Choi <oss.patchbox@gmail.com>
To: Keith Busch <kbusch@kernel.org>, Jens Axboe <axboe@kernel.dk>,
Christoph Hellwig <hch@lst.de>, Sagi Grimberg <sagi@grimberg.me>
Cc: linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org,
Yuho Choi <oss.patchbox@gmail.com>
Subject: [PATCH v1] nvme-pci: shut down the controller if disabling the HMB fails on suspend
Date: Thu, 22 Oct 2026 00:58:18 -0400 [thread overview]
Message-ID: <20261022045828.1392332-2-oss.patchbox@gmail.com> (raw)
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
reply other threads:[~2026-10-22 4:58 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261022045828.1392332-2-oss.patchbox@gmail.com \
--to=oss.patchbox@gmail.com \
--cc=axboe@kernel.dk \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=sagi@grimberg.me \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®