Linux PCI subsystem development
 help / color / mirror / Atom feed
* [PATCH 1/1] pci: Add subordinate check before pci_add_new_bus()
@ 2025-08-14  9:39 Rui He
  2025-08-14 20:36 ` Bjorn Helgaas
  2025-08-17  2:46 ` Ethan Zhao
  0 siblings, 2 replies; 7+ messages in thread
From: Rui He @ 2025-08-14  9:39 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: linux-pci, linux-kernel, Prashant.Chikhalkar, Jiguang.Xiao,
	Rui.He

For preconfigured PCI bridge, child bus created on the first scan.
While for some reasons(e.g register mutation), the secondary, and subordiante
register reset to 0 on the second scan, which caused to create
PCI bus twice for the same PCI device.

Following is the related log:
[Wed May 28 20:38:36 CST 2025] pci 0000:0b:01.0: PCI bridge to [bus 0d]
[Wed May 28 20:38:36 CST 2025] pci 0000:0b:05.0: bridge configuration invalid ([bus 00-00]), reconfiguring
[Wed May 28 20:38:36 CST 2025] pci 0000:0b:01.0: PCI bridge to [bus 0e-10]
[Wed May 28 20:38:36 CST 2025] pci 0000:0b:05.0: PCI bridge to [bus 0f-10]

Here PCI device 000:0b:01.0 assigend to bus 0d and 0e.

This patch checks if child PCI bus has been created on the second scan
of bridge. If yes, return directly instead of create a new one.

Signed-off-by: Rui He <rui.he@windriver.com>
---
 drivers/pci/probe.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index f41128f91ca76..ec67adbf31738 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1444,6 +1444,9 @@ static int pci_scan_bridge_extend(struct pci_bus *bus, struct pci_dev *dev,
 			goto out;
 		}
 
+		if(pci_has_subordinate(dev))
+			goto out;
+
 		/* Clear errors */
 		pci_write_config_word(dev, PCI_STATUS, 0xffff);
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-08-26  7:01 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-14  9:39 [PATCH 1/1] pci: Add subordinate check before pci_add_new_bus() Rui He
2025-08-14 20:36 ` Bjorn Helgaas
2025-08-15  2:31   ` He, Rui
2025-08-15 14:22     ` Bjorn Helgaas
2025-08-26  7:01       ` He, Rui
2025-08-17  2:46 ` Ethan Zhao
2025-08-25  8:47   ` He, Rui

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox