From owner-p4-projects@FreeBSD.ORG Fri May 13 17:56:54 2011 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id DF3411065673; Fri, 13 May 2011 17:56:53 +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 A18DE106564A for ; Fri, 13 May 2011 17:56:53 +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 8F3508FC0A for ; Fri, 13 May 2011 17:56:53 +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 p4DHurv3010724 for ; Fri, 13 May 2011 17:56:53 GMT (envelope-from jhb@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.4/8.14.4/Submit) id p4DHurHm010721 for perforce@freebsd.org; Fri, 13 May 2011 17:56:53 GMT (envelope-from jhb@freebsd.org) Date: Fri, 13 May 2011 17:56:53 GMT Message-Id: <201105131756.p4DHurHm010721@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 193073 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: Fri, 13 May 2011 17:56:54 -0000 http://p4web.freebsd.org/@@193073?ac=10 Change 193073 by jhb@jhb_fiver on 2011/05/13 17:56:19 - Centralize host_mem_start rather than duplicating it a fourth time. - Add adjust resource method for mptable host bridge driver. Affected files ... .. //depot/projects/pci/sys/amd64/pci/pci_bus.c#6 edit .. //depot/projects/pci/sys/dev/acpica/acpi_pcib_acpi.c#19 edit .. //depot/projects/pci/sys/i386/pci/pci_bus.c#6 edit .. //depot/projects/pci/sys/x86/include/bus.h#2 edit .. //depot/projects/pci/sys/x86/x86/mptable_pci.c#9 edit .. //depot/projects/pci/sys/x86/x86/nexus.c#8 edit Differences ... ==== //depot/projects/pci/sys/amd64/pci/pci_bus.c#6 (text+ko) ==== @@ -302,35 +302,12 @@ return ENOENT; } -SYSCTL_DECL(_hw_pci); - -static unsigned long legacy_host_mem_start = 0x80000000; -TUNABLE_ULONG("hw.pci.host_mem_start", &legacy_host_mem_start); -SYSCTL_ULONG(_hw_pci, OID_AUTO, host_mem_start, CTLFLAG_RDTUN, - &legacy_host_mem_start, 0x80000000, - "Limit the host bridge memory to being above this address. Must be\n\ -set at boot via a tunable."); - struct resource * legacy_pcib_alloc_resource(device_t dev, device_t child, int type, int *rid, u_long start, u_long end, u_long count, u_int flags) { - /* - * If no memory preference is given, use upper 32MB slot most - * bioses use for their memory window. Typically other bridges - * before us get in the way to assert their preferences on memory. - * Hardcoding like this sucks, so a more MD/MI way needs to be - * found to do it. This is typically only used on older laptops - * that don't have pci busses behind pci bridge, so assuming > 32MB - * is liekly OK. - * - * However, this can cause problems for other chipsets, so we make - * this tunable by hw.pci.host_mem_start. - */ - if (type == SYS_RES_MEMORY && start == 0UL && end == ~0UL) - start = legacy_host_mem_start; - if (type == SYS_RES_IOPORT && start == 0UL && end == ~0UL) - start = 0x1000; + + start = hostb_alloc_start(type, start, end, count); return (bus_generic_alloc_resource(dev, child, type, rid, start, end, count, flags)); } ==== //depot/projects/pci/sys/dev/acpica/acpi_pcib_acpi.c#19 (text+ko) ==== @@ -547,17 +547,9 @@ struct acpi_hpcib_softc *sc; #endif - /* - * If this is not a request for a specific resource range, - * exclude low resource ranges that are not generally suitable - * for PCI BARs, etc. - */ - if (start + count - 1 != end) { - if (type == SYS_RES_MEMORY && start < acpi_host_mem_start) - start = acpi_host_mem_start; - if (type == SYS_RES_IOPORT && start < 0x1000) - start = 0x1000; - } +#if defined(__i386__) || defined(__amd64__) + start = hostb_alloc_start(type, start, end, count); +#endif #ifdef NEW_PCIB sc = device_get_softc(dev); ==== //depot/projects/pci/sys/i386/pci/pci_bus.c#6 (text+ko) ==== @@ -519,35 +519,12 @@ return ENOENT; } -SYSCTL_DECL(_hw_pci); - -static unsigned long legacy_host_mem_start = 0x80000000; -TUNABLE_ULONG("hw.pci.host_mem_start", &legacy_host_mem_start); -SYSCTL_ULONG(_hw_pci, OID_AUTO, host_mem_start, CTLFLAG_RDTUN, - &legacy_host_mem_start, 0x80000000, - "Limit the host bridge memory to being above this address. Must be\n\ -set at boot via a tunable."); - struct resource * legacy_pcib_alloc_resource(device_t dev, device_t child, int type, int *rid, u_long start, u_long end, u_long count, u_int flags) { - /* - * If no memory preference is given, use upper 32MB slot most - * bioses use for their memory window. Typically other bridges - * before us get in the way to assert their preferences on memory. - * Hardcoding like this sucks, so a more MD/MI way needs to be - * found to do it. This is typically only used on older laptops - * that don't have pci busses behind pci bridge, so assuming > 32MB - * is liekly OK. - * - * However, this can cause problems for other chipsets, so we make - * this tunable by hw.pci.host_mem_start. - */ - if (type == SYS_RES_MEMORY && start == 0UL && end == ~0UL) - start = legacy_host_mem_start; - if (type == SYS_RES_IOPORT && start == 0UL && end == ~0UL) - start = 0x1000; + + start = hostb_alloc_start(type, start, end, count); return (bus_generic_alloc_resource(dev, child, type, rid, start, end, count, flags)); } ==== //depot/projects/pci/sys/x86/include/bus.h#2 (text+ko) ==== @@ -1095,4 +1095,6 @@ #define bus_space_copy_region_stream_4(t, h1, o1, h2, o2, c) \ bus_space_copy_region_4((t), (h1), (o1), (h2), (o2), (c)) +u_long hostb_alloc_start(int type, u_long start, u_long end, u_long count); + #endif /* _X86_BUS_H_ */ ==== //depot/projects/pci/sys/x86/x86/mptable_pci.c#9 (text+ko) ==== @@ -164,9 +164,21 @@ } } } + start = hostb_alloc_start(type, start, end, count); return (pcib_host_res_alloc(&sc->sc_host_res, child, type, rid, start, end, count, flags)); } + +int +mptable_hostb_adjust_resource(device_t dev, device_t child, int type, + struct resource *r, u_long start, u_long end) +{ + struct mptable_hostb_softc *sc; + + sc = device_get_softc(dev); + return (pcib_host_res_adjust(&sc->sc_host_res, child, type, r, start, + end)); +} #endif static device_method_t mptable_hostb_methods[] = { @@ -182,8 +194,8 @@ DEVMETHOD(bus_read_ivar, legacy_pcib_read_ivar), DEVMETHOD(bus_write_ivar, legacy_pcib_write_ivar), #ifdef NEW_PCIB - DEVMETHOD(bus_alloc_resource, legacy_pcib_alloc_resource), - DEVMETHOD(bus_adjust_resource, bus_generic_adjust_resource), + DEVMETHOD(bus_alloc_resource, mptable_hostb_alloc_resource), + DEVMETHOD(bus_adjust_resource, mptable_hostb_adjust_resource), #else DEVMETHOD(bus_alloc_resource, legacy_pcib_alloc_resource), DEVMETHOD(bus_adjust_resource, bus_generic_adjust_resource), ==== //depot/projects/pci/sys/x86/x86/nexus.c#8 (text+ko) ==== @@ -856,3 +856,37 @@ DRIVER_MODULE(sysresource, isa, sysresource_driver, sysresource_devclass, 0, 0); #endif /* DEV_ISA */ + + +/* + * Helper routine for x86 Host-PCI bridge driver resource allocation. + * This is used to adjust the start address of wildcard allocation + * requests to avoid low addresses that are known to be problematic. + * + * If no memory preference is given, use upper 32MB slot most BIOSes + * use for their memory window. This is typically only used on older + * laptops that don't have PCI busses behind a PCI bridge, so assuming + * > 32MB is likely OK. + * + * However, this can cause problems for other chipsets, so we make + * this tunable by hw.pci.host_mem_start. + */ +SYSCTL_DECL(_hw_pci); + +static unsigned long host_mem_start = 0x80000000; +TUNABLE_ULONG("hw.pci.host_mem_start", &host_mem_start); +SYSCTL_ULONG(_hw_pci, OID_AUTO, host_mem_start, CTLFLAG_RDTUN, &host_mem_start, 0, + "Limit the host bridge memory to being above this address."); + +u_long +hostb_alloc_start(int type, u_long start, u_long end, u_long count) +{ + + if (start + count - 1 != end) { + if (type == SYS_RES_MEMORY && start < acpi_host_mem_start) + start = host_mem_start; + if (type == SYS_RES_IOPORT && start < 0x1000) + start = 0x1000; + } + return (start); +}