From owner-svn-src-head@freebsd.org Wed Apr 27 16:39:07 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 70CCDB1E52E; Wed, 27 Apr 2016 16:39:07 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 49D161AD3; Wed, 27 Apr 2016 16:39:07 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u3RGd6uN029551; Wed, 27 Apr 2016 16:39:06 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u3RGd5lv029543; Wed, 27 Apr 2016 16:39:05 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201604271639.u3RGd5lv029543@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Wed, 27 Apr 2016 16:39:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r298711 - in head/sys: dev/acpica dev/pci powerpc/ofw sparc64/pci X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Apr 2016 16:39:07 -0000 Author: jhb Date: Wed Apr 27 16:39:05 2016 New Revision: 298711 URL: https://svnweb.freebsd.org/changeset/base/298711 Log: 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 Modified: head/sys/dev/acpica/acpi_pcib.c head/sys/dev/acpica/acpi_pcib_acpi.c head/sys/dev/acpica/acpi_pcib_pci.c head/sys/dev/acpica/acpi_pcibvar.h head/sys/dev/pci/pci_pci.c head/sys/dev/pci/pcib_private.h head/sys/powerpc/ofw/ofw_pcib_pci.c head/sys/sparc64/pci/ofw_pcib.c Modified: head/sys/dev/acpica/acpi_pcib.c ============================================================================== --- head/sys/dev/acpica/acpi_pcib.c Wed Apr 27 16:34:29 2016 (r298710) +++ head/sys/dev/acpica/acpi_pcib.c Wed Apr 27 16:39:05 2016 (r298711) @@ -126,11 +126,10 @@ prt_attach_devices(ACPI_PCI_ROUTING_TABL 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_BUFF 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 Modified: head/sys/dev/acpica/acpi_pcib_acpi.c ============================================================================== --- head/sys/dev/acpica/acpi_pcib_acpi.c Wed Apr 27 16:34:29 2016 (r298710) +++ head/sys/dev/acpica/acpi_pcib_acpi.c Wed Apr 27 16:39:05 2016 (r298711) @@ -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)); } /* Modified: head/sys/dev/acpica/acpi_pcib_pci.c ============================================================================== --- head/sys/dev/acpica/acpi_pcib_pci.c Wed Apr 27 16:34:29 2016 (r298710) +++ head/sys/dev/acpica/acpi_pcib_pci.c Wed Apr 27 16:39:05 2016 (r298711) @@ -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 Modified: head/sys/dev/acpica/acpi_pcibvar.h ============================================================================== --- head/sys/dev/acpica/acpi_pcibvar.h Wed Apr 27 16:34:29 2016 (r298710) +++ head/sys/dev/acpica/acpi_pcibvar.h Wed Apr 27 16:39:05 2016 (r298711) @@ -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, Modified: head/sys/dev/pci/pci_pci.c ============================================================================== --- head/sys/dev/pci/pci_pci.c Wed Apr 27 16:34:29 2016 (r298710) +++ head/sys/dev/pci/pci_pci.c Wed Apr 27 16:39:05 2016 (r298711) @@ -1075,21 +1075,26 @@ pcib_attach_common(device_t dev) } int +pcib_attach_child(device_t dev) +{ + struct pcib_softc *sc; + + sc = device_get_softc(dev); + if (sc->bus.sec == 0) { + /* no secondary bus; we should have fixed this */ + return(0); + } + + sc->child = device_add_child(dev, "pci", -1); + return (bus_generic_attach(dev)); +} + +int pcib_attach(device_t dev) { - struct pcib_softc *sc; - device_t child; pcib_attach_common(dev); - sc = device_get_softc(dev); - if (sc->bus.sec != 0) { - child = device_add_child(dev, "pci", -1); - if (child != NULL) - return(bus_generic_attach(dev)); - } - - /* no secondary bus; we should have fixed this */ - return(0); + return (pcib_attach_child(dev)); } int Modified: head/sys/dev/pci/pcib_private.h ============================================================================== --- head/sys/dev/pci/pcib_private.h Wed Apr 27 16:34:29 2016 (r298710) +++ head/sys/dev/pci/pcib_private.h Wed Apr 27 16:39:05 2016 (r298711) @@ -101,6 +101,7 @@ struct pcib_secbus { struct pcib_softc { device_t dev; + device_t child; uint32_t flags; /* flags */ #define PCIB_SUBTRACTIVE 0x1 #define PCIB_DISABLE_MSI 0x2 @@ -144,6 +145,7 @@ void pcib_setup_secbus(device_t dev, st int min_count); #endif int pcib_attach(device_t dev); +int pcib_attach_child(device_t dev); void pcib_attach_common(device_t dev); void pcib_bridge_init(device_t dev); #ifdef NEW_PCIB Modified: head/sys/powerpc/ofw/ofw_pcib_pci.c ============================================================================== --- head/sys/powerpc/ofw/ofw_pcib_pci.c Wed Apr 27 16:34:29 2016 (r298710) +++ head/sys/powerpc/ofw/ofw_pcib_pci.c Wed Apr 27 16:39:05 2016 (r298711) @@ -114,10 +114,7 @@ ofw_pcib_pci_attach(device_t dev) sizeof(cell_t)); pcib_attach_common(dev); - - device_add_child(dev, "pci", -1); - - return (bus_generic_attach(dev)); + return (pcib_attach_child(dev)); } static phandle_t Modified: head/sys/sparc64/pci/ofw_pcib.c ============================================================================== --- head/sys/sparc64/pci/ofw_pcib.c Wed Apr 27 16:34:29 2016 (r298710) +++ head/sys/sparc64/pci/ofw_pcib.c Wed Apr 27 16:39:05 2016 (r298711) @@ -149,8 +149,7 @@ ofw_pcib_attach(device_t dev) ofw_pcib_gen_setup(dev); pcib_attach_common(dev); - device_add_child(dev, "pci", -1); - return (bus_generic_attach(dev)); + return (pcib_attach_child(dev)); } static void