Thread (56 messages) 56 messages, 5 authors, 2015-01-19

[PATCH 01/28] PCI: Rip out pci_bus_add_devices() from pci_scan_bus()

From: Greg Ungerer <hidden>
Date: 2015-01-19 05:09:14
Also in: linux-alpha, linux-pci, lkml, sparclinux

On 19/01/15 12:04, Yijing Wang wrote:
On 2015/1/17 7:16, Yinghai Lu wrote:
quoted
On Fri, Jan 16, 2015 at 3:15 PM, Yinghai Lu [off-list ref] wrote:
quoted
On Thu, Jan 15, 2015 at 5:43 PM, Yijing Wang [off-list ref] wrote:
quoted
Pci_bus_add_devices() should not be placed in pci_scan_bus().
Now pci device will be added to driver core once its
creation. All things left in pci_bus_add_devices() are
driver attachment and other trivial sysfs things.
Pci_scan_bus() should be the function responsible for
scanning PCI devices, not including driver attachment.
Other, some callers(m68k,unicore32,alpha) of pci_scan_bus()
will call pci_bus_size_bridges() and pci_bus_assign_resources()
after pci_scan_bus().

E.g.
In m68k
mcf_pci_init()
        pci_scan_bus()
                ...
                pci_bus_add_devices() --- try to attach driver
        pci_fixup_irqs()
        pci_bus_size_bridges()
        pci_bus_assign_resources()

It is not correct, resources should be assigned correctly
before attaching driver.
No, for booting path, at that time pci drivers are *NOT* loaded yet.
Hi Yinghai, I knew code flow here would not cause problems, sorry the log
confused you, I will refresh it. But I think pci_scan_bus()/pci_scan_root_bus()
which could only be used during system boot up(before module_init) make
the pci scan logic obscure. Because most callers additionally call
pci_bus_size_bridges() and pci_bus_assign_resources() later,
so rip out pci_bus_add_devices() from pci_scan_bus()/pci_scan_root_bus()
make code have better readability.
I agree that ordering seems odd. I recall there was a reason I had
to put it in that order (at that time - which is a few years back now).
I can't remember exactly now, but it was something like bridges
didn't get resourced properly without a pci scan first.

Regards
Greg
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help