git: dc75bb826441 - stable/14 - acpica: add domain ivar
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 03 Dec 2024 00:51:19 UTC
The branch stable/14 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=dc75bb826441630c9d3934044172b9b97873d532 commit dc75bb826441630c9d3934044172b9b97873d532 Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2024-10-26 10:12:37 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2024-12-03 00:39:22 +0000 acpica: add domain ivar (cherry picked from commit 7dd1f0dcd134de52c5ace8da5876b3bd518cee7e) --- sys/dev/acpica/acpi.c | 43 +++++++++++++++++++++---------------------- sys/dev/acpica/acpi_pci.c | 28 +++++++++++++++++++++++++++- sys/dev/acpica/acpivar.h | 9 ++++++++- 3 files changed, 56 insertions(+), 24 deletions(-) diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c index 45b6146b6308..cbb454a52099 100644 --- a/sys/dev/acpica/acpi.c +++ b/sys/dev/acpica/acpi.c @@ -137,6 +137,7 @@ static bus_child_location_t acpi_child_location_method; static bus_hint_device_unit_t acpi_hint_device_unit; static bus_get_property_t acpi_bus_get_prop; static bus_get_device_path_t acpi_get_device_path; +static bus_get_domain_t acpi_get_domain_method; static acpi_id_probe_t acpi_device_id_probe; static acpi_evaluate_object_t acpi_device_eval_obj; @@ -211,7 +212,7 @@ static device_method_t acpi_methods[] = { 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), + DEVMETHOD(bus_get_domain, acpi_get_domain_method), DEVMETHOD(bus_get_property, acpi_bus_get_prop), DEVMETHOD(bus_get_device_path, acpi_get_device_path), @@ -809,6 +810,7 @@ acpi_add_child(device_t bus, u_int order, const char *name, int unit) if ((ad = malloc(sizeof(*ad), M_ACPIDEV, M_NOWAIT | M_ZERO)) == NULL) return (NULL); + ad->ad_domain = ACPI_DEV_DOMAIN_UNKNOWN; resource_list_init(&ad->ad_rl); child = device_add_child_ordered(bus, order, name, unit); @@ -1045,6 +1047,9 @@ acpi_read_ivar(device_t dev, device_t child, int index, uintptr_t *result) case ACPI_IVAR_FLAGS: *(int *)result = ad->ad_flags; break; + case ACPI_IVAR_DOMAIN: + *(int *)result = ad->ad_domain; + break; case ISA_IVAR_VENDORID: case ISA_IVAR_SERIAL: case ISA_IVAR_COMPATID: @@ -1089,6 +1094,9 @@ acpi_write_ivar(device_t dev, device_t child, int index, uintptr_t value) case ACPI_IVAR_FLAGS: ad->ad_flags = (int)value; break; + case ACPI_IVAR_DOMAIN: + ad->ad_domain = (int)value; + break; default: panic("bad ivar write request (%d)", index); return (ENOENT); @@ -1287,29 +1295,16 @@ acpi_get_cpus(device_t dev, device_t child, enum cpu_sets op, size_t setsize, } } -/* - * Fetch the NUMA domain for the given device 'dev'. - * - * If a device has a _PXM method, map that to a NUMA domain. - * 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) +static int +acpi_get_domain_method(device_t dev, device_t child, int *domain) { - int d; + int error; - d = acpi_pxm_parse(child); - if (d >= 0) { - *domain = d; + error = acpi_read_ivar(dev, child, ACPI_IVAR_DOMAIN, + (uintptr_t *)domain); + if (error == 0 && *domain != ACPI_DEV_DOMAIN_UNKNOWN) return (0); - } - if (d == -1) - return (ENOENT); - - /* No _PXM node; go up a level */ - return (bus_generic_get_domain(dev, child, domain)); + return (ENOENT); } /* @@ -2303,7 +2298,7 @@ acpi_probe_child(ACPI_HANDLE handle, UINT32 level, void *context, void **status) ACPI_HANDLE h; device_t bus, child; char *handle_str; - int order; + int d, order; ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); @@ -2411,6 +2406,10 @@ acpi_probe_child(ACPI_HANDLE handle, UINT32 level, void *context, void **status) } AcpiOsFree(devinfo); } + + d = acpi_pxm_parse(child); + if (d >= 0) + ad->ad_domain = d; break; } } diff --git a/sys/dev/acpica/acpi_pci.c b/sys/dev/acpica/acpi_pci.c index a1ac3499662d..6411af02ee58 100644 --- a/sys/dev/acpica/acpi_pci.c +++ b/sys/dev/acpica/acpi_pci.c @@ -93,6 +93,7 @@ static int acpi_pci_set_powerstate_method(device_t dev, device_t child, int state); static void acpi_pci_update_device(ACPI_HANDLE handle, device_t pci_child); static bus_dma_tag_t acpi_pci_get_dma_tag(device_t bus, device_t child); +static int acpi_pci_get_domain(device_t dev, device_t child, int *domain); static device_method_t acpi_pci_methods[] = { /* Device interface */ @@ -108,7 +109,7 @@ static device_method_t acpi_pci_methods[] = { DEVMETHOD(bus_get_device_path, acpi_pci_get_device_path), DEVMETHOD(bus_get_cpus, acpi_get_cpus), DEVMETHOD(bus_get_dma_tag, acpi_pci_get_dma_tag), - DEVMETHOD(bus_get_domain, acpi_get_domain), + DEVMETHOD(bus_get_domain, acpi_pci_get_domain), /* PCI interface */ DEVMETHOD(pci_alloc_devinfo, acpi_pci_alloc_devinfo), @@ -206,6 +207,31 @@ acpi_pci_get_device_path(device_t bus, device_t child, const char *locator, stru return (pci_get_device_path_method(bus, child, locator, sb)); } +/* + * Fetch the NUMA domain for the given device 'dev'. + * + * If a device has a _PXM method, map that to a NUMA domain. + * Otherwise, pass the request up to the parent. + * If there's no matching domain or the domain cannot be + * determined, return ENOENT. + */ +static int +acpi_pci_get_domain(device_t dev, device_t child, int *domain) +{ + int d; + + d = acpi_pxm_parse(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)); +} + /* * PCI power manangement */ diff --git a/sys/dev/acpica/acpivar.h b/sys/dev/acpica/acpivar.h index a8bd9ec33cb7..80ea18e782ac 100644 --- a/sys/dev/acpica/acpivar.h +++ b/sys/dev/acpica/acpivar.h @@ -86,6 +86,7 @@ struct acpi_device { void *ad_private; int ad_flags; int ad_cls_class; + int ad_domain; ACPI_BUFFER dsd; /* Device Specific Data */ const ACPI_OBJECT *dsd_pkg; @@ -269,6 +270,12 @@ extern int acpi_override_isa_irq_polarity; #define ACPI_IVAR_UNUSED 0x101 /* Unused/reserved. */ #define ACPI_IVAR_PRIVATE 0x102 #define ACPI_IVAR_FLAGS 0x103 +#define ACPI_IVAR_DOMAIN 0x104 + +/* + * ad_domain NUMA domain special value. + */ +#define ACPI_DEV_DOMAIN_UNKNOWN (-1) /* * Accessor functions for our ivars. Default value for BUS_READ_IVAR is @@ -294,6 +301,7 @@ static __inline void varp ## _set_ ## var(device_t dev, type t) \ __ACPI_BUS_ACCESSOR(acpi, handle, ACPI, HANDLE, ACPI_HANDLE) __ACPI_BUS_ACCESSOR(acpi, private, ACPI, PRIVATE, void *) __ACPI_BUS_ACCESSOR(acpi, flags, ACPI, FLAGS, int) +__ACPI_BUS_ACCESSOR(acpi, domain, ACPI, DOMAIN, int) void acpi_fake_objhandler(ACPI_HANDLE h, void *data); static __inline device_t @@ -594,7 +602,6 @@ int acpi_pxm_parse(device_t dev); */ int acpi_map_pxm_to_vm_domainid(int pxm); bus_get_cpus_t acpi_get_cpus; -bus_get_domain_t acpi_get_domain; #ifdef __aarch64__ /*