Date: Sat, 16 Apr 2011 21:33:38 GMT From: John Baldwin <jhb@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 191632 for review Message-ID: <201104162133.p3GLXcit002895@skunkworks.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://p4web.freebsd.org/@@191632?ac=10 Change 191632 by jhb@jhb_jhbbsd on 2011/04/16 21:33:25 Compile. Affected files ... .. //depot/projects/pci/sys/dev/acpica/acpi_pcib_acpi.c#7 edit .. //depot/projects/pci/sys/dev/acpica/acpi_resource.c#5 edit .. //depot/projects/pci/sys/dev/pci/pci_domain.c#3 edit .. //depot/projects/pci/sys/dev/pci/pci_pci.c#13 edit .. //depot/projects/pci/sys/dev/pci/pcib_private.h#10 edit .. //depot/projects/pci/sys/x86/x86/nexus.c#6 edit Differences ... ==== //depot/projects/pci/sys/dev/acpica/acpi_pcib_acpi.c#7 (text+ko) ==== @@ -200,7 +200,10 @@ max = res->Data.Address64.Maximum; length = res->Data.Address64.AddressLength; break; - case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64: + default: + KASSERT(res->Type == + ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64, + ("should never happen")); min = res->Data.ExtAddress64.Minimum; max = res->Data.ExtAddress64.Maximum; length = res->Data.ExtAddress64.AddressLength; ==== //depot/projects/pci/sys/dev/acpica/acpi_resource.c#5 (text+ko) ==== @@ -141,9 +141,30 @@ struct acpi_resource_context { struct acpi_parse_resource_set *set; + device_t dev; void *context; }; +#ifdef ACPI_DEBUG_OUTPUT +static const char * +acpi_address_range_name(UINT8 ResourceType) +{ + static char buf[16]; + + switch (ResourceType) { + case ACPI_MEMORY_RANGE: + return ("Memory"); + case ACPI_IO_RANGE: + return ("IO"); + case ACPI_BUS_NUMBER_RANGE: + return ("Bus Number"); + default: + snprintf(buf, sizeof(buf), "type %u", ResourceType); + return (buf); + } +} +#endif + static ACPI_STATUS acpi_parse_resource(ACPI_RESOURCE *res, void *context) { @@ -151,12 +172,10 @@ struct acpi_resource_context *arc; UINT64 min, max, length, gran; const char *name; + device_t dev; -#define ADDRESS_RANGE_NAME(type) \ - ((type) == ACPI_MEMORY_RANGE ? "Memory" : (type) == ACPI_IO_RANGE ? "IO" : \ - "Bus Number") - arc = context; + dev = arc->dev; set = arc->set; switch (res->Type) { @@ -263,7 +282,7 @@ case ACPI_RESOURCE_TYPE_ADDRESS32: case ACPI_RESOURCE_TYPE_ADDRESS64: case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64: - switch (res->type) { + switch (res->Type) { case ACPI_RESOURCE_TYPE_ADDRESS16: gran = res->Data.Address16.Granularity; min = res->Data.Address16.Minimum; @@ -285,7 +304,9 @@ length = res->Data.Address64.AddressLength; name = "Address64"; break; - case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64: + default: + KASSERT(res->Type == ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64, + ("should never happen")); gran = res->Data.ExtAddress64.Granularity; min = res->Data.ExtAddress64.Minimum; max = res->Data.ExtAddress64.Maximum; @@ -293,12 +314,12 @@ name = "ExtAddress64"; break; } - if (len <= 0) + if (length <= 0) break; if (res->Data.Address.ProducerConsumer != ACPI_CONSUMER) { ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "ignored %s %s producer\n", name, - ADDRESS_RANGE_NAME(res->Data.Address.ResourceType))); + acpi_address_range_name(res->Data.Address.ResourceType))); break; } if (res->Data.Address.ResourceType != ACPI_MEMORY_RANGE && @@ -374,16 +395,14 @@ acpi_parse_resources(device_t dev, ACPI_HANDLE handle, struct acpi_parse_resource_set *set, void *arg) { - ACPI_BUFFER buf; - ACPI_RESOURCE *res; - char *curr, *last; + struct acpi_resource_context arc; ACPI_STATUS status; - struct acpi_resource_context arc; ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); set->set_init(dev, arg, &arc.context); arc.set = set; + arc.dev = dev; status = AcpiWalkResources(handle, "_CRS", acpi_parse_resource, &arc); if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { printf("can't fetch resources for %s - %s\n", ==== //depot/projects/pci/sys/dev/pci/pci_domain.c#3 (text+ko) ==== @@ -4,8 +4,13 @@ * Support utilities for Host to PCI bridge drivers. */ +#include <sys/param.h> +#include <sys/bus.h> +#include <sys/libkern.h> +#include <sys/malloc.h> #include <sys/rman.h> #include <dev/pci/pcireg.h> +#include <dev/pci/pcivar.h> #include <dev/pci/pcib_private.h> struct pci_domain { @@ -37,12 +42,12 @@ snprintf(buf, sizeof(buf), "PCI domain %d", domain); d = malloc(sizeof(*d) + strlen(buf) + 1, M_DEVBUF, M_WAITOK | M_ZERO); d->pd_domain = domain; - d->pd_rman.rm_start = 0; - d->pd_rman.rm_end = PCI_BUSMAX; - d->pd_rman.rm_type = RMAN_ARRAY; - d->pd_rman.rm_descr = (char *)(d + 1); - strcpy(d->pd_rman.rm_descr, buf); - error = rman_init(&d->pd_rman); + d->pd_bus_rman.rm_start = 0; + d->pd_bus_rman.rm_end = PCI_BUSMAX; + d->pd_bus_rman.rm_type = RMAN_ARRAY; + strcpy((char *)(d + 1), buf); + d->pd_bus_rman.rm_descr = (char *)(d + 1); + error = rman_init(&d->pd_bus_rman); if (error) panic("Failed to initialize PCI domain %d rman", domain); TAILQ_INSERT_TAIL(&domains, d, pd_link); @@ -50,8 +55,8 @@ } struct resource * -pci_domain_alloc_bus(int domain, device_t dev, int *rid, u_long start, u_long end, - u_long count, u_int flags) +pci_domain_alloc_bus(int domain, device_t dev, int *rid, u_long start, + u_long end, u_long count, u_int flags) { struct pci_domain *d; struct resource *res; @@ -59,7 +64,8 @@ if (domain < 0 || domain > PCI_DOMAINMAX) return (NULL); d = pci_find_domain(domain); - res = rman_reserve_resource(&d->pd_rman, start, end, count, flags, dev); + res = rman_reserve_resource(&d->pd_bus_rman, start, end, count, flags, + dev); if (res == NULL) return (NULL); @@ -68,8 +74,8 @@ } int -pci_domain_adjust_bus(int domain, device_t dev, struct resource *r, u_long start, - u_long end) +pci_domain_adjust_bus(int domain, device_t dev, struct resource *r, + u_long start, u_long end) { #ifdef INVARIANTS struct pci_domain *d; @@ -79,7 +85,7 @@ return (EINVAL); #ifdef INVARIANTS d = pci_find_domain(domain); - KASSERT(rman_is_region_manager(r, &d->pd_rman), "bad resource"); + KASSERT(rman_is_region_manager(r, &d->pd_bus_rman), ("bad resource")); #endif return (rman_adjust_resource(r, start, end)); } @@ -95,7 +101,7 @@ return (EINVAL); #ifdef INVARIANTS d = pci_find_domain(domain); - KASSERT(rman_is_region_manager(r, &d->pd_rman), "bad resource"); + KASSERT(rman_is_region_manager(r, &d->pd_bus_rman), ("bad resource")); #endif return (rman_release_resource(r)); } @@ -178,7 +184,7 @@ * Release all allocated resources and remove them from the * parent's resource list. */ - STAILQ_FOREACH(rle, rl, link) { + STAILQ_FOREACH(rle, &hr->hr_rl, link) { if (rle->res != NULL) { bus_release_resource(pcib, rle->type, rle->rid, rle->res); @@ -186,7 +192,8 @@ } bus_delete_resource(pcib, rle->type, rle->rid); } - resource_list_delete(&hr->hr_rl); + resource_list_free(&hr->hr_rl); + return (0); } static struct rman * @@ -239,20 +246,21 @@ return (error); r = bus_alloc_resource_any(hr->hr_pcib, type, &rid, 0); if (r == NULL) { - device_printf(pcib, "Failed to allocate %d res %#lx-%#lx\n", - type, start, end); + device_printf(hr->hr_pcib, + "Failed to allocate %d res %#lx-%#lx\n", type, start, end); return (ENXIO); } KASSERT(rman_get_start(r) == start && rman_get_end(r) == end, ("resource mismatch")); error = rman_manage_region(rm, start, end); if (error) { - device_printf(pcib, "Failed to add %d res %#lx-%#lx to rman\n", - type, start, end); + device_printf(hr->hr_pcib, + "Failed to add %d res %#lx-%#lx to rman\n", type, start, + end); bus_release_resource(hr->hr_pcib, type, rid, r); return (error); } - rle = resource_list_add(&hr->hr_rl, type, start, end, count); + rle = resource_list_add(&hr->hr_rl, type, rid, start, end, count); rle->res = r; return (0); } @@ -264,7 +272,6 @@ { struct resource *r; struct rman *rm; - int error; rm = pcib_host_res_rman(hr, type); if (rm == NULL) @@ -280,7 +287,7 @@ } if (bootverbose) - device_printf(sc->dev, + device_printf(hr->hr_pcib, "allocated type %d (%#lx-%#lx) for rid %x of %s\n", type, rman_get_start(r), rman_get_end(r), *rid, pcib_child_name(dev)); @@ -292,7 +299,7 @@ * activating sub-allocated resources. */ if (flags & RF_ACTIVE) { - if (bus_activate_resource(child, type, *rid, r) != 0) { + if (bus_activate_resource(dev, type, *rid, r) != 0) { rman_release_resource(r); *rp = NULL; return (0); @@ -310,7 +317,8 @@ if (pcib_host_res_is_resource_managed(hr, type, r)) return (rman_adjust_resource(r, start, end)); - return (bus_generic_adjust_resource(bus, child, type, r, start, end)); + return (bus_generic_adjust_resource(hr->hr_pcib, dev, type, r, start, + end)); } int @@ -321,12 +329,11 @@ if (pcib_host_res_is_resource_managed(hr, type, r)) { if (rman_get_flags(r) & RF_ACTIVE) { - error = bus_deactivate_resource(child, type, rid, r); + error = bus_deactivate_resource(dev, type, rid, r); if (error) return (error); } return (rman_release_resource(r)); } - return (bus_generic_release_resource(dev, child, type, rid, r)); + return (bus_generic_release_resource(hr->hr_pcib, dev, type, rid, r)); } - ==== //depot/projects/pci/sys/dev/pci/pci_pci.c#13 (text+ko) ==== @@ -770,7 +770,7 @@ } #ifdef NEW_PCIB -static const char * +const char * pcib_child_name(device_t child) { static char buf[64]; ==== //depot/projects/pci/sys/dev/pci/pcib_private.h#10 (text+ko) ==== @@ -105,6 +105,7 @@ typedef uint32_t pci_read_config_fn(int b, int s, int f, int reg, int width); #ifdef NEW_PCIB +const char *pcib_child_name(device_t child); int pcib_host_res_init(device_t pcib, struct pcib_host_resources *hr); int pcib_host_res_free(device_t pcib, ==== //depot/projects/pci/sys/x86/x86/nexus.c#6 (text+ko) ==== @@ -70,7 +70,10 @@ #include <machine/resource.h> #include <machine/pc/bios.h> +#ifdef PCI_RES_BUS +#include <dev/pci/pcivar.h> #include <dev/pci/pcib_private.h> +#endif #ifdef DEV_APIC #include "pcib_if.h"
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201104162133.p3GLXcit002895>