From owner-p4-projects@FreeBSD.ORG Sat Apr 16 04:08:58 2011 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 99635106566C; Sat, 16 Apr 2011 04:08:57 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 51658106564A for ; Sat, 16 Apr 2011 04:08:57 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [IPv6:2001:4f8:fff6::2d]) by mx1.freebsd.org (Postfix) with ESMTP id 243EB8FC08 for ; Sat, 16 Apr 2011 04:08:57 +0000 (UTC) Received: from skunkworks.freebsd.org (localhost [127.0.0.1]) by skunkworks.freebsd.org (8.14.4/8.14.4) with ESMTP id p3G48v8C007433 for ; Sat, 16 Apr 2011 04:08:57 GMT (envelope-from jhb@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.4/8.14.4/Submit) id p3G48vl7007430 for perforce@freebsd.org; Sat, 16 Apr 2011 04:08:57 GMT (envelope-from jhb@freebsd.org) Date: Sat, 16 Apr 2011 04:08:57 GMT Message-Id: <201104160408.p3G48vl7007430@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to jhb@freebsd.org using -f From: John Baldwin To: Perforce Change Reviews Precedence: bulk Cc: Subject: PERFORCE change 191580 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 Apr 2011 04:08:58 -0000 http://p4web.freebsd.org/@@191580?ac=10 Change 191580 by jhb@jhb_fiver on 2011/04/16 04:07:53 Update the ACPI Host-PCI bridge driver to properly handle bus number resources (I think). Affected files ... .. //depot/projects/pci/sys/dev/acpica/acpi_pcib_acpi.c#6 edit Differences ... ==== //depot/projects/pci/sys/dev/acpica/acpi_pcib_acpi.c#6 (text+ko) ==== @@ -64,7 +64,6 @@ ACPI_BUFFER ap_prt; /* interrupt routing table */ #ifdef NEW_PCIB struct pcib_host_resources ap_host_res; - struct resource *ap_bus_res; /* resource for 'ap_bus' */ #endif }; @@ -219,9 +218,11 @@ case ACPI_IO_RANGE: type = SYS_RES_IOPORT; break; +#ifdef PCI_RES_BUS case ACPI_BUS_NUMBER_RANGE: type = PCI_RES_BUS; break; +#endif default: return (AE_OK); } @@ -266,6 +267,11 @@ ACPI_STATUS status; static int bus0_seen = 0; u_int addr, slot, func, busok; +#if defined(NEW_PCIB) && defined(PCI_RES_BUS) + struct resource *bus_res; + u_long start, end; + int rid; +#endif uint8_t busno; ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); @@ -365,15 +371,38 @@ } } -#ifdef NEW_PCIB +#if defined(NEW_PCIB) && defined(PCI_RES_BUS) /* - * If we have a valid bus number, allocate it from our domain. If - * we do not have a valid bus number, hope that ACPI at least lays - * out the Host-PCI bridges in order and that as a result the next - * free bus number is our bus number. + * If nothing else worked, hope that ACPI at least lays out the + * Host-PCI bridges in order and that as a result the next free + * bus number is our bus number. */ - if (busok) { + if (busok == 0) { + /* + * If we have a region of bus numbers, use the first + * number for our bus. + */ + if (rman_first_free_region(&sc->ap_host_res.hr_bus_rman, &start, + &end) == 0) + sc->ap_bus = start; + else { + rid = 0; + bus_res = bus_alloc_resource(dev, PCI_RES_BUS, &rid, 0, + PCI_BUSMAX, 1, 0); + if (bus_res == NULL) { + device_printf(dev, "could not allocate bus number\n"); + pcib_host_res_free(dev, &sc->ap_host_res); + return (ENXIO); + } + sc->ap_bus = rman_get_start(bus_res); + bus_release_resource(dev, PCI_RES_BUS, rid, bus_res); + } } else { +#ifdef INVARIANTS + if (rman_first_free_region(&sc->ap_host_res.hr_bus_rman, &start, + &end) == 0) + KASSERT(start == sc->ap_bus, ("bus number mismatch")); +#endif } #else /*