bonzini / qboot

Minimal x86 firmware for booting Linux kernels
GNU General Public License v2.0
704 stars 118 forks source link

pci: reduce pci_foreach() calls #14

Closed stefano-garzarella closed 6 years ago

stefano-garzarella commented 6 years ago

In order to reduce the boot time, we can reduce the pci_foreach() calls, aggregating the steps in a single function.

Signed-off-by: Stefano Garzarella sgarzare@redhat.com

bonzini commented 6 years ago

Unfortunately this does not work. The idea is that some of the bridges could have overlapping bus values, so before visiting the secondary buses all of the bridges have to be disabled.

What you could do is move do_block_pci_bridges into do_setup_pci, and then do a second pci_foreach that allocates bus numbers and calls do_setup_pci recursively. The second call can be skipped if there are no bridges.

The simple though not super-efficient way to do this is with a variable like bridges_left. Another crazy idea, on top of this one, is that while the bridges are blocked you could use PCI_SECONDARY_BUS in the configuration space to store the device/function of the next bridge, in a sort of linked list. That would avoid the second pci_foreach completely.

stefano-garzarella commented 6 years ago

Thanks for the explanation! Sorry, but I was confused because I didn't see that pci_foreach() uses the bus global variable.

So, if I understood correctly, to block a bridge is enough to set PCI_SUBORDINATE_BUS to 0. Is it correct?

bonzini commented 6 years ago

... and SECONDARY_BUS to nonzero.

stefano-garzarella commented 6 years ago

Hi Paolo, I close this pull request and I'll open a new one with the implementation that you suggested.