nvme-pci: Log failures to probe
v2 cover nvme-pci: Log failures to probe
Hi,
occasionally, an NVMe drive fails to reply to MMIO reads despite the PCI link being operational. In these situations (obviously not on the boot-device :) it is preferred to have this reported in the kernel log instead of deducing that something is wrong by comparing expectated vs. observed number of nvme devices.
- 1/2 adds a clear indication that the device driver failed to probe an NVMe drive and will not register a nvme device.
- 2/2 adds a debug log that allows to further zoom in on the exact failure
I've split this into two patches, since 2/2 might be less important wrt to back-ports, etc.
Thanks,
Gerd
---
Changes in v2:
- Patch 1/2:
- Replace dev_err() with dev_err_probe(), now last before return
- Drop R-b from Wilfred Mallawa
- Patch 2/2: Reword as suggested by Christoph Hellwig, pick up R-b's
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Gerd Bayer (2):
nvme-pci: Print error message on failure in nvme_probe
nvme-pci: Add debug message on fail to read CSTS
drivers/nvme/host/pci.c | 2 ++ 1 file changed, 2 insertions(+)
---
base-commit: 211ddde0823f1442e4ad052a2f30f050145ccada
change-id: 20251015-nvme_probefail-3976120a4719
Best regards,
Signature · 1 line
Gerd Bayer <[email protected]>
PATCH v2 1/2 nvme-pci: Print error message on failure in nvme_probe
Add a new error message that makes failures to probe visible in the kernel log, like:
nvme 0008:00:00.0: error -ENODEV: probe failed
This highlights issues with a particular device right away instead of leaving users to search for missing drives.
--- drivers/nvme/host/pci.c | 1 + 1 file changed, 1 insertion(+)
drivers/nvme/host/pci.c +1 -0
@@ -3522,6 +3522,7 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id)nvme_uninit_ctrl (&dev->ctrl); out_put_ctrl:nvme_put_ctrl (&dev->ctrl); +dev_err_probe (&pdev->dev, result,"probe failed\n" );return result; }
Signature · 1 line
2.48.1
Re: [PATCH v2 1/2] nvme-pci: Print error message on failure in nvme_probe
Quoted 17 lines · Gerd Bayer
Add a new error message that makes failures to probe visible in the kernel log, like:
nvme 0008:00:00.0: error-ENODEV: probe failedThis highlights issues with a particular device right away instead of leaving users to search for missing drives.
Signed-off-by Gerd Bayer <[email protected]>--- drivers/nvme/host/pci.c | 1 + 1 file changed, 1 insertion(+)drivers/nvme/host/pci.c +0
-0
drivers/nvme/host/pci.c static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id) · line 3527
Quoted 6 lines
drivers/nvme/host/pci.c +1
-0@@ -3522,6 +3522,7 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id)nvme_uninit_ctrl (&dev->ctrl); out_put_ctrl:nvme_put_ctrl (&dev->ctrl); +dev_err_probe (&pdev->dev, result,"probe failed\n" );return result; }
This one failed to reach Chaitanya due to a typo in the email address on my side. Sorry!
Re: [PATCH v2 1/2] nvme-pci: Print error message on failure in nvme_probe
In reply to Gerd BayerQuoted 8 lines · Gerd Bayer
Add a new error message that makes failures to probe visible in the kernel log, like:
nvme 0008:00:00.0: error-ENODEV: probe failedThis highlights issues with a particular device right away instead of leaving users to search for missing drives.
Signed-off-by Gerd Bayer <[email protected]>
Looks good:
PATCH v2 2/2 nvme-pci: Add debug message on fail to read CSTS
In reply to Gerd BayerAdd a debug log spelling out that reading the CSTS register failed - to distinguish this from other reasons for ENODEV.
--- drivers/nvme/host/pci.c | 1 + 1 file changed, 1 insertion(+)
drivers/nvme/host/pci.c +1 -0
@@ -2906,6 +2906,7 @@ static int nvme_pci_enable(struct nvme_dev *dev)pci_set_master (pdev);if (readl (dev->bar +NVME_REG_CSTS ) ==-1 ) { +dev_dbg (dev->ctrl.device,"reading CSTS register failed" ); result = -ENODEV ; goto disable; }
Signature · 1 line
2.48.1
Re: [PATCH v2 2/2] nvme-pci: Add debug message on fail to read CSTS
Quoted 2 lines · Gerd Bayer
Add a debug log spelling out that reading the CSTS register failed - to distinguish this from other reasons for ENODEV.
Looks good:
Re: [PATCH v2 2/2] nvme-pci: Add debug message on fail to read CSTS
In reply to Gerd BayerQuoted 15 lines · Gerd Bayer
Add a debug log spelling out that reading the CSTS register failed - to distinguish this from other reasons for ENODEV.
Reviewed-by Wilfred Mallawa <[email protected]>Reviewed-by Chaitanya Kulkarni <[email protected]>Signed-off-by Gerd Bayer <[email protected]>--- drivers/nvme/host/pci.c | 1 + 1 file changed, 1 insertion(+)drivers/nvme/host/pci.c +0
-0
drivers/nvme/host/pci.c static int nvme_pci_enable(struct nvme_dev *dev) · line 2909
Quoted 4 lines
drivers/nvme/host/pci.c +1
-0@@ -2906,6 +2906,7 @@ static int nvme_pci_enable(struct nvme_dev *dev)pci_set_master (pdev);if (readl (dev->bar +NVME_REG_CSTS ) ==-1 ) { +dev_dbg (dev->ctrl.device,"reading CSTS register failed" );
we should add "\n" as a good practice, no?
Quoted 4 lines
drivers/nvme/host/pci.c +0
-0result = -ENODEV ; goto disable; }
Re: [PATCH v2 2/2] nvme-pci: Add debug message on fail to read CSTS
Quoted 18 lines · John Garry
Quoted 17 lines · Gerd Bayer
Add a debug log spelling out that reading the CSTS register failed - to distinguish this from other reasons for ENODEV.
Reviewed-by Wilfred Mallawa <[email protected]>Reviewed-by Chaitanya Kulkarni <[email protected]>Signed-off-by Gerd Bayer <[email protected]>--- drivers/nvme/host/pci.c | 1 + 1 file changed, 1 insertion(+)drivers/nvme/host/pci.c +0
-0@@ -2906,6 +2906,7 @@ static int nvme_pci_enable(struct nvme_dev *dev)pci_set_master (pdev);
Quoted 4 lines
drivers/nvme/host/pci.c static int nvme_pci_enable(struct nvme_dev *dev) · line 2909
Quoted 2 lines
drivers/nvme/host/pci.c +1
-0if (readl (dev->bar +NVME_REG_CSTS ) ==-1 ) { +dev_dbg (dev->ctrl.device,"reading CSTS register failed" );we should add "\n" as a good practice, no?
that's a very valid point. Sheesh - how much can go wrong...
Thanks,
Gerd
Quoted 5 lines
Quoted 5 lines
drivers/nvme/host/pci.c +0
-0result = -ENODEV ; goto disable; }