[PATCH] nvme-pci: try function level reset on init failure
Keith Busch
kbusch at meta.com
Mon Jul 14 10:13:28 PDT 2025
From: Keith Busch <kbusch at 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 at 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
More information about the Linux-nvme
mailing list