Skip to contentSkip to conversation

nvme-pci: Log failures to probe

PATCH Superseded Gerd Bayer 3 participants 8 messages Oct 22, 2025 – Oct 23, 2025 NVMe

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Gerd Bayer

author
#0 lore raw

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

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

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 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..8c624960c9f67e0cc8409023de5e532d6ed9b3ac 100644

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!

maintainer Reviewed-by on v2 1/2
#3 lore raw

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

In reply to Gerd Bayer
Quoted 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 failed

This highlights issues with a particular device right away instead of leaving users to search for missing drives.

Looks good:

author
#4 lore raw

PATCH v2 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..ce563e93d29443a25e9236d0b6d8152ee85796d7 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");
 		result = -ENODEV;
 		goto disable;
 	}
Signature · 1 line
2.48.1
maintainer Reviewed-by on v2 2/2
#5 lore raw

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:

#6 lore raw

Re: [PATCH v2 2/2] nvme-pci: Add debug message on fail to read CSTS

In reply to Gerd Bayer
Quoted 15 lines · 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 +0 -0
index 8c624960c9f67e0cc8409023de5e532d6ed9b3ac..ce563e93d29443a25e9236d0b6d8152ee85796d7 100644

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 -0
  		result = -ENODEV;
  		goto disable;
  	}
author
#7 lore raw

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.

---
  drivers/nvme/host/pci.c | 1 +
  1 file changed, 1 insertion(+)
drivers/nvme/host/pci.c +0 -0
index 8c624960c9f67e0cc8409023de5e532d6ed9b3ac..ce563e93d29443a25e9236d0b6d8152ee85796d7 100644
@@ -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 -0
  	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?

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 -0
  		result = -ENODEV;
  		goto disable;
  	}