Skip to contentSkip to conversation

PCI: Print a debug message on PCI device release

PATCH Applied Niklas Schnelle 2 participants 2 messages Mar 11, 2021 – May 27, 2021 PCI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PCI: Print a debug message on PCI device release

Commit 62795041418d ("PCI: enhance physical slot debug information") added a debug print on releasing the PCI slot and another message on destroying it. There is however no debug print on releasing the PCI device structure itself and even with closely looking at the kernel log during hotplug testing, I overlooked several missing pci_dev_put() calls for way too long. So let's add a debug print in pci_release_dev() making it much easier to spot when the PCI device structure is not released when it is supposed to.

---
 drivers/pci/probe.c | 1 +
 1 file changed, 1 insertion(+)
drivers/pci/probe.c +1 -0
index 953f15abc850..3e3669a00a2f 100644
@@ -2226,6 +2226,7 @@ static void pci_release_dev(struct device *dev)
 	pci_bus_put(pci_dev->bus);
 	kfree(pci_dev->driver_override);
 	bitmap_free(pci_dev->dma_alias_mask);
+	dev_dbg(dev, "device released\n");
 	kfree(pci_dev);
 }
 
Signature · 1 line
2.25.1
#1 lore raw
Quoted 10 lines · Niklas Schnelle

Commit 62795041418d ("PCI: enhance physical slot debug information") added a debug print on releasing the PCI slot and another message on destroying it. There is however no debug print on releasing the PCI device structure itself and even with closely looking at the kernel log during hotplug testing, I overlooked several missing pci_dev_put() calls for way too long. So let's add a debug print in pci_release_dev() making it much easier to spot when the PCI device structure is not released when it is supposed to.

Applied to pci/enumeration for v5.14, thanks!

Quoted 19 lines
---
 drivers/pci/probe.c | 1 +
 1 file changed, 1 insertion(+)
drivers/pci/probe.c +1 -0
index 953f15abc850..3e3669a00a2f 100644
@@ -2226,6 +2226,7 @@ static void pci_release_dev(struct device *dev)
 	pci_bus_put(pci_dev->bus);
 	kfree(pci_dev->driver_override);
 	bitmap_free(pci_dev->dma_alias_mask);
+	dev_dbg(dev, "device released\n");
 	kfree(pci_dev);
 }
 
Signature · 1 line
2.25.1