nvme-pci: try function level reset on init failure
PATCH 1/1 nvme-pci: try function level reset on init failure
From: Keith Busch <[email protected]>
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.
--- drivers/nvme/host/pci.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/nvme/host/pci.c +12 -2
@@ -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)
Signature · 1 line
2.47.1
Quoted 11 lines · Keith Busch
From: Keith Busch <[email protected]>
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 <[email protected]>
I hope there are no setups that are relying on this failure and okay with implicit PCIe FLR and any side-effects it might have, but I think that is okay, looks good.
-ck
Quoted 29 lines
--- drivers/nvme/host/pci.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)drivers/nvme/host/pci.c +12
-2@@ -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)
Christoph Hellwig
maintainerQuoted 6 lines · Keith Busch
From: Keith Busch <[email protected]>
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.
Who is the "we" here?
Quoted 2 lines
In many cases, a PCIe FLR is sufficient to restart operation without a power cycle. Try it if controller reset fails the first time.
Why is that only done in the probe path and not the runtime reset path?
drivers/nvme/host/pci.c static int nvme_pci_configure_admin_queue(struct nvme_dev *dev) · line 2081
Quoted 12 lines
drivers/nvme/host/pci.c +12
-0+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; + }
Either way this warrants a big comment explaining what we are doing here.
Keith Busch
maintainerQuoted 9 lines · Christoph Hellwig
Quoted 6 lines · Keith Busch
From: Keith Busch <[email protected]>
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.
Who is the "we" here?
Meta.
Quoted 4 lines
Quoted 2 lines
In many cases, a PCIe FLR is sufficient to restart operation without a power cycle. Try it if controller reset fails the first time.
Why is that only done in the probe path and not the runtime reset path?
nvme_pci_configure_admin_queue() is called for both probe and reset_work.
Is it because I wrote "fails the first time"? I mean the first reset for each initialization attempt, whether it happens during probe or a later reset. The code path will try an FLR on every single nvme reset if CSTS.RDY doesn't clear as expected.
Quoted 7 lines
Quoted 7 lines
drivers/nvme/host/pci.c +7
-0+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);
Quoted 8 lines
drivers/nvme/host/pci.c static int nvme_pci_configure_admin_queue(struct nvme_dev *dev) · line 2081
Quoted 5 lines
drivers/nvme/host/pci.c +5
-0+ + result =nvme_disable_ctrl (&dev->ctrl, false); +if (result <0 ) +return result; + }Either way this warrants a big comment explaining what we are doing here.
Sure, no problem. I think also a dev_warn() if the 2nd disable_ctrl call was successful to indicate an FLR was needed to get an expected response.