Skip to content

Commit db21731

Browse files
ozbenhmpe
authored andcommitted
powerpc/powernv/pci: Work around races in PCI bridge enabling
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 <benh@kernel.crashing.org> Cc: stable@vger.kernel.org Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
1 parent a581831 commit db21731

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
@@ -3227,12 +3227,49 @@ static void pnv_pci_ioda_create_dbgfs(void)
32273227
#endif /* CONFIG_DEBUG_FS */
32283228
}
32293229

3230+
static void pnv_pci_enable_bridge(struct pci_bus *bus)
3231+
{
3232+
struct pci_dev *dev = bus->self;
3233+
struct pci_bus *child;
3234+
3235+
/* Empty bus ? bail */
3236+
if (list_empty(&bus->devices))
3237+
return;
3238+
3239+
/*
3240+
* If there's a bridge associated with that bus enable it. This works
3241+
* around races in the generic code if the enabling is done during
3242+
* parallel probing. This can be removed once those races have been
3243+
* fixed.
3244+
*/
3245+
if (dev) {
3246+
int rc = pci_enable_device(dev);
3247+
if (rc)
3248+
pci_err(dev, "Error enabling bridge (%d)\n", rc);
3249+
pci_set_master(dev);
3250+
}
3251+
3252+
/* Perform the same to child busses */
3253+
list_for_each_entry(child, &bus->children, node)
3254+
pnv_pci_enable_bridge(child);
3255+
}
3256+
3257+
static void pnv_pci_enable_bridges(void)
3258+
{
3259+
struct pci_controller *hose;
3260+
3261+
list_for_each_entry(hose, &hose_list, list_node)
3262+
pnv_pci_enable_bridge(hose->bus);
3263+
}
3264+
32303265
static void pnv_pci_ioda_fixup(void)
32313266
{
32323267
pnv_pci_ioda_setup_PEs();
32333268
pnv_pci_ioda_setup_iommu_api();
32343269
pnv_pci_ioda_create_dbgfs();
32353270

3271+
pnv_pci_enable_bridges();
3272+
32363273
#ifdef CONFIG_EEH
32373274
pnv_eeh_post_init();
32383275
#endif

0 commit comments

Comments
 (0)