Bug#594967: Bug #594967: [poulsbo] grub-pc Hangs After "Welcome to GRUB!"

Colin Watson cjwatson at debian.org
Sun Jan 2 09:38:54 UTC 2011


On Sun, Jan 02, 2011 at 09:14:25AM +0000, Colin Watson wrote:
> grub_pci_iterate itself, IIRC.  On the system I briefly had access to,
> it hung when it tried to read from a particular address in PCI memory
> (when it got to some high-numbered bus - 171 or something like that, I
> forget the exact number).
> 
> GRUB just reads through PCI busses sequentially from 0 to 255.  Linux
> does something much more complicated.  In the time I had available I
> couldn't figure out how to reproduce it in GRUB, or whether it was
> necessary - it seemed to be stopping well before bus 255 though.  I
> think it was getting the limit from PCI configuration space, but there
> seemed to be some kind of multi-level scheme going on.

The PCI specification itself is behind a membership-only interface (I
haven't looked yet to see if membership is free).  However, from what I
can make out, we shouldn't be just walking from 0 to 255.  What you're
supposed to do is:

  * Walk through bus 0.
  * If any PCI-PCI bridge devices (class 6, subclass 4) were found, then
    they may have additional buses behind them.  The bus numbers behind
    these bridges must be > the bridge's Secondary Bus Number register,
    and <= the bridge's Subordinate Bus Number register.  Recursively
    walk these buses in the same way as bus 0.

Since the Subordinate Bus Number is a recursive upper bound for any bus
beyond a given bridge, perhaps it's enough to take the maximum of all
the Subordinate Bus Number registers for all PCI-PCI bridges on bus 0
and use that as the system's maximum bus number.  It would seem more
efficient to account for possible gaps in bus numbering and not try to
interrogate buses we know to be in the gaps, though.

http://tldp.org/LDP/tlk/dd/pci.html seems like a reasonable layman's
summary.

-- 
Colin Watson                                       [cjwatson at debian.org]





More information about the Pkg-grub-devel mailing list