Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nvme-pci: try function level reset on init failure
@ 2025-07-14 17:13 Keith Busch
  2025-07-15  0:27 ` Chaitanya Kulkarni
  2025-07-15  7:45 ` Christoph Hellwig
  0 siblings, 2 replies; 4+ messages in thread
From: Keith Busch @ 2025-07-14 17:13 UTC (permalink / raw)
  To: linux-nvme, hch; +Cc: Keith Busch

From: Keith Busch <kbusch@kernel.org>

I've encountered various nvme devices that for whatever reason are stuck
in a reset state. Historically these have required a power cycle to make
them usable again. Vendors don't report any problem with the device when
we ship these for analysis.

In many cases, a PCIe FLR is sufficient to restart operation without a
power cycle. Try it if controller reset fails the first time.

Signed-off-by: Keith Busch <kbusch@kernel.org>
---
 drivers/nvme/host/pci.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 4cf87fb5d8573..85749f19e3a23 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -2067,8 +2067,18 @@ static int nvme_pci_configure_admin_queue(struct nvme_dev *dev)
 	 * might be pointing at!
 	 */
 	result = nvme_disable_ctrl(&dev->ctrl, false);
-	if (result < 0)
-		return result;
+	if (result < 0) {
+		struct pci_dev *pdev = to_pci_dev(dev->dev);
+
+		result = pcie_flr(pdev);
+		if (result < 0)
+			return result;
+		pci_restore_state(pdev);
+
+		result = nvme_disable_ctrl(&dev->ctrl, false);
+		if (result < 0)
+			return result;
+	}
 
 	result = nvme_alloc_queue(dev, 0, NVME_AQ_DEPTH);
 	if (result)
-- 
2.47.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-07-15 15:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-14 17:13 [PATCH] nvme-pci: try function level reset on init failure Keith Busch
2025-07-15  0:27 ` Chaitanya Kulkarni
2025-07-15  7:45 ` Christoph Hellwig
2025-07-15 13:30   ` Keith Busch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox