From: Zhang Zekun <zhangzekun11@huawei.com> hulk inclusion category: feature bugzilla: https://atomgit.com/src-openeuler/kernel/issues/20607 -------------------------------------------- After a device is hot-added, the locality information which is initialized in the boot time will be removed after performing the hot-remove procedure. Let the hot-added device using the static HMAT locality information when _HMA is specified and a empty buffer is returned, which means no update of the system locality information since boot time. Signed-off-by: Zhang Zekun <zhangzekun11@huawei.com> Conflicts: drivers/acpi/numa/hmat.c [Ziming Du: context conflict de03acfa5731af980b681e0370157d014ba077d3] Signed-off-by: Ziming Du <duziming2@huawei.com> --- drivers/acpi/acpi_memhotplug.c | 13 +++++++++++++ drivers/acpi/internal.h | 1 + drivers/acpi/numa/hmat.c | 17 +++++++++++++++++ 3 files changed, 31 insertions(+) diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c index 456647c6ef819..40b8bc3c3da77 100644 --- a/drivers/acpi/acpi_memhotplug.c +++ b/drivers/acpi/acpi_memhotplug.c @@ -265,6 +265,19 @@ static int acpi_memory_enable_device(struct acpi_memory_device *mem_device) hotplug_mdev_set(mem_device); num_enabled++; } + if (acpi_has_method(handle, "_HMA")) { + acpi_status status; + struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; + + status = acpi_evaluate_object(handle, "_HMA", NULL, &buffer); + if (ACPI_SUCCESS(status) && buffer.length) { + union acpi_object *obj = buffer.pointer; + + if (!obj->buffer.length) + hmat_restore_target(node); + } + } + if (!num_enabled) { dev_err(&mem_device->device->dev, "add_memory failed\n"); return -EINVAL; diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h index 0592aebe0c394..10f64907f3c37 100644 --- a/drivers/acpi/internal.h +++ b/drivers/acpi/internal.h @@ -273,5 +273,6 @@ void acpi_init_lpit(void); #else static inline void acpi_init_lpit(void) { } #endif +void hmat_restore_target(int nid); #endif /* _ACPI_INTERNAL_H_ */ diff --git a/drivers/acpi/numa/hmat.c b/drivers/acpi/numa/hmat.c index dfcd27a42ce92..c95d3bcda525f 100644 --- a/drivers/acpi/numa/hmat.c +++ b/drivers/acpi/numa/hmat.c @@ -804,6 +804,23 @@ static void hmat_hotplug_target(struct memory_target *target) target->registered = true; } +void hmat_restore_target(int nid) +{ + struct memory_target *target; + int pxm; + + pxm = node_to_pxm(nid); + target = find_mem_target(pxm); + if (!target) + return; + + mutex_lock(&target_lock); + hmat_register_target_cache(target); + hmat_register_target_perf(target, 0); + hmat_register_target_perf(target, 1); + mutex_unlock(&target_lock); +} + static void hmat_register_target(struct memory_target *target) { /* -- 2.43.0