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 --- v2->v3: - add stub for hotplug_mdev_clear() and hotplug_mdev_set()
drivers/acpi/acpi_memhotplug.c | 29 +++++++++++++++++++++++++++++ include/linux/memory_hotplug.h | 4 ++++ 2 files changed, 33 insertions(+)
diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c index d0c1a71007d0..456647c6ef81 100644 --- a/drivers/acpi/acpi_memhotplug.c +++ b/drivers/acpi/acpi_memhotplug.c @@ -57,6 +57,11 @@ struct acpi_memory_device { int mgid; };
+#if IS_ENABLED(CONFIG_HISI_HBMDEV) +struct acpi_device *hotplug_mdev[MAX_NUMNODES]; +EXPORT_SYMBOL_GPL(hotplug_mdev); +#endif + static acpi_status acpi_memory_get_resource(struct acpi_resource *resource, void *context) { @@ -167,6 +172,27 @@ static void acpi_unbind_memory_blocks(struct acpi_memory_info *info) acpi_unbind_memblk); }
+#if IS_ENABLED(CONFIG_HISI_HBMDEV) +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; +} +#else +static void hotplug_mdev_set(struct acpi_memory_device *mem_device) {} +static void hotplug_mdev_clear(struct acpi_memory_device *mem_device) {} +#endif + static int acpi_memory_enable_device(struct acpi_memory_device *mem_device) { acpi_handle handle = mem_device->device->handle; @@ -235,6 +261,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 +284,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..a7164c67dcd8 100644 --- a/include/linux/memory_hotplug.h +++ b/include/linux/memory_hotplug.h @@ -67,6 +67,10 @@ 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);
+#if IS_ENABLED(CONFIG_HISI_HBMDEV) +extern struct acpi_device *hotplug_mdev[MAX_NUMNODES]; +#endif + /* Types for control the zone type of onlined and offlined memory */ enum { /* Offline the memory. */