Skip to contentSkip to conversation

Enumerate all undiscovered PCIe busses

PATCH In review Ruud 3 participants 6 messages Oct 2, 2015 – Oct 7, 2015

Subsystems (2)
lore
Share & tools
lore

Ruud

author
#0 lore raw

PATCH 1/1 Enumerate all undiscovered PCIe busses

Multiple root complexes have a different start busnumber. Poll all undiscovered busses for a root complex

---
 lib/generic.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
lib/generic.c +5 -1
index c219592..21b8022 100644
@@ -69,9 +69,13 @@ void
 pci_generic_scan(struct pci_access *a)
 {
   byte busmap[256];
+  int basebus;
 
   memset(busmap, 0, sizeof(busmap));
-  pci_generic_scan_bus(a, busmap, 0);
+  for(basebus=0;basebus<256;basebus++) {
+      if (busmap[basebus]==0)
+          pci_generic_scan_bus(a, busmap, basebus);
+  }
 }
 
 int
Signature · 1 line
1.7.0.4
#1 lore raw

This appears to be a patch for pciutils, so I cc'd Martin, who maintains that.

Quoted 34 lines · Ruud

Multiple root complexes have a different start busnumber. Poll all undiscovered busses for a root complex

---
 lib/generic.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
lib/generic.c +5 -1
index c219592..21b8022 100644
@@ -69,9 +69,13 @@ void
 pci_generic_scan(struct pci_access *a)
 {
   byte busmap[256];
+  int basebus;
 
   memset(busmap, 0, sizeof(busmap));
-  pci_generic_scan_bus(a, busmap, 0);
+  for(basebus=0;basebus<256;basebus++) {
+      if (busmap[basebus]==0)
+          pci_generic_scan_bus(a, busmap, basebus);
+  }
 }
 
 int
Signature · 6 lines
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#2 lore raw

Hi!

Quoted 2 lines

This appears to be a patch for pciutils, so I cc'd Martin, who maintains that.

Thanks, I manage to follow linux-pci only very loosely these days...

Quoted 3 lines · Ruud
Quoted 2 lines

Multiple root complexes have a different start busnumber. Poll all undiscovered busses for a root complex

Unfortunately, this is not correct to do. Many systems report junk on unused bus number (for example, they decode bus numbers only partially, so the buses repeat).

In which situation do you need this? Is it on Linux? Only lspci, or your own code using libpci?

Does `lspci -M' help?

Have a nice fortnight

Signature · 3 lines
Martin `MJ' Mares                          <[email protected]>   http://mj.ucw.cz/
Faculty of Math and Physics, Charles University, Prague, Czech Rep., Earth
"Please try to fit your code to 80 columns. That's decimal 80." -- A. Morton
author
#3 lore raw

Hi Martin,

I can't check the effect of "-M" at the moment so that will have to wait. Some context:

I got some buggy BIOS and lots of GPU's. The effect is that I need to reenumerate busses and to let linux do that it is suggested to use setpci to clear busnumber etc.
To make sure I do not clobber the linux drivers, I prefer to remove the switches at the root level (echo 1>remove) and set the registers using -H1 as hardware access.

Unfortunately on the multiprocessor intel system, three root complexes
exist: one at bus 0x00, One at bux 0x80 (and one at 0x7f IIRC). lspci -H1 will only report bus 0x00.

It is not a problem for me to use a patched version of pciutils locally, but hoped to share. Perhaps as an idea: make the base bus-number configurable at the command line instead of hard coded?

Best regards,

Ruud

2015-10-05 12:21 GMT+02:00 Martin Mares <[email protected]>:

Quoted 25 lines

Hi!

Quoted 2 lines

This appears to be a patch for pciutils, so I cc'd Martin, who maintains that.

Thanks, I manage to follow linux-pci only very loosely these days...

Quoted 3 lines · Ruud
Quoted 2 lines

Multiple root complexes have a different start busnumber. Poll all undiscovered busses for a root complex

Unfortunately, this is not correct to do. Many systems report junk on unused bus number (for example, they decode bus numbers only partially, so the buses repeat).

In which situation do you need this? Is it on Linux? Only lspci, or your own code using libpci?

Does `lspci -M' help?

Have a nice fortnight
--
Martin `MJ' Mares <[email protected]> http://mj.ucw.cz/
Faculty of Math and Physics, Charles University, Prague, Czech Rep., Earth "Please try to fit your code to 80 columns. That's decimal 80." -- A. Morton

author
#4 lore raw

Hi Martin,

I did some more digging

Quoted 2 lines

Does `lspci -M' help?

The -M option shows all busses (but not a tree view), but more important setpci doesn't have the option and thus does not allow to do settings on the alternative busses.

With respect to the "incorrectness" of the patch, one could argue that scanning all busses is allowed as they should read 0xFF for unassigned busses IIRC.

Quoted 1 line

From that respect it may make more sense to have a command line

option that forces a single bus, but scans by default instead of the other way around.

What do you think?

Best regards,

Ruud

2015-10-05 16:23 GMT+02:00 Ruud <[email protected]>:

Quoted 51 lines

Hi Martin,

I can't check the effect of "-M" at the moment so that will have to wait. Some context:

I got some buggy BIOS and lots of GPU's. The effect is that I need to reenumerate busses and to let linux do that it is suggested to use setpci to clear busnumber etc.
To make sure I do not clobber the linux drivers, I prefer to remove the switches at the root level (echo 1>remove) and set the registers using -H1 as hardware access.

Unfortunately on the multiprocessor intel system, three root complexes
exist: one at bus 0x00, One at bux 0x80 (and one at 0x7f IIRC). lspci -H1 will only report bus 0x00.

It is not a problem for me to use a patched version of pciutils locally, but hoped to share. Perhaps as an idea: make the base bus-number configurable at the command line instead of hard coded?

Best regards,

Ruud

2015-10-05 12:21 GMT+02:00 Martin Mares <[email protected]>:

Quoted 25 lines

Hi!

Quoted 2 lines

This appears to be a patch for pciutils, so I cc'd Martin, who maintains that.

Thanks, I manage to follow linux-pci only very loosely these days...

Quoted 3 lines · Ruud
Quoted 2 lines

Multiple root complexes have a different start busnumber. Poll all undiscovered busses for a root complex

Unfortunately, this is not correct to do. Many systems report junk on unused bus number (for example, they decode bus numbers only partially, so the buses repeat).

In which situation do you need this? Is it on Linux? Only lspci, or your own code using libpci?

Does `lspci -M' help?

Have a nice fortnight
--
Martin `MJ' Mares <[email protected]> http://mj.ucw.cz/
Faculty of Math and Physics, Charles University, Prague, Czech Rep., Earth "Please try to fit your code to 80 columns. That's decimal 80." -- A. Morton