From: Sepherosa Ziehau Date: Sun, 17 Apr 2011 10:58:26 +0000 (+0800) Subject: acpi/pcib: If bus does not present, give other bus drivers chance X-Git-Tag: v2.11.0~16 X-Git-Url: https://gitweb.dragonflybsd.org/~nant/dragonfly.git/commitdiff_plain/2c61a93fa6fa30927436688cd4c9ea56d22fabdf acpi/pcib: If bus does not present, give other bus drivers chance - Call acpi_DeviceIsPresent() during probing, so that if bus does not present other bus drivers could have chance to take over the bus. - In acpi_pcib_attach(), assert that bus is present, since the presence of the bus is checked during probing. Reported-by: swildner@ --- diff --git a/sys/dev/acpica5/acpi_pcib.c b/sys/dev/acpica5/acpi_pcib.c index 6c238ac455..36addd9002 100644 --- a/sys/dev/acpica5/acpi_pcib.c +++ b/sys/dev/acpica5/acpi_pcib.c @@ -40,6 +40,7 @@ #include #include +#include #include "pcib_if.h" /* Hooks for the ACPI CA debugging infrastructure. */ @@ -133,14 +134,10 @@ acpi_pcib_attach(device_t dev, ACPI_BUFFER *prt, int busno) ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); - /* - * Don't attach if we're not really there. - * - * XXX: This isn't entirely correct since we may be a PCI bus - * on a hot-plug docking station, etc. - */ - if (!acpi_DeviceIsPresent(dev)) - return_VALUE(ENXIO); + if (!acpi_DeviceIsPresent(dev)) { + /* Caller should already have checked it */ + panic("%s device is not present\n", __func__); + } ACPI_SERIAL_INIT(pcib); @@ -287,3 +284,21 @@ out: return_VALUE (interrupt); } + +int +acpi_pcib_probe(device_t dev) +{ + /* + * Don't attach if we're not really there. + * + * XXX: This isn't entirely correct since we may be a PCI bus + * on a hot-plug docking station, etc. + */ + if (!acpi_DeviceIsPresent(dev)) + return ENXIO; + + if (pci_cfgregopen() == 0) + return ENXIO; + + return 0; +} diff --git a/sys/dev/acpica5/acpi_pcib_acpi.c b/sys/dev/acpica5/acpi_pcib_acpi.c index 9debe2478b..e5661eea6b 100644 --- a/sys/dev/acpica5/acpi_pcib_acpi.c +++ b/sys/dev/acpica5/acpi_pcib_acpi.c @@ -38,7 +38,7 @@ #include "acpi.h" #include -#include +#include #include #include #include "pcib_if.h" @@ -130,14 +130,18 @@ MODULE_DEPEND(acpi_pcib, acpi, 1, 1, 1); static int acpi_pcib_acpi_probe(device_t dev) { + int error; + static char *pcib_ids[] = { "PNP0A03", NULL }; if (acpi_disabled("pcib") || ACPI_ID_PROBE(device_get_parent(dev), dev, pcib_ids) == NULL) return (ENXIO); - if (pci_cfgregopen() == 0) - return (ENXIO); + error = acpi_pcib_probe(dev); + if (error) + return (error); + device_set_desc(dev, "ACPI Host-PCI bridge"); return (0); } diff --git a/sys/dev/acpica5/acpi_pcib_pci.c b/sys/dev/acpica5/acpi_pcib_pci.c index e29e1521c2..11bf0e4f8e 100644 --- a/sys/dev/acpica5/acpi_pcib_pci.c +++ b/sys/dev/acpica5/acpi_pcib_pci.c @@ -39,7 +39,6 @@ #include #include -#include #include #include #include @@ -111,14 +110,16 @@ MODULE_DEPEND(acpi_pcib, acpi, 1, 1, 1); static int acpi_pcib_pci_probe(device_t dev) { + int error; + if (pci_get_class(dev) != PCIC_BRIDGE || pci_get_subclass(dev) != PCIS_BRIDGE_PCI || acpi_disabled("pci")) return (ENXIO); - if (acpi_get_handle(dev) == NULL) - return (ENXIO); - if (pci_cfgregopen() == 0) - return (ENXIO); + + error = acpi_pcib_probe(dev); + if (error) + return (error); device_set_desc(dev, "ACPI PCI-PCI bridge"); return (-100); diff --git a/sys/dev/acpica5/acpi_pcibvar.h b/sys/dev/acpica5/acpi_pcibvar.h index bbbacd596b..017575664d 100644 --- a/sys/dev/acpica5/acpi_pcibvar.h +++ b/sys/dev/acpica5/acpi_pcibvar.h @@ -34,6 +34,7 @@ void acpi_pci_link_add_reference(device_t dev, int index, device_t pcib, int slot, int pin); int acpi_pci_link_route_interrupt(device_t dev, int index); +int acpi_pcib_probe(device_t bus); int acpi_pcib_attach(device_t bus, ACPI_BUFFER *prt, int busno); int acpi_pcib_route_interrupt(device_t pcib, device_t dev, int pin, ACPI_BUFFER *prtbuf);