diff mbox series

pciutils: Extend pci_generic_scan() to scan all 256 buses.

Message ID 1515018604-13008-1-git-send-email-vburru@caviumnetworks.com
State Not Applicable
Headers show
Series pciutils: Extend pci_generic_scan() to scan all 256 buses. | expand

Commit Message

Veerasenareddy Burru Jan. 3, 2018, 10:30 p.m. UTC
Currently, pci_generic_scan() scans only bus 0 and its subordinate buses.
Due to this, 'lspci -H1' does not list the devices that are not under
root bus not 0 as shown below:
[root@caliobm11 pciutils]# lspci -n -s 84:00.0
84:00.0 0200: 177d:9702 (rev 02)
[root@caliobm11 pciutils]# lspci -H1 -n -s 84:00.0
[root@caliobm11 pciutils]#

Signed-off-by: Veerasenareddy Burru <vburru@caviumnetworks.com>
---
 lib/generic.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Martin Mareš Jan. 3, 2018, 11:04 p.m. UTC | #1
Hello!

> Currently, pci_generic_scan() scans only bus 0 and its subordinate buses.

This is intentional. Some machines decode bus numbers only partially,
so scanning all buses leads to many "ghost devices" found. I am not sure
if such devices are still around, though.

Feel free to add a switch for that.

				Have a nice fortnight
diff mbox series

Patch

diff --git a/lib/generic.c b/lib/generic.c
index c219592..9c5e267 100644
--- a/lib/generic.c
+++ b/lib/generic.c
@@ -69,9 +69,14 @@  void
 pci_generic_scan(struct pci_access *a)
 {
   byte busmap[256];
+  int bus;
 
   memset(busmap, 0, sizeof(busmap));
-  pci_generic_scan_bus(a, busmap, 0);
+  for (bus=0; bus<256; bus++)
+    {
+      if (!busmap[bus])
+        pci_generic_scan_bus(a, busmap, bus);
+    }
 }
 
 int