From 4a26c9bbdf73e90e480ac36d601cd327f8cf76f0 Mon Sep 17 00:00:00 2001 From: jhb Date: Wed, 27 Apr 2016 16:39:05 +0000 Subject: Add a pcib_attach_child() method to manage adding the child "pci" device. This allows the PCI-PCI bridge driver to save a reference to the child device in its softc. Note that this required moving the "pci" device creation out of acpi_pcib_attach(). Instead, acpi_pcib_attach() is renamed to acpi_pcib_fetch_prt() as it's sole action now is to fetch the PCI interrupt routing table. Differential Revision: https://reviews.freebsd.org/D6021 --- sys/dev/acpica/acpi_pcib.c | 18 +++--------------- sys/dev/acpica/acpi_pcib_acpi.c | 8 +++++++- sys/dev/acpica/acpi_pcib_pci.c | 4 +++- sys/dev/acpica/acpi_pcibvar.h | 2 +- 4 files changed, 14 insertions(+), 18 deletions(-) (limited to 'sys/dev/acpica') diff --git a/sys/dev/acpica/acpi_pcib.c b/sys/dev/acpica/acpi_pcib.c index c2c2499..ffcb8ca 100644 --- a/sys/dev/acpica/acpi_pcib.c +++ b/sys/dev/acpica/acpi_pcib.c @@ -126,11 +126,10 @@ prt_attach_devices(ACPI_PCI_ROUTING_TABLE *entry, void *arg) ACPI_ADR_PCI_SLOT(entry->Address), entry->Pin); } -int -acpi_pcib_attach(device_t dev, ACPI_BUFFER *prt, int busno) +void +acpi_pcib_fetch_prt(device_t dev, ACPI_BUFFER *prt) { ACPI_STATUS status; - int error; ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); @@ -148,20 +147,9 @@ acpi_pcib_attach(device_t dev, ACPI_BUFFER *prt, int busno) acpi_name(acpi_get_handle(dev)), AcpiFormatException(status)); /* - * Attach the PCI bus proper. - */ - if (device_add_child(dev, "pci", -1) == NULL) { - device_printf(device_get_parent(dev), "couldn't attach pci bus\n"); - return_VALUE(ENXIO); - } - - /* - * Now go scan the bus. + * Ensure all the link devices are attached. */ prt_walk_table(prt, prt_attach_devices, dev); - - error = bus_generic_attach(dev); - return_VALUE(error); } static void diff --git a/sys/dev/acpica/acpi_pcib_acpi.c b/sys/dev/acpica/acpi_pcib_acpi.c index f31bab7..e9bcbd1 100644 --- a/sys/dev/acpica/acpi_pcib_acpi.c +++ b/sys/dev/acpica/acpi_pcib_acpi.c @@ -502,7 +502,13 @@ acpi_pcib_acpi_attach(device_t dev) if (sc->ap_segment == 0 && sc->ap_bus == 0) bus0_seen = 1; - return (acpi_pcib_attach(dev, &sc->ap_prt, sc->ap_bus)); + acpi_pcib_fetch_prt(dev, &sc->ap_prt); + + if (device_add_child(dev, "pci", -1) == NULL) { + device_printf(device_get_parent(dev), "couldn't attach pci bus\n"); + return (ENXIO); + } + return (bus_generic_attach(dev)); } /* diff --git a/sys/dev/acpica/acpi_pcib_pci.c b/sys/dev/acpica/acpi_pcib_pci.c index d3f4cbc..ca94d38 100644 --- a/sys/dev/acpica/acpi_pcib_pci.c +++ b/sys/dev/acpica/acpi_pcib_pci.c @@ -120,7 +120,9 @@ acpi_pcib_pci_attach(device_t dev) pcib_attach_common(dev); sc = device_get_softc(dev); sc->ap_handle = acpi_get_handle(dev); - return (acpi_pcib_attach(dev, &sc->ap_prt, sc->ap_pcibsc.bus.sec)); + acpi_pcib_fetch_prt(dev, &sc->ap_prt); + + return (pcib_attach_child(dev)); } static int diff --git a/sys/dev/acpica/acpi_pcibvar.h b/sys/dev/acpica/acpi_pcibvar.h index 9a4be07..f563e77 100644 --- a/sys/dev/acpica/acpi_pcibvar.h +++ b/sys/dev/acpica/acpi_pcibvar.h @@ -35,7 +35,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_attach(device_t bus, ACPI_BUFFER *prt, int busno); +void acpi_pcib_fetch_prt(device_t bus, ACPI_BUFFER *prt); int acpi_pcib_route_interrupt(device_t pcib, device_t dev, int pin, ACPI_BUFFER *prtbuf); int acpi_pcib_power_for_sleep(device_t pcib, device_t dev, -- cgit v1.1