Skip to content

Commit 1eb08e7

Browse files
ozbenhgregkh
authored andcommitted
powerpc/powernv/pci: Work around races in PCI bridge enabling
commit db21731 upstream. The generic code is racy when multiple children of a PCI bridge try to enable it simultaneously. This leads to drivers trying to access a device through a not-yet-enabled bridge, and this EEH errors under various circumstances when using parallel driver probing. There is work going on to fix that properly in the PCI core but it will take some time. x86 gets away with it because (outside of hotplug), the BIOS enables all the bridges at boot time. This patch does the same thing on powernv by enabling all bridges that have child devices at boot time, thus avoiding subsequent races. It's suitable for backporting to stable and distros, while the proper PCI fix will probably be significantly more invasive. Signed-off-by: Benjamin Herrenschmidt <[email protected]> Cc: [email protected] Signed-off-by: Michael Ellerman <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 15677df commit 1eb08e7

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

arch/powerpc/platforms/powernv/pci-ioda.c

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3286,12 +3286,49 @@ static void pnv_pci_ioda_create_dbgfs(void)
32863286
#endif /* CONFIG_DEBUG_FS */
32873287
}
32883288

3289+
static void pnv_pci_enable_bridge(struct pci_bus *bus)
3290+
{
3291+
struct pci_dev *dev = bus->self;
3292+
struct pci_bus *child;
3293+
3294+
/* Empty bus ? bail */
3295+
if (list_empty(&bus->devices))
3296+
return;
3297+
3298+
/*
3299+
* If there's a bridge associated with that bus enable it. This works
3300+
* around races in the generic code if the enabling is done during
3301+
* parallel probing. This can be removed once those races have been
3302+
* fixed.
3303+
*/
3304+
if (dev) {
3305+
int rc = pci_enable_device(dev);
3306+
if (rc)
3307+
pci_err(dev, "Error enabling bridge (%d)\n", rc);
3308+
pci_set_master(dev);
3309+
}
3310+
3311+
/* Perform the same to child busses */
3312+
list_for_each_entry(child, &bus->children, node)
3313+
pnv_pci_enable_bridge(child);
3314+
}
3315+
3316+
static void pnv_pci_enable_bridges(void)
3317+
{
3318+
struct pci_controller *hose;
3319+
3320+
list_for_each_entry(hose, &hose_list, list_node)
3321+
pnv_pci_enable_bridge(hose->bus);
3322+
}
3323+
32893324
static void pnv_pci_ioda_fixup(void)
32903325
{
32913326
pnv_pci_ioda_setup_PEs();
32923327
pnv_pci_ioda_setup_iommu_api();
32933328
pnv_pci_ioda_create_dbgfs();
32943329

3330+
pnv_pci_enable_bridges();
3331+
32953332
#ifdef CONFIG_EEH
32963333
eeh_init();
32973334
eeh_addr_cache_build();

0 commit comments

Comments
 (0)