From ef0472302eb5b918de4648230c760038a2a0c4e8 Mon Sep 17 00:00:00 2001 From: jhibbits Date: Tue, 4 Dec 2018 04:55:49 +0000 Subject: [PATCH] Sprinkle EARLY_DRIVER_MODULE around the tree Mark some buses as BUS_PASS_BUS, and some resources as BUS_PASS_RESOURCE. This also decouples some resource attachment orderings from being races by device tree ordering, instead relying on the bus pass to provide the ordering. This was originally intended to support multipass suspend/resume, but it's also needed on PowerMacs when using fdt, as the device tree seems to get created in reverse of the OFW tree. Reviewed by: nwhitehorn (long ago) Differential Revision: https://reviews.freebsd.org/D918 --- sys/dev/pci/pci.c | 3 ++- sys/dev/pci/pci_pci.c | 3 ++- sys/powerpc/ofw/ofw_pcib_pci.c | 3 ++- sys/powerpc/ofw/ofw_pcibus.c | 3 ++- sys/powerpc/ofw/openpic_ofw.c | 9 ++++++--- sys/powerpc/powermac/cpcht.c | 6 ++++-- sys/powerpc/powermac/macgpio.c | 3 ++- sys/powerpc/powermac/macio.c | 3 ++- sys/powerpc/powermac/pmu.c | 6 ++++-- sys/powerpc/powermac/smu.c | 3 ++- sys/powerpc/powermac/uninorth.c | 3 ++- sys/powerpc/powermac/uninorthpci.c | 3 ++- 12 files changed, 32 insertions(+), 16 deletions(-) diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c index 7c6a1604c13..0d3ab2b5c43 100644 --- a/sys/dev/pci/pci.c +++ b/sys/dev/pci/pci.c @@ -214,7 +214,8 @@ static device_method_t pci_methods[] = { DEFINE_CLASS_0(pci, pci_driver, pci_methods, sizeof(struct pci_softc)); static devclass_t pci_devclass; -DRIVER_MODULE(pci, pcib, pci_driver, pci_devclass, pci_modevent, NULL); +EARLY_DRIVER_MODULE(pci, pcib, pci_driver, pci_devclass, pci_modevent, NULL, + BUS_PASS_BUS); MODULE_VERSION(pci, 1); static char *pci_vendordata; diff --git a/sys/dev/pci/pci_pci.c b/sys/dev/pci/pci_pci.c index a61d8c2fb2e..18bf1196422 100644 --- a/sys/dev/pci/pci_pci.c +++ b/sys/dev/pci/pci_pci.c @@ -131,7 +131,8 @@ static device_method_t pcib_methods[] = { static devclass_t pcib_devclass; DEFINE_CLASS_0(pcib, pcib_driver, pcib_methods, sizeof(struct pcib_softc)); -DRIVER_MODULE(pcib, pci, pcib_driver, pcib_devclass, NULL, NULL); +EARLY_DRIVER_MODULE(pcib, pci, pcib_driver, pcib_devclass, NULL, NULL, + BUS_PASS_BUS); #if defined(NEW_PCIB) || defined(PCI_HP) SYSCTL_DECL(_hw_pci); diff --git a/sys/powerpc/ofw/ofw_pcib_pci.c b/sys/powerpc/ofw/ofw_pcib_pci.c index 3cf3db16ee8..480475afd0e 100644 --- a/sys/powerpc/ofw/ofw_pcib_pci.c +++ b/sys/powerpc/ofw/ofw_pcib_pci.c @@ -86,7 +86,8 @@ struct ofw_pcib_softc { DEFINE_CLASS_1(pcib, ofw_pcib_pci_driver, ofw_pcib_pci_methods, sizeof(struct ofw_pcib_softc), pcib_driver); -DRIVER_MODULE(ofw_pcib, pci, ofw_pcib_pci_driver, pcib_devclass, 0, 0); +EARLY_DRIVER_MODULE(ofw_pcib, pci, ofw_pcib_pci_driver, pcib_devclass, 0, 0, + BUS_PASS_BUS); static int ofw_pcib_pci_probe(device_t dev) diff --git a/sys/powerpc/ofw/ofw_pcibus.c b/sys/powerpc/ofw/ofw_pcibus.c index 023a6c51b2d..ed4e66dde20 100644 --- a/sys/powerpc/ofw/ofw_pcibus.c +++ b/sys/powerpc/ofw/ofw_pcibus.c @@ -100,7 +100,8 @@ static devclass_t pci_devclass; DEFINE_CLASS_1(pci, ofw_pcibus_driver, ofw_pcibus_methods, sizeof(struct pci_softc), pci_driver); -DRIVER_MODULE(ofw_pcibus, pcib, ofw_pcibus_driver, pci_devclass, 0, 0); +EARLY_DRIVER_MODULE(ofw_pcibus, pcib, ofw_pcibus_driver, pci_devclass, 0, 0, + BUS_PASS_BUS); MODULE_VERSION(ofw_pcibus, 1); MODULE_DEPEND(ofw_pcibus, pci, 1, 1, 1); diff --git a/sys/powerpc/ofw/openpic_ofw.c b/sys/powerpc/ofw/openpic_ofw.c index ecb71ce3250..6a66c8dce00 100644 --- a/sys/powerpc/ofw/openpic_ofw.c +++ b/sys/powerpc/ofw/openpic_ofw.c @@ -95,9 +95,12 @@ static driver_t openpic_ofw_driver = { sizeof(struct openpic_softc), }; -DRIVER_MODULE(openpic, ofwbus, openpic_ofw_driver, openpic_devclass, 0, 0); -DRIVER_MODULE(openpic, simplebus, openpic_ofw_driver, openpic_devclass, 0, 0); -DRIVER_MODULE(openpic, macio, openpic_ofw_driver, openpic_devclass, 0, 0); +EARLY_DRIVER_MODULE(openpic, ofwbus, openpic_ofw_driver, openpic_devclass, + 0, 0, BUS_PASS_INTERRUPT); +EARLY_DRIVER_MODULE(openpic, simplebus, openpic_ofw_driver, openpic_devclass, + 0, 0, BUS_PASS_INTERRUPT); +EARLY_DRIVER_MODULE(openpic, macio, openpic_ofw_driver, openpic_devclass, 0, 0, + BUS_PASS_INTERRUPT); static int openpic_ofw_probe(device_t dev) diff --git a/sys/powerpc/powermac/cpcht.c b/sys/powerpc/powermac/cpcht.c index 8fba05eb2a3..8905e89bc4c 100644 --- a/sys/powerpc/powermac/cpcht.c +++ b/sys/powerpc/powermac/cpcht.c @@ -139,7 +139,8 @@ struct cpcht_softc { static devclass_t cpcht_devclass; DEFINE_CLASS_1(pcib, cpcht_driver, cpcht_methods, sizeof(struct cpcht_softc), ofw_pci_driver); -DRIVER_MODULE(cpcht, ofwbus, cpcht_driver, cpcht_devclass, 0, 0); +EARLY_DRIVER_MODULE(cpcht, ofwbus, cpcht_driver, cpcht_devclass, 0, 0, + BUS_PASS_BUS); #define CPCHT_IOPORT_BASE 0xf4000000UL /* Hardwired */ #define CPCHT_IOPORT_SIZE 0x00400000UL @@ -545,7 +546,8 @@ static driver_t openpic_cpcht_driver = { sizeof(struct openpic_cpcht_softc), }; -DRIVER_MODULE(openpic, unin, openpic_cpcht_driver, openpic_devclass, 0, 0); +EARLY_DRIVER_MODULE(openpic, unin, openpic_cpcht_driver, openpic_devclass, + 0, 0, BUS_PASS_INTERRUPT); static int openpic_cpcht_probe(device_t dev) diff --git a/sys/powerpc/powermac/macgpio.c b/sys/powerpc/powermac/macgpio.c index 4ba24a6dbfa..8c7c526500a 100644 --- a/sys/powerpc/powermac/macgpio.c +++ b/sys/powerpc/powermac/macgpio.c @@ -125,7 +125,8 @@ static driver_t macgpio_pci_driver = { devclass_t macgpio_devclass; -DRIVER_MODULE(macgpio, macio, macgpio_pci_driver, macgpio_devclass, 0, 0); +EARLY_DRIVER_MODULE(macgpio, macio, macgpio_pci_driver, macgpio_devclass, 0, 0, + BUS_PASS_BUS); struct macgpio_devinfo { struct ofw_bus_devinfo mdi_obdinfo; diff --git a/sys/powerpc/powermac/macio.c b/sys/powerpc/powermac/macio.c index f44a47ee5c4..797ffc86d4a 100644 --- a/sys/powerpc/powermac/macio.c +++ b/sys/powerpc/powermac/macio.c @@ -135,7 +135,8 @@ static driver_t macio_pci_driver = { devclass_t macio_devclass; -DRIVER_MODULE(macio, pci, macio_pci_driver, macio_devclass, 0, 0); +EARLY_DRIVER_MODULE(macio, pci, macio_pci_driver, macio_devclass, 0, 0, + BUS_PASS_BUS); /* * PCI ID search table diff --git a/sys/powerpc/powermac/pmu.c b/sys/powerpc/powermac/pmu.c index a487aedd937..501f63b5659 100644 --- a/sys/powerpc/powermac/pmu.c +++ b/sys/powerpc/powermac/pmu.c @@ -153,7 +153,8 @@ static driver_t pmu_driver = { static devclass_t pmu_devclass; -DRIVER_MODULE(pmu, macio, pmu_driver, pmu_devclass, 0, 0); +EARLY_DRIVER_MODULE(pmu, macio, pmu_driver, pmu_devclass, 0, 0, + BUS_PASS_RESOURCE); DRIVER_MODULE(adb, pmu, adb_driver, adb_devclass, 0, 0); static int pmuextint_probe(device_t); @@ -175,7 +176,8 @@ static driver_t pmuextint_driver = { static devclass_t pmuextint_devclass; -DRIVER_MODULE(pmuextint, macgpio, pmuextint_driver, pmuextint_devclass, 0, 0); +EARLY_DRIVER_MODULE(pmuextint, macgpio, pmuextint_driver, pmuextint_devclass, + 0, 0, BUS_PASS_RESOURCE); /* Make sure uhid is loaded, as it turns off some of the ADB emulation */ MODULE_DEPEND(pmu, usb, 1, 1, 1); diff --git a/sys/powerpc/powermac/smu.c b/sys/powerpc/powermac/smu.c index 23349098abc..d70424cb0cd 100644 --- a/sys/powerpc/powermac/smu.c +++ b/sys/powerpc/powermac/smu.c @@ -630,7 +630,8 @@ static driver_t doorbell_driver = { static devclass_t doorbell_devclass; -DRIVER_MODULE(smudoorbell, macgpio, doorbell_driver, doorbell_devclass, 0, 0); +EARLY_DRIVER_MODULE(smudoorbell, macgpio, doorbell_driver, doorbell_devclass, + 0, 0, BUS_PASS_SUPPORTDEV); static int doorbell_probe(device_t dev) diff --git a/sys/powerpc/powermac/uninorth.c b/sys/powerpc/powermac/uninorth.c index 314b3f8949b..821564295c2 100644 --- a/sys/powerpc/powermac/uninorth.c +++ b/sys/powerpc/powermac/uninorth.c @@ -146,7 +146,8 @@ static devclass_t unin_chip_devclass; */ static device_t unin_chip; -DRIVER_MODULE(unin, ofwbus, unin_chip_driver, unin_chip_devclass, 0, 0); +EARLY_DRIVER_MODULE(unin, ofwbus, unin_chip_driver, unin_chip_devclass, 0, 0, + BUS_PASS_BUS); /* * Add an interrupt to the dev's resource list if present diff --git a/sys/powerpc/powermac/uninorthpci.c b/sys/powerpc/powermac/uninorthpci.c index 72c7106f53f..3a0a120b7a0 100644 --- a/sys/powerpc/powermac/uninorthpci.c +++ b/sys/powerpc/powermac/uninorthpci.c @@ -101,7 +101,8 @@ static devclass_t uninorth_devclass; DEFINE_CLASS_1(pcib, uninorth_driver, uninorth_methods, sizeof(struct uninorth_softc), ofw_pci_driver); -DRIVER_MODULE(uninorth, ofwbus, uninorth_driver, uninorth_devclass, 0, 0); +EARLY_DRIVER_MODULE(uninorth, ofwbus, uninorth_driver, uninorth_devclass, 0, 0, + BUS_PASS_BUS); static int uninorth_probe(device_t dev) -- 2.45.2