On 2023/12/14 15:46, Zhang Zekun wrote:
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 | 30 ++++++++++++++++++++++++++++++ include/linux/memory_hotplug.h | 4 ++++ 2 files changed, 34 insertions(+)
diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c index d0c1a71007d0..86b2da43fdc4 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,24 @@ 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;
+}
通过新加stub函数来处理;
+#endif
- static int acpi_memory_enable_device(struct acpi_memory_device *mem_device) { acpi_handle handle = mem_device->device->handle;
@@ -235,6 +258,10 @@ 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. */
+#if IS_ENABLED(CONFIG_HISI_HBMDEV)
hotplug_mdev_set(mem_device);
+#endif num_enabled++; } if (!num_enabled) { @@ -256,6 +283,9 @@ static void acpi_memory_remove_memory(struct acpi_memory_device *mem_device) { struct acpi_memory_info *info, *n;
+#if IS_ENABLED(CONFIG_HISI_HBMDEV)
- hotplug_mdev_clear(mem_device);
+#endif 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. */