hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I67QNJ CVE: NA
---------------------------------------------------------
Export the state of a hotplug memory device, and driviers can use this information to manipulate the hotplug memory device.
Signed-off-by: Zhang Zekun zhangzekun11@huawei.com --- drivers/acpi/acpi_memhotplug.c | 22 ++++++++++++++++++++++ include/linux/memory_hotplug.h | 1 + 2 files changed, 23 insertions(+)
diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c index d0c1a71007d0..7354c6cb69a5 100644 --- a/drivers/acpi/acpi_memhotplug.c +++ b/drivers/acpi/acpi_memhotplug.c @@ -57,6 +57,9 @@ struct acpi_memory_device { int mgid; };
+struct acpi_device *hotplug_mdev[MAX_NUMNODES]; +EXPORT_SYMBOL_GPL(hotplug_mdev); + static acpi_status acpi_memory_get_resource(struct acpi_resource *resource, void *context) { @@ -167,6 +170,22 @@ static void acpi_unbind_memory_blocks(struct acpi_memory_info *info) acpi_unbind_memblk); }
+static void hotplug_mdev_set(struct acpi_memory_device *mem_device) +{ + acpi_handle handle = mem_device->device->handle; + int nid = acpi_get_node(handle); + + hotplug_mdev[nid] = mem_device->device; +} + +static void hotplug_mdev_clear(struct acpi_memory_device *mem_device) +{ + acpi_handle handle = mem_device->device->handle; + int nid = acpi_get_node(handle); + + hotplug_mdev[nid] = NULL; +} + static int acpi_memory_enable_device(struct acpi_memory_device *mem_device) { acpi_handle handle = mem_device->device->handle; @@ -235,6 +254,8 @@ static int acpi_memory_enable_device(struct acpi_memory_device *mem_device) * Add num_enable even if add_memory() returns -EEXIST, so the * device is bound to this driver. */ + + hotplug_mdev_set(mem_device); num_enabled++; } if (!num_enabled) { @@ -256,6 +277,7 @@ static void acpi_memory_remove_memory(struct acpi_memory_device *mem_device) { struct acpi_memory_info *info, *n;
+ hotplug_mdev_clear(mem_device); list_for_each_entry_safe(info, n, &mem_device->res_list, list) { if (!info->enabled) continue; diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h index 7d2076583494..22c0b6c87f08 100644 --- a/include/linux/memory_hotplug.h +++ b/include/linux/memory_hotplug.h @@ -66,6 +66,7 @@ static inline void arch_refresh_nodedata(int nid, pg_data_t *pgdat)
#ifdef CONFIG_MEMORY_HOTPLUG struct page *pfn_to_online_page(unsigned long pfn); +extern struct acpi_device *hotplug_mdev[MAX_NUMNODES];
/* Types for control the zone type of onlined and offlined memory */ enum {