diff mbox series

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

Message ID 20191120012859.23300-39-oohall@gmail.com (mailing list archive)
State RFC
Headers show
Series [Very,RFC,01/46] powerpc/eeh: Don't attempt to restore VF config space after reset | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch warning Failed to apply on branch powerpc/merge (784eee1cc44801366d4f197e0ade7739ee8e1e83)
snowpatch_ozlabs/apply_patch warning Failed to apply on branch powerpc/next (0695f8bca93ea0c57f0e8e21b4b4db70183b3d1c)
snowpatch_ozlabs/apply_patch warning Failed to apply on branch linus/master (c74386d50fbaf4a54fd3fe560f1abc709c0cff4b)
snowpatch_ozlabs/apply_patch warning Failed to apply on branch powerpc/fixes (7d6475051fb3d9339c5c760ed9883bc0a9048b21)
snowpatch_ozlabs/apply_patch warning Failed to apply on branch linux-next (5d1131b4d61e52e5702e0fa4bcbec81ac7d6ef52)
snowpatch_ozlabs/apply_patch fail Failed to apply to any branch

Commit Message

Oliver O'Halloran Nov. 20, 2019, 1:28 a.m. UTC
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.

Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Oliver O'Halloran <oohall@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(-)

Comments

Alexey Kardashevskiy Nov. 27, 2019, 6:27 a.m. UTC | #1
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@kernel.crashing.org>
> Signed-off-by: Oliver O'Halloran <oohall@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
>
diff mbox series

Patch

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