[Very RFC 38/46] powerpc/pci-hotplug: Scan the whole bus when using PCI_PROBE_NORMAL

Alexey Kardashevskiy aik at ozlabs.ru
Wed Nov 27 17:27:21 AEDT 2019



On 20/11/2019 12:28, Oliver O'Halloran wrote:
> Currently when using the normal (i.e not building pci_dev's from the DT
> node) probe method we only scan the devfn corresponding to the first child
> of the bridge's DT node. This doesn't make much sense to me, but it seems
> to have worked so far. At a guess it seems to work because in a PCIe
> environment the first downstream child will be at devfn 00.0.
> 
> In any case it's completely broken when no pci_dn is available. Remove
> the PCI_DN checking and scan each of the device number that might be on
> the downstream bus.


Then why not just use pci_scan_child_bus()? Thanks,


> Cc: Benjamin Herrenschmidt <benh at kernel.crashing.org>
> Signed-off-by: Oliver O'Halloran <oohall at gmail.com>
> ---
> I'm not sure we should be using pci_scan_slot() directly here. Maybe
> there's some insane legacy reason for it.
> ---
>  arch/powerpc/kernel/pci-hotplug.c | 15 ++++-----------
>  1 file changed, 4 insertions(+), 11 deletions(-)
> 
> diff --git a/arch/powerpc/kernel/pci-hotplug.c b/arch/powerpc/kernel/pci-hotplug.c
> index d6a67f814983..85299c769768 100644
> --- a/arch/powerpc/kernel/pci-hotplug.c
> +++ b/arch/powerpc/kernel/pci-hotplug.c
> @@ -123,17 +123,10 @@ void pci_hp_add_devices(struct pci_bus *bus)
>  	if (mode == PCI_PROBE_DEVTREE) {
>  		/* use ofdt-based probe */
>  		of_rescan_bus(dn, bus);
> -	} else if (mode == PCI_PROBE_NORMAL &&
> -		   dn->child && PCI_DN(dn->child)) {
> -		/*
> -		 * Use legacy probe. In the partial hotplug case, we
> -		 * probably have grandchildren devices unplugged. So
> -		 * we don't check the return value from pci_scan_slot() in
> -		 * order for fully rescan all the way down to pick them up.
> -		 * They can have been removed during partial hotplug.
> -		 */
> -		slotno = PCI_SLOT(PCI_DN(dn->child)->devfn);
> -		pci_scan_slot(bus, PCI_DEVFN(slotno, 0));
> +	} else if (mode == PCI_PROBE_NORMAL) {
> +		for (slotno = 0; slotno < 255; slotno += 8)
> +			pci_scan_slot(bus, slotno);
> +
>  		max = bus->busn_res.start;
>  		/*
>  		 * Scan bridges that are already configured. We don't touch
> 

-- 
Alexey


More information about the Linuxppc-dev mailing list