Commit fbbefb32 authored by Oliver O'Halloran's avatar Oliver O'Halloran Committed by Michael Ellerman
Browse files

powerpc/pci: Move PHB discovery for PCI_DN using platforms



Make powernv, pseries, powermac and maple use ppc_mc.discover_phbs.
These platforms need to be done together because they all depend on
pci_dn's being created from the DT. The pci_dn contains a pointer to
the relevant pci_controller so they need to be created after the
pci_controller structures are available, but before PCI devices are
scanned. Currently this ordering is provided by initcalls and the
sequence is:

  1. PHBs are discovered (setup_arch) (early boot, pre-initcalls)
  2. pci_dn are created from the unflattended DT (core initcall)
  3. PHBs are scanned pcibios_init() (subsys initcall)

The new ppc_md.discover_phbs() function is also a core_initcall so we
can't guarantee ordering between the creation of pci_controllers and
the creation of pci_dn's which require a pci_controller. We could use
the postcore, or core_sync initcall levels, but it's cleaner to just
move the pci_dn setup into the per-PHB inits which occur inside of
.discover_phb() for these platforms. This brings the boot-time path in
line with the PHB hotplug path that is used for pseries DLPAR
operations too.

Signed-off-by: default avatarOliver O'Halloran <oohall@gmail.com>
[mpe: Squash powermac & maple in to avoid breakage those platforms,
      convert memblock allocs to use kmalloc to avoid warnings]
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20201103043523.916109-2-oohall@gmail.com
parent 5537fcb3
Loading
Loading
Loading
Loading
+0 −22
Original line number Diff line number Diff line
@@ -481,28 +481,6 @@ void pci_devs_phb_init_dynamic(struct pci_controller *phb)
	pci_traverse_device_nodes(dn, add_pdn, phb);
}

/** 
 * pci_devs_phb_init - Initialize phbs and pci devs under them.
 * 
 * This routine walks over all phb's (pci-host bridges) on the
 * system, and sets up assorted pci-related structures 
 * (including pci info in the device node structs) for each
 * pci device found underneath.  This routine runs once,
 * early in the boot sequence.
 */
static int __init pci_devs_phb_init(void)
{
	struct pci_controller *phb, *tmp;

	/* This must be done first so the device nodes have valid pci info! */
	list_for_each_entry_safe(phb, tmp, &hose_list, list_node)
		pci_devs_phb_init_dynamic(phb);

	return 0;
}

core_initcall(pci_devs_phb_init);

static void pci_dev_pdn_setup(struct pci_dev *pdev)
{
	struct pci_dn *pdn;
+3 −0
Original line number Diff line number Diff line
@@ -536,6 +536,9 @@ static int __init maple_add_bridge(struct device_node *dev)
	/* Check for legacy IOs */
	isa_bridge_find_early(hose);

	/* create pci_dn's for DT nodes under this PHB */
	pci_devs_phb_init_dynamic(hose);

	return 0;
}

+1 −3
Original line number Diff line number Diff line
@@ -179,9 +179,6 @@ static void __init maple_setup_arch(void)
#ifdef CONFIG_SMP
	smp_ops = &maple_smp_ops;
#endif
	/* Lookup PCI hosts */
       	maple_pci_init();

	maple_use_rtas_reboot_and_halt_if_present();

	printk(KERN_DEBUG "Using native/NAP idle loop\n");
@@ -351,6 +348,7 @@ define_machine(maple) {
	.name			= "Maple",
	.probe			= maple_probe,
	.setup_arch		= maple_setup_arch,
	.discover_phbs		= maple_pci_init,
	.init_IRQ		= maple_init_IRQ,
	.pci_irq_fixup		= maple_pci_irq_fixup,
	.pci_get_legacy_ide_irq	= maple_pci_get_legacy_ide_irq,
+4 −0
Original line number Diff line number Diff line
@@ -850,6 +850,10 @@ static int __init pmac_add_bridge(struct device_node *dev)
	/* Fixup "bus-range" OF property */
	fixup_bus_range(dev);

	/* create pci_dn's for DT nodes under this PHB */
	if (IS_ENABLED(CONFIG_PPC64))
		pci_devs_phb_init_dynamic(hose);

	return 0;
}

+1 −3
Original line number Diff line number Diff line
@@ -298,9 +298,6 @@ static void __init pmac_setup_arch(void)
		of_node_put(ic);
	}

	/* Lookup PCI hosts */
	pmac_pci_init();

#ifdef CONFIG_PPC32
	ohare_init();
	l2cr_init();
@@ -600,6 +597,7 @@ define_machine(powermac) {
	.name			= "PowerMac",
	.probe			= pmac_probe,
	.setup_arch		= pmac_setup_arch,
	.discover_phbs		= pmac_pci_init,
	.show_cpuinfo		= pmac_show_cpuinfo,
	.init_IRQ		= pmac_pic_init,
	.get_irq		= NULL,	/* changed later */
Loading