Skip to contentSkip to conversation

nvme-pci: Log failures to probe

PATCH Applied Gerd Bayer 3 participants 5 messages Oct 24, 2025 – Oct 27, 2025 NVMe

lore
Share & tools
lore

Gerd Bayer

author
#0 lore raw

v3 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 v3:
- Both patches: Added Christop Helwig's R-b's
- Patch 2/2: add newline (per John Garry)
- Link to v2: https://lore.kernel.org/r/[email protected]

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]>
author
#1 lore raw

PATCH v3 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
index c916176bd9f058b49e6e6768675711df52b15765..8c624960c9f67e0cc8409023de5e532d6ed9b3ac 100644
@@ -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
Reviewed-by on v3 1/2
#2 lore raw

Re: [PATCH v3 1/2] nvme-pci: Print error message on failure in nvme_probe

Quoted 25 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 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 +0 -0

index c916176bd9f058b49e6e6768675711df52b15765..8c624960c9f67e0cc8409023de5 e532d6ed9b3ac 100644

drivers/nvme/host/pci.c +0 -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);

drivers/nvme/host/pci.c +1 -0
+	dev_err_probe(&pdev->dev, result, "probe failed\n");
Quoted 3 lines

  return result;
 }

Regards,
Wilfred

author
#3 lore raw

PATCH v3 2/2 nvme-pci: Add debug message on fail to read CSTS

In reply to Gerd Bayer

Add 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
index 8c624960c9f67e0cc8409023de5e532d6ed9b3ac..15c12e6cba884a9bb5248f70d75490254014b9f9 100644
@@ -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\n");
 		result = -ENODEV;
 		goto disable;
 	}
Signature · 1 line
2.48.1
maintainer Applied
#4 lore raw
In reply to Gerd Bayer
Quoted 5 lines · Gerd Bayer

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.

Thanks, applied to nvme-6.19.