diff mbox

Enumerate all undiscovered PCIe busses

Message ID 1443810216-3215-1-git-send-email-netwerkforens@gmail.com
State Not Applicable
Headers show

Commit Message

Ruud Oct. 2, 2015, 6:23 p.m. UTC
Multiple root complexes have a different start busnumber.
Poll all undiscovered busses for a root complex

Signed-off-by: Ruud <netwerkforens@gmail.com>
---
 lib/generic.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

Comments

Bjorn Helgaas Oct. 3, 2015, 2:30 p.m. UTC | #1
This appears to be a patch for pciutils, so I cc'd Martin, who
maintains that.

On Fri, Oct 02, 2015 at 06:23:36PM +0000, Ruud wrote:
> Multiple root complexes have a different start busnumber.
> Poll all undiscovered busses for a root complex
>
> Signed-off-by: Ruud <netwerkforens@gmail.com>
> ---
>  lib/generic.c |    6 +++++-
>  1 files changed, 5 insertions(+), 1 deletions(-)
> 
> diff --git a/lib/generic.c b/lib/generic.c
> index c219592..21b8022 100644
> --- a/lib/generic.c
> +++ b/lib/generic.c
> @@ -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
> -- 
> 1.7.0.4
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-pci" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Martin Mareš Oct. 5, 2015, 10:21 a.m. UTC | #2
Hi!

> 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...

> On Fri, Oct 02, 2015 at 06:23:36PM +0000, Ruud wrote:
> > 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
Ruud Oct. 5, 2015, 2:23 p.m. UTC | #3
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 <mj@ucw.cz>:
> Hi!
>
>> 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...
>
>> On Fri, Oct 02, 2015 at 06:23:36PM +0000, Ruud wrote:
>> > 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                          <mj@ucw.cz>   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
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Ruud Oct. 7, 2015, 7:30 a.m. UTC | #4
Hi Martin,

I did some more digging
>
> 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.
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 <netwerkforens@gmail.com>:
> 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 <mj@ucw.cz>:
>> Hi!
>>
>>> 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...
>>
>>> On Fri, Oct 02, 2015 at 06:23:36PM +0000, Ruud wrote:
>>> > 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                          <mj@ucw.cz>   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
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Ruud Oct. 7, 2015, 9:16 a.m. UTC | #5
As alternative I made another patch that allows to specify a specific
busnumber as a base:

https://github.com/netwerkforens/pciutils/tree/multibus_v2
https://github.com/pciutils/pciutils/pull/2


>> 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?
>>
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/lib/generic.c b/lib/generic.c
index c219592..21b8022 100644
--- a/lib/generic.c
+++ b/lib/generic.c
@@ -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