Date: Fri, 13 May 2011 17:56:53 GMT From: John Baldwin <jhb@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 193073 for review Message-ID: <201105131756.p4DHurHm010721@skunkworks.freebsd.org>
next in thread | raw e-mail | index | archive | help
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); +}
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201105131756.p4DHurHm010721>