diff options
| author | John Baldwin <jhb@FreeBSD.org> | 2016-05-09 20:50:21 +0000 |
|---|---|---|
| committer | John Baldwin <jhb@FreeBSD.org> | 2016-05-09 20:50:21 +0000 |
| commit | 8d791e5af1e6773782656648cdef47bdc35002fb (patch) | |
| tree | af412c855aeec6fd0582f885ff22d5e9bcb786e0 /sys/dev/acpica | |
| parent | 8dd5aa946f36d62f286eb56bdbc2767df0d7d17e (diff) | |
Notes
Diffstat (limited to 'sys/dev/acpica')
| -rw-r--r-- | sys/dev/acpica/acpi.c | 86 | ||||
| -rw-r--r-- | sys/dev/acpica/acpi_pci.c | 1 | ||||
| -rw-r--r-- | sys/dev/acpica/acpi_pcib.c | 8 | ||||
| -rw-r--r-- | sys/dev/acpica/acpi_pcib_acpi.c | 1 | ||||
| -rw-r--r-- | sys/dev/acpica/acpi_pcib_pci.c | 1 | ||||
| -rw-r--r-- | sys/dev/acpica/acpi_pcibvar.h | 2 | ||||
| -rw-r--r-- | sys/dev/acpica/acpivar.h | 3 |
7 files changed, 72 insertions, 30 deletions
diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c index 326fc717d462..b29b3c415277 100644 --- a/sys/dev/acpica/acpi.c +++ b/sys/dev/acpica/acpi.c @@ -211,6 +211,7 @@ static device_method_t acpi_methods[] = { DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), DEVMETHOD(bus_hint_device_unit, acpi_hint_device_unit), + DEVMETHOD(bus_get_cpus, acpi_get_cpus), DEVMETHOD(bus_get_domain, acpi_get_domain), /* ACPI bus */ @@ -1077,52 +1078,79 @@ acpi_hint_device_unit(device_t acdev, device_t child, const char *name, } /* - * Fetch the VM domain for the given device 'dev'. - * - * Return 1 + domain if there's a domain, 0 if not found; - * -1 upon an error. + * Fetch the NUMA domain for a device by mapping the value returned by + * _PXM to a NUMA domain. If the device does not have a _PXM method, + * -2 is returned. If any other error occurs, -1 is returned. */ -int -acpi_parse_pxm(device_t dev, int *domain) +static int +acpi_parse_pxm(device_t dev) { #ifdef DEVICE_NUMA - ACPI_HANDLE h; - int d, pxm; + ACPI_HANDLE handle; + ACPI_STATUS status; + int pxm; - h = acpi_get_handle(dev); - if ((h != NULL) && - ACPI_SUCCESS(acpi_GetInteger(h, "_PXM", &pxm))) { - d = acpi_map_pxm_to_vm_domainid(pxm); - if (d < 0) - return (-1); - *domain = d; - return (1); - } + handle = acpi_get_handle(dev); + if (handle == NULL) + return (-2); + status = acpi_GetInteger(handle, "_PXM", &pxm); + if (ACPI_SUCCESS(status)) + return (acpi_map_pxm_to_vm_domainid(pxm)); + if (status == AE_NOT_FOUND) + return (-2); #endif + return (-1); +} - return (0); +int +acpi_get_cpus(device_t dev, device_t child, enum cpu_sets op, size_t setsize, + cpuset_t *cpuset) +{ + int d, error; + + d = acpi_parse_pxm(child); + if (d < 0) + return (bus_generic_get_cpus(dev, child, op, setsize, cpuset)); + + switch (op) { + case LOCAL_CPUS: + if (setsize != sizeof(cpuset_t)) + return (EINVAL); + *cpuset = cpuset_domain[d]; + return (0); + case INTR_CPUS: + error = bus_generic_get_cpus(dev, child, op, setsize, cpuset); + if (error != 0) + return (error); + if (setsize != sizeof(cpuset_t)) + return (EINVAL); + CPU_AND(cpuset, &cpuset_domain[d]); + return (0); + default: + return (bus_generic_get_cpus(dev, child, op, setsize, cpuset)); + } } /* - * Fetch the NUMA domain for the given device. + * Fetch the NUMA domain for the given device 'dev'. * * If a device has a _PXM method, map that to a NUMA domain. - * - * If none is found, then it'll call the parent method. - * If there's no domain, return ENOENT. + * Otherwise, pass the request up to the parent. + * If there's no matching domain or the domain cannot be + * determined, return ENOENT. */ int acpi_get_domain(device_t dev, device_t child, int *domain) { - int ret; + int d; - ret = acpi_parse_pxm(child, domain); - /* Error */ - if (ret == -1) - return (ENOENT); - /* Found */ - if (ret == 1) + d = acpi_parse_pxm(child); + if (d >= 0) { + *domain = d; return (0); + } + if (d == -1) + return (ENOENT); /* No _PXM node; go up a level */ return (bus_generic_get_domain(dev, child, domain)); diff --git a/sys/dev/acpica/acpi_pci.c b/sys/dev/acpica/acpi_pci.c index 44b58044eef2..43a523e326ca 100644 --- a/sys/dev/acpica/acpi_pci.c +++ b/sys/dev/acpica/acpi_pci.c @@ -95,6 +95,7 @@ static device_method_t acpi_pci_methods[] = { DEVMETHOD(bus_write_ivar, acpi_pci_write_ivar), DEVMETHOD(bus_child_deleted, acpi_pci_child_deleted), DEVMETHOD(bus_child_location_str, acpi_pci_child_location_str_method), + DEVMETHOD(bus_get_cpus, acpi_get_cpus), DEVMETHOD(bus_get_dma_tag, acpi_pci_get_dma_tag), DEVMETHOD(bus_get_domain, acpi_get_domain), diff --git a/sys/dev/acpica/acpi_pcib.c b/sys/dev/acpica/acpi_pcib.c index ffcb8cafd90d..bf1fc79b2d63 100644 --- a/sys/dev/acpica/acpi_pcib.c +++ b/sys/dev/acpica/acpi_pcib.c @@ -265,3 +265,11 @@ acpi_pcib_power_for_sleep(device_t pcib, device_t dev, int *pstate) acpi_device_pwr_for_sleep(acpi_dev, dev, pstate); return (0); } + +int +acpi_pcib_get_cpus(device_t pcib, device_t dev, enum cpu_sets op, + size_t setsize, cpuset_t *cpuset) +{ + + return (bus_get_cpus(pcib, op, setsize, cpuset)); +} diff --git a/sys/dev/acpica/acpi_pcib_acpi.c b/sys/dev/acpica/acpi_pcib_acpi.c index 506e2671b30a..dfd95bc25385 100644 --- a/sys/dev/acpica/acpi_pcib_acpi.c +++ b/sys/dev/acpica/acpi_pcib_acpi.c @@ -132,6 +132,7 @@ static device_method_t acpi_pcib_acpi_methods[] = { DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + DEVMETHOD(bus_get_cpus, acpi_pcib_get_cpus), /* pcib interface */ DEVMETHOD(pcib_maxslots, pcib_maxslots), diff --git a/sys/dev/acpica/acpi_pcib_pci.c b/sys/dev/acpica/acpi_pcib_pci.c index ca94d38c4778..a041bca23708 100644 --- a/sys/dev/acpica/acpi_pcib_pci.c +++ b/sys/dev/acpica/acpi_pcib_pci.c @@ -78,6 +78,7 @@ static device_method_t acpi_pcib_pci_methods[] = { /* Bus interface */ DEVMETHOD(bus_read_ivar, acpi_pcib_read_ivar), + DEVMETHOD(bus_get_cpus, acpi_pcib_get_cpus), /* pcib interface */ DEVMETHOD(pcib_route_interrupt, acpi_pcib_pci_route_interrupt), diff --git a/sys/dev/acpica/acpi_pcibvar.h b/sys/dev/acpica/acpi_pcibvar.h index f563e77360e0..1781c637746c 100644 --- a/sys/dev/acpica/acpi_pcibvar.h +++ b/sys/dev/acpica/acpi_pcibvar.h @@ -36,6 +36,8 @@ 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); void acpi_pcib_fetch_prt(device_t bus, ACPI_BUFFER *prt); +int acpi_pcib_get_cpus(device_t pcib, device_t dev, enum cpu_sets op, + size_t setsize, cpuset_t *cpuset); 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, diff --git a/sys/dev/acpica/acpivar.h b/sys/dev/acpica/acpivar.h index 56b634f01a20..bdd179b96962 100644 --- a/sys/dev/acpica/acpivar.h +++ b/sys/dev/acpica/acpivar.h @@ -506,8 +506,9 @@ SYSCTL_DECL(_debug_acpi); * Returns the VM domain ID if found, or -1 if not found / invalid. */ int acpi_map_pxm_to_vm_domainid(int pxm); +int acpi_get_cpus(device_t dev, device_t child, enum cpu_sets op, + size_t setsize, cpuset_t *cpuset); int acpi_get_domain(device_t dev, device_t child, int *domain); -int acpi_parse_pxm(device_t dev, int *domain); #endif /* _KERNEL */ #endif /* !_ACPIVAR_H_ */ |
