[PATCH OLK-6.6 00/17] hisilicon: HBM dev/cache fixes and sysfs cleanup
This series fixes several issues in the HiSilicon HBM device/cache drivers and cleans up the hisi_hbmdev sysfs interface. Highlights: - Serialize the ACPI device online/offline path to avoid races. - Protect the PCC operation region with locks in hbmdev/hbmcache. - Prevent hung task via mutex_trylock in hbmcache. - Don't poweroff when memory blocks failed to offline; fix NULL pointer dereference on the offline path. - Add missing locality information for hot-added ACPI/HMAT devices. - Revert the extra memory-topology and ACLS repair/query features and drop the now-unused memdev kobj / state-show sysfs. Bugzilla: https://atomgit.com/src-openeuler/kernel/issues/20607 Dengdui Huang (1): arm64: openeuler_defconfig: add Kunpeng HCCS config Zhang Zekun (13): soc:hisilicon: Use _ON and _OFF in hbmcache hisilicon/hisi_hbmcache: Add a lock to protect pcc operation region hisilicon/hisi_hbmdev: Add lock to protect pcc operation region ACPI/HMAT: Add missing locality information for hot-added device hisilicon/hisi_hbmcache: Use mutex_trylock to prevent hung task soc: hisilicon: Don't poweroff if memblocks don't offlined soc: hisilicon: hisi_hbmdev: Notify the device in the ACPI soc: hisilicon: Setting the demand_offline in sysfs interface hisilicon/hisi_hbmdev: prevent NULL pointer dereference when corrently arm64: config: Open the hbmdev related config soc: hisilicon: hbmdev: Only support built-in soc/hisilicon: Clean the hbmcache state show sysfs soc/hisilicon: Remove the memdev kobj Ziming Du (3): soc: hisilicon: Serialize the online and onfline the acpi devices Revert "soc: hisilicon: hisi_hbmdev: Add hbm acls repair and query methods" Revert "soc: hisilicon: hisi_hbmdev: Provide extra memory topology information" arch/arm64/configs/openeuler_defconfig | 8 + drivers/acpi/acpi_memhotplug.c | 13 + drivers/acpi/device_sysfs.c | 8 + drivers/acpi/internal.h | 1 + drivers/acpi/numa/hmat.c | 17 ++ drivers/acpi/osl.c | 6 +- drivers/soc/hisilicon/Kconfig | 21 +- drivers/soc/hisilicon/hisi_hbmcache.c | 42 ++- drivers/soc/hisilicon/hisi_hbmdev.c | 346 ++++++------------------- include/linux/acpi.h | 2 + 10 files changed, 160 insertions(+), 304 deletions(-) -- 2.43.0
From: Zhang Zekun <zhangzekun11@huawei.com> hulk inclusion category: feature bugzilla: https://atomgit.com/src-openeuler/kernel/issues/20607 -------------------------------------- Switch PS* ACPI interfaces to _ON and _OFF which can simplify the code logic a lot. Signed-off-by: Zhang Zekun <zhangzekun11@huawei.com> Signed-off-by: Ziming Du <duziming2@huawei.com> --- drivers/soc/hisilicon/hisi_hbmcache.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/soc/hisilicon/hisi_hbmcache.c b/drivers/soc/hisilicon/hisi_hbmcache.c index 34121320742ea..1df7587d2b437 100644 --- a/drivers/soc/hisilicon/hisi_hbmcache.c +++ b/drivers/soc/hisilicon/hisi_hbmcache.c @@ -20,21 +20,22 @@ static ssize_t state_store(struct device *d, struct device_attribute *attr, { struct acpi_device *adev = ACPI_COMPANION(d); const int type = online_type_from_str(buf); - int ret = -EINVAL; + acpi_handle handle = adev->handle; + acpi_status status = AE_OK; switch (type) { case STATE_ONLINE: - ret = acpi_device_set_power(adev, ACPI_STATE_D0); + status = acpi_evaluate_object(handle, "_ON", NULL, NULL); break; case STATE_OFFLINE: - ret = acpi_device_set_power(adev, ACPI_STATE_D3); + status = acpi_evaluate_object(handle, "_OFF", NULL, NULL); break; default: break; } - if (ret) - return ret; + if (ACPI_FAILURE(status)) + return -ENODEV; return count; } @@ -108,8 +109,8 @@ static int cache_remove(struct platform_device *pdev) } static const struct acpi_device_id cache_acpi_ids[] = { - {"HISI04A1"}, - {}, + {"HISI04A1", 0}, + {"", 0}, }; static struct platform_driver hbm_cache_driver = { -- 2.43.0
From: Zhang Zekun <zhangzekun11@huawei.com> hulk inclusion category: bugfix bugzilla: https://atomgit.com/src-openeuler/kernel/issues/20607 -------------------------------------------------- Add a lock to protect against the concurrently operating on PCC operation region in hisi_hbmcache. Fixes: 24856a362e65 ("soc: hbmcache: Add support for online and offline the hbm cache") Signed-off-by: Zhang Zekun <zhangzekun11@huawei.com> Signed-off-by: Ziming Du <duziming2@huawei.com> --- drivers/soc/hisilicon/hisi_hbmcache.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/soc/hisilicon/hisi_hbmcache.c b/drivers/soc/hisilicon/hisi_hbmcache.c index 1df7587d2b437..04504ca7ee0af 100644 --- a/drivers/soc/hisilicon/hisi_hbmcache.c +++ b/drivers/soc/hisilicon/hisi_hbmcache.c @@ -14,6 +14,7 @@ #define MODULE_NAME "hbm_cache" static struct kobject *cache_kobj; +static struct mutex cache_lock; static ssize_t state_store(struct device *d, struct device_attribute *attr, const char *buf, size_t count) @@ -23,6 +24,7 @@ static ssize_t state_store(struct device *d, struct device_attribute *attr, acpi_handle handle = adev->handle; acpi_status status = AE_OK; + mutex_lock(&cache_lock); switch (type) { case STATE_ONLINE: status = acpi_evaluate_object(handle, "_ON", NULL, NULL); @@ -33,6 +35,7 @@ static ssize_t state_store(struct device *d, struct device_attribute *attr, default: break; } + mutex_unlock(&cache_lock); if (ACPI_FAILURE(status)) return -ENODEV; @@ -130,6 +133,8 @@ static int __init hbm_cache_module_init(void) if (!cache_kobj) return -ENOMEM; + mutex_init(&cache_lock); + ret = platform_driver_register(&hbm_cache_driver); if (ret) { kobject_put(cache_kobj); -- 2.43.0
From: Zhang Zekun <zhangzekun11@huawei.com> hulk inclusion category: bugfix bugzilla: https://atomgit.com/src-openeuler/kernel/issues/20607 -------------------------------------------------- Add a lock to protect against the concurrency of PCC operation region. Fixes: 039ec3f73992 ("soc: hisilicon: hisi_hbmdev: Add power domain control methods") Signed-off-by: Zhang Zekun <zhangzekun11@huawei.com> Signed-off-by: Ziming Du <duziming2@huawei.com> --- drivers/soc/hisilicon/hisi_hbmdev.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/soc/hisilicon/hisi_hbmdev.c b/drivers/soc/hisilicon/hisi_hbmdev.c index e60fe1c14c0ff..a7bb386c685d1 100644 --- a/drivers/soc/hisilicon/hisi_hbmdev.c +++ b/drivers/soc/hisilicon/hisi_hbmdev.c @@ -255,7 +255,9 @@ static int memdev_power_on(struct acpi_device *adev) acpi_handle handle = adev->handle; acpi_status status; + acpi_scan_lock_acquire(); status = acpi_evaluate_object(handle, "_ON", NULL, NULL); + acpi_scan_lock_release(); if (ACPI_FAILURE(status)) { acpi_handle_warn(handle, "Power on failed (0x%x)\n", status); return -ENODEV; -- 2.43.0
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
From: Zhang Zekun <zhangzekun11@huawei.com> hulk inclusion category: bugfix bugzilla: https://atomgit.com/src-openeuler/kernel/issues/20607 -------------------------------------------------- Use mutex_trylock() to prevent hung task when concurrent power on/off is triggered. Fixes: 8d7c8662bce2 ("hisilicon/hisi_hbmcache: Add a lock to protect pcc operation region") Signed-off-by: Zhang Zekun <zhangzekun11@huawei.com> Signed-off-by: Ziming Du <duziming2@huawei.com> --- drivers/soc/hisilicon/hisi_hbmcache.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/soc/hisilicon/hisi_hbmcache.c b/drivers/soc/hisilicon/hisi_hbmcache.c index 04504ca7ee0af..2e62f914ae028 100644 --- a/drivers/soc/hisilicon/hisi_hbmcache.c +++ b/drivers/soc/hisilicon/hisi_hbmcache.c @@ -24,7 +24,9 @@ static ssize_t state_store(struct device *d, struct device_attribute *attr, acpi_handle handle = adev->handle; acpi_status status = AE_OK; - mutex_lock(&cache_lock); + if (!mutex_trylock(&cache_lock)) + return -EBUSY; + switch (type) { case STATE_ONLINE: status = acpi_evaluate_object(handle, "_ON", NULL, NULL); -- 2.43.0
From: Zhang Zekun <zhangzekun11@huawei.com> hulk inclusion category: bugfix bugzilla: https://atomgit.com/src-openeuler/kernel/issues/20607 ------------------------------------ We can not determine which physical_node can be offlined. There could be pages pinned by user space. when we try to offline a memblock on which has already pinned pages, we will fall into a loop to migrate these pinned pages. Fixes: 039ec3f73992 ("soc: hisilicon: hisi_hbmdev: Add power domain control methods") Signed-off-by: Zhang Zekun <zhangzekun11@huawei.com> Signed-off-by: Ziming Du <duziming2@huawei.com> --- drivers/soc/hisilicon/hisi_hbmdev.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/soc/hisilicon/hisi_hbmdev.c b/drivers/soc/hisilicon/hisi_hbmdev.c index a7bb386c685d1..d42a6451240fc 100644 --- a/drivers/soc/hisilicon/hisi_hbmdev.c +++ b/drivers/soc/hisilicon/hisi_hbmdev.c @@ -317,14 +317,16 @@ static ssize_t state_store(struct device *dev, struct device_attribute *attr, } static DEVICE_ATTR_WO(state); -static int hbmdev_find(struct acpi_device *adev, void *arg) +static int hbmdev_setup(struct acpi_device *adev, void *arg) { const char *hid = acpi_device_hid(adev); bool *found = arg; if (!strcmp(hid, ACPI_MEMORY_DEVICE_HID)) { + acpi_scan_lock_acquire(); + adev->handler->hotplug.demand_offline = true; + acpi_scan_lock_release(); *found = true; - return -1; } return 0; @@ -339,7 +341,7 @@ static bool has_hbmdev(struct device *dev) if (strcmp(hid, ACPI_GENERIC_CONTAINER_DEVICE_HID)) return found; - acpi_dev_for_each_child(adev, hbmdev_find, &found); + acpi_dev_for_each_child(adev, hbmdev_setup, &found); return found; } -- 2.43.0
From: Zhang Zekun <zhangzekun11@huawei.com> hulk inclusion category: feature bugzilla: https://atomgit.com/src-openeuler/kernel/issues/20607 ---------------------------------- Move the hbm power off logic to ACPI. The hotplugable devices can be ejected by receiving Notify 0x3, so there is no need to call acpi_hotplug_schedule in driver. Signed-off-by: Zhang Zekun <zhangzekun11@huawei.com> Signed-off-by: Ziming Du <duziming2@huawei.com> --- drivers/acpi/osl.c | 1 - drivers/soc/hisilicon/hisi_hbmdev.c | 26 ++++++-------------------- 2 files changed, 6 insertions(+), 21 deletions(-) diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index ff72f545885bf..28527d246fc36 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c @@ -1190,7 +1190,6 @@ acpi_status acpi_hotplug_schedule(struct acpi_device *adev, u32 src) } return AE_OK; } -EXPORT_SYMBOL_GPL(acpi_hotplug_schedule); bool acpi_queue_hotplug_work(struct work_struct *work) { diff --git a/drivers/soc/hisilicon/hisi_hbmdev.c b/drivers/soc/hisilicon/hisi_hbmdev.c index d42a6451240fc..70046bb57a0e5 100644 --- a/drivers/soc/hisilicon/hisi_hbmdev.c +++ b/drivers/soc/hisilicon/hisi_hbmdev.c @@ -266,30 +266,16 @@ static int memdev_power_on(struct acpi_device *adev) return 0; } -static int eject_device(struct acpi_device *acpi_device, void *not_used) +static int memdev_power_off(struct acpi_device *adev) { - acpi_object_type unused; + acpi_handle handle = adev->handle; acpi_status status; - status = acpi_get_type(acpi_device->handle, &unused); - if (ACPI_FAILURE(status) || !acpi_device->flags.ejectable) + status = acpi_evaluate_object(handle, "_OFF", NULL, NULL); + if (ACPI_FAILURE(status)) { return -ENODEV; - - get_device(&acpi_device->dev); - status = acpi_hotplug_schedule(acpi_device, ACPI_OST_EC_OSPM_EJECT); - if (ACPI_SUCCESS(status)) - return 0; - - put_device(&acpi_device->dev); - acpi_evaluate_ost(acpi_device->handle, ACPI_OST_EC_OSPM_EJECT, - ACPI_OST_SC_NON_SPECIFIC_FAILURE, NULL); - - return status == AE_NO_MEMORY ? -ENOMEM : -EAGAIN; -} - -static int memdev_power_off(struct acpi_device *adev) -{ - return acpi_dev_for_each_child(adev, eject_device, NULL); + } + return 0; } static ssize_t state_store(struct device *dev, struct device_attribute *attr, -- 2.43.0
From: Zhang Zekun <zhangzekun11@huawei.com> hulk inclusion category: bugfix bugzilla: https://atomgit.com/src-openeuler/kernel/issues/20607 ------------------------------ Move the setting of demand_offline in sysfs interface, because there could be devices have not been attached to acpi_bus, If we set it in the probe phase, we might missing some pnp devices which is attached later. Fixes: 6f2b4e587ed4 ("soc: hisilicon: Don't poweroff if memblocks don't offlined") Signed-off-by: Zhang Zekun <zhangzekun11@huawei.com> Signed-off-by: Ziming Du <duziming2@huawei.com> --- drivers/soc/hisilicon/hisi_hbmdev.c | 43 +++++++++++++++++------------ 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/drivers/soc/hisilicon/hisi_hbmdev.c b/drivers/soc/hisilicon/hisi_hbmdev.c index 70046bb57a0e5..2acd001f53b16 100644 --- a/drivers/soc/hisilicon/hisi_hbmdev.c +++ b/drivers/soc/hisilicon/hisi_hbmdev.c @@ -266,11 +266,36 @@ static int memdev_power_on(struct acpi_device *adev) return 0; } +static int hbmdev_check(struct acpi_device *adev, void *arg) +{ + const char *hid = acpi_device_hid(adev); + + if (!strcmp(hid, ACPI_MEMORY_DEVICE_HID)) { + if (arg) { + bool *found = arg; + *found = true; + return -1; + } + + /* There might be devices have not attached */ + if (!adev->handler) + return 0; + + acpi_scan_lock_acquire(); + adev->handler->hotplug.demand_offline = true; + acpi_scan_lock_release(); + } + + return 0; +} + static int memdev_power_off(struct acpi_device *adev) { acpi_handle handle = adev->handle; acpi_status status; + acpi_dev_for_each_child(adev, hbmdev_check, NULL); + status = acpi_evaluate_object(handle, "_OFF", NULL, NULL); if (ACPI_FAILURE(status)) { return -ENODEV; @@ -303,21 +328,6 @@ static ssize_t state_store(struct device *dev, struct device_attribute *attr, } static DEVICE_ATTR_WO(state); -static int hbmdev_setup(struct acpi_device *adev, void *arg) -{ - const char *hid = acpi_device_hid(adev); - bool *found = arg; - - if (!strcmp(hid, ACPI_MEMORY_DEVICE_HID)) { - acpi_scan_lock_acquire(); - adev->handler->hotplug.demand_offline = true; - acpi_scan_lock_release(); - *found = true; - } - - return 0; -} - static bool has_hbmdev(struct device *dev) { struct acpi_device *adev = ACPI_COMPANION(dev); @@ -327,8 +337,7 @@ static bool has_hbmdev(struct device *dev) if (strcmp(hid, ACPI_GENERIC_CONTAINER_DEVICE_HID)) return found; - acpi_dev_for_each_child(adev, hbmdev_setup, &found); - + acpi_dev_for_each_child(adev, hbmdev_check, &found); return found; } -- 2.43.0
From: Zhang Zekun <zhangzekun11@huawei.com> hulk inclusion category: bugfix bugzilla: https://atomgit.com/src-openeuler/kernel/issues/20607 ------------------------------------------------ There could have race problem when concurrently online or offline the device. "adev->handler" could be set to NULL when calling hbmdev_check. Let's add lock to prevent the NULL pointer dereference. Fixes: f37b8c99659d ("soc: hisilicon: Setting the demand_offline in sysfs interface") Signed-off-by: Zhang Zekun <zhangzekun11@huawei.com> Signed-off-by: Ziming Du <duziming2@huawei.com> --- drivers/soc/hisilicon/hisi_hbmdev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/soc/hisilicon/hisi_hbmdev.c b/drivers/soc/hisilicon/hisi_hbmdev.c index 2acd001f53b16..5c5f7c0a02410 100644 --- a/drivers/soc/hisilicon/hisi_hbmdev.c +++ b/drivers/soc/hisilicon/hisi_hbmdev.c @@ -281,9 +281,7 @@ static int hbmdev_check(struct acpi_device *adev, void *arg) if (!adev->handler) return 0; - acpi_scan_lock_acquire(); adev->handler->hotplug.demand_offline = true; - acpi_scan_lock_release(); } return 0; @@ -294,7 +292,9 @@ static int memdev_power_off(struct acpi_device *adev) acpi_handle handle = adev->handle; acpi_status status; + acpi_scan_lock_acquire(); acpi_dev_for_each_child(adev, hbmdev_check, NULL); + acpi_scan_lock_release(); status = acpi_evaluate_object(handle, "_OFF", NULL, NULL); if (ACPI_FAILURE(status)) { -- 2.43.0
From: Dengdui Huang <huangdengdui@huawei.com> openEuler inclusion category: feature bugzilla: https://atomgit.com/src-openeuler/kernel/issues/20607 CVE: NA -------------------------------- add Kunpeng HCCS config. Signed-off-by: Dengdui Huang <huangdengdui@huawei.com> Signed-off-by: Ziming Du <duziming2@huawei.com> --- arch/arm64/configs/openeuler_defconfig | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/arm64/configs/openeuler_defconfig b/arch/arm64/configs/openeuler_defconfig index edf2ed90efb80..d53048a0048c4 100644 --- a/arch/arm64/configs/openeuler_defconfig +++ b/arch/arm64/configs/openeuler_defconfig @@ -6840,6 +6840,14 @@ CONFIG_QCOM_KRYO_L2_ACCESSORS=y # Xilinx SoC drivers # # end of Xilinx SoC drivers + +# +# Hisilicon SoC drivers +# +CONFIG_KUNPENG_HCCS=m +# CONFIG_HISI_HBMDEV is not set +# CONFIG_HISI_HBMCACHE is not set +# end of Hisilicon SoC drivers # end of SOC (System On Chip) specific Drivers CONFIG_PM_DEVFREQ=y -- 2.43.0
From: Zhang Zekun <zhangzekun11@huawei.com> hulk inclusion category: category bugzilla: https://atomgit.com/src-openeuler/kernel/issues/20607 -------------------------------------------- Open the hbmdev related config, add support for kunpeng hbm related drivers. Signed-off-by: Zhang Zekun <zhangzekun11@huawei.com> Signed-off-by: Ziming Du <duziming2@huawei.com> --- arch/arm64/configs/openeuler_defconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm64/configs/openeuler_defconfig b/arch/arm64/configs/openeuler_defconfig index d53048a0048c4..d7a0daa041257 100644 --- a/arch/arm64/configs/openeuler_defconfig +++ b/arch/arm64/configs/openeuler_defconfig @@ -6845,8 +6845,8 @@ CONFIG_QCOM_KRYO_L2_ACCESSORS=y # Hisilicon SoC drivers # CONFIG_KUNPENG_HCCS=m -# CONFIG_HISI_HBMDEV is not set -# CONFIG_HISI_HBMCACHE is not set +CONFIG_HISI_HBMDEV=m +CONFIG_HISI_HBMCACHE=m # end of Hisilicon SoC drivers # end of SOC (System On Chip) specific Drivers -- 2.43.0
From: Zhang Zekun <zhangzekun11@huawei.com> hulk inclusion category: feature bugzilla: https://atomgit.com/src-openeuler/kernel/issues/20607 ----------------------------------------------------------- Only support built in compile for hisi_hbmdev. We need to use lock_device_hotplug_sysfs() to prevent directly racing on acpi_scan_lock(), hbm memory can be time consumed during power on. Signed-off-by: Zhang Zekun <zhangzekun11@huawei.com> Signed-off-by: Ziming Du <duziming2@huawei.com> --- arch/arm64/configs/openeuler_defconfig | 2 +- drivers/soc/hisilicon/Kconfig | 2 +- drivers/soc/hisilicon/hisi_hbmdev.c | 18 +++++++++++++++--- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/arch/arm64/configs/openeuler_defconfig b/arch/arm64/configs/openeuler_defconfig index d7a0daa041257..df37ee5c07853 100644 --- a/arch/arm64/configs/openeuler_defconfig +++ b/arch/arm64/configs/openeuler_defconfig @@ -6845,7 +6845,7 @@ CONFIG_QCOM_KRYO_L2_ACCESSORS=y # Hisilicon SoC drivers # CONFIG_KUNPENG_HCCS=m -CONFIG_HISI_HBMDEV=m +CONFIG_HISI_HBMDEV=y CONFIG_HISI_HBMCACHE=m # end of Hisilicon SoC drivers # end of SOC (System On Chip) specific Drivers diff --git a/drivers/soc/hisilicon/Kconfig b/drivers/soc/hisilicon/Kconfig index 4d501a4c4c5b0..98f0e7d118dab 100644 --- a/drivers/soc/hisilicon/Kconfig +++ b/drivers/soc/hisilicon/Kconfig @@ -4,7 +4,7 @@ menu "Hisilicon SoC drivers" depends on ARCH_HISI || COMPILE_TEST config HISI_HBMDEV - tristate "add extra support for hbm memory device" + bool "add extra support for hbm memory device" depends on ACPI_HOTPLUG_MEMORY && ARCH_HISI select ACPI_CONTAINER help diff --git a/drivers/soc/hisilicon/hisi_hbmdev.c b/drivers/soc/hisilicon/hisi_hbmdev.c index 5c5f7c0a02410..778a9cc1450a8 100644 --- a/drivers/soc/hisilicon/hisi_hbmdev.c +++ b/drivers/soc/hisilicon/hisi_hbmdev.c @@ -255,9 +255,8 @@ static int memdev_power_on(struct acpi_device *adev) acpi_handle handle = adev->handle; acpi_status status; - acpi_scan_lock_acquire(); + /* Power on and online the devices */ status = acpi_evaluate_object(handle, "_ON", NULL, NULL); - acpi_scan_lock_release(); if (ACPI_FAILURE(status)) { acpi_handle_warn(handle, "Power on failed (0x%x)\n", status); return -ENODEV; @@ -296,6 +295,7 @@ static int memdev_power_off(struct acpi_device *adev) acpi_dev_for_each_child(adev, hbmdev_check, NULL); acpi_scan_lock_release(); + /* Eject the devices and power off */ status = acpi_evaluate_object(handle, "_OFF", NULL, NULL); if (ACPI_FAILURE(status)) { return -ENODEV; @@ -308,7 +308,12 @@ static ssize_t state_store(struct device *dev, struct device_attribute *attr, { struct acpi_device *adev = ACPI_COMPANION(dev); const int type = online_type_from_str(buf); - int ret = -EINVAL; + int ret; + + /* Disallow pending on the mutex to avoid potential hung task*/ + ret = lock_device_hotplug_sysfs(); + if (ret) + return ret; switch (type) { case STATE_ONLINE: @@ -320,6 +325,7 @@ static ssize_t state_store(struct device *dev, struct device_attribute *attr, default: break; } + unlock_device_hotplug(); if (ret) return ret; @@ -392,10 +398,16 @@ static int container_init(void) return 0; } +static struct acpi_platform_list hbm_plat_info[] = { + {"HISI ", "HIP11 ", 0, ACPI_SIG_IORT, all_versions, NULL, 0}, + { } +}; static int __init mdev_init(void) { int ret; + if (acpi_match_platform_list(hbm_plat_info) < 0) + return 0; mdev = kzalloc(sizeof(struct memory_dev), GFP_KERNEL); if (!mdev) -- 2.43.0
hulk inclusion category: bugfix bugzilla: https://atomgit.com/src-openeuler/kernel/issues/20607 ----------------------------------------------- The parallelization of hbm on and off can cause problems, such as the abnormal state of acpi device. Force paralleize the routine of power on/off the hbm device, which can fix various the abnormal state of acpi devices. Fixes: 039ec3f73992 ("soc: hisilicon: hisi_hbmdev: Add power domain control methods") Signed-off-by: Zhang Zekun <zhangzekun11@huawei.com> Conflicts: drivers/soc/hisilicon/hisi_hbmdev.c [context conflict: e6bdbcc764af822ff7172a4a78d437dc433a0c74] Signed-off-by: Ziming Du <duziming2@huawei.com> --- drivers/acpi/device_sysfs.c | 8 +++ drivers/acpi/osl.c | 5 ++ drivers/soc/hisilicon/hisi_hbmdev.c | 90 ++++++++++++++++++++--------- include/linux/acpi.h | 2 + 4 files changed, 77 insertions(+), 28 deletions(-) diff --git a/drivers/acpi/device_sysfs.c b/drivers/acpi/device_sysfs.c index eae6016ad2825..40db928064e62 100644 --- a/drivers/acpi/device_sysfs.c +++ b/drivers/acpi/device_sysfs.c @@ -366,6 +366,11 @@ static ssize_t power_state_show(struct device *dev, static DEVICE_ATTR_RO(power_state); +static struct acpi_platform_list no_eject_plat_info[] = { + {"HISI ", "HIP11 ", 0, ACPI_SIG_IORT, all_versions, NULL, 0}, + { } +}; + static ssize_t eject_store(struct device *d, struct device_attribute *attr, const char *buf, size_t count) @@ -385,6 +390,9 @@ eject_store(struct device *d, struct device_attribute *attr, if (ACPI_FAILURE(status) || !acpi_device->flags.ejectable) return -ENODEV; + if (acpi_match_platform_list(no_eject_plat_info) >= 0) + return -ENODEV; + acpi_dev_get(acpi_device); status = acpi_hotplug_schedule(acpi_device, ACPI_OST_EC_OSPM_EJECT); if (ACPI_SUCCESS(status)) diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index 28527d246fc36..851af01a00cc3 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c @@ -1196,6 +1196,11 @@ bool acpi_queue_hotplug_work(struct work_struct *work) return queue_work(kacpi_hotplug_wq, work); } +void flush_hotplug_workqueue(void) +{ + flush_workqueue(kacpi_hotplug_wq); +} + acpi_status acpi_os_create_semaphore(u32 max_units, u32 initial_units, acpi_handle * handle) { diff --git a/drivers/soc/hisilicon/hisi_hbmdev.c b/drivers/soc/hisilicon/hisi_hbmdev.c index 778a9cc1450a8..73f691902466f 100644 --- a/drivers/soc/hisilicon/hisi_hbmdev.c +++ b/drivers/soc/hisilicon/hisi_hbmdev.c @@ -33,6 +33,7 @@ struct memory_dev { nodemask_t cluster_cpumask[MAX_NUMNODES]; }; +static struct mutex dev_lock; static struct memory_dev *mdev; static ssize_t memory_locality_show(struct kobject *kobj, @@ -250,21 +251,6 @@ static ssize_t pxms_show(struct device *dev, } static DEVICE_ATTR_RO(pxms); -static int memdev_power_on(struct acpi_device *adev) -{ - acpi_handle handle = adev->handle; - acpi_status status; - - /* Power on and online the devices */ - status = acpi_evaluate_object(handle, "_ON", NULL, NULL); - if (ACPI_FAILURE(status)) { - acpi_handle_warn(handle, "Power on failed (0x%x)\n", status); - return -ENODEV; - } - - return 0; -} - static int hbmdev_check(struct acpi_device *adev, void *arg) { const char *hid = acpi_device_hid(adev); @@ -275,34 +261,71 @@ static int hbmdev_check(struct acpi_device *adev, void *arg) *found = true; return -1; } + } - /* There might be devices have not attached */ - if (!adev->handler) - return 0; + return 0; +} - adev->handler->hotplug.demand_offline = true; - } +static int check_memdev_status(struct acpi_device *child, void *data) +{ + unsigned long long sta = 0; + acpi_status status; + + status = acpi_evaluate_integer(child->handle, "_STA", NULL, &sta); + if (ACPI_FAILURE(status) || (sta & ACPI_STA_DEVICE_ENABLED)) + return -EINVAL; return 0; } -static int memdev_power_off(struct acpi_device *adev) +static int memdev_power_on(struct acpi_device *adev) { acpi_handle handle = adev->handle; acpi_status status; + int ret; - acpi_scan_lock_acquire(); - acpi_dev_for_each_child(adev, hbmdev_check, NULL); - acpi_scan_lock_release(); + ret = acpi_dev_for_each_child(adev, check_memdev_status, NULL); + if (ret) + return ret; - /* Eject the devices and power off */ - status = acpi_evaluate_object(handle, "_OFF", NULL, NULL); + /* Power on and online the devices */ + status = acpi_evaluate_object(handle, "_ON", NULL, NULL); if (ACPI_FAILURE(status)) { + acpi_handle_warn(handle, "Power on failed (0x%x)\n", status); return -ENODEV; } + return 0; } +static int schedule_memdev_offline(struct acpi_device *child, void *data) +{ + const char *hid = acpi_device_hid(child); + acpi_status status; + + if (strcmp(hid, ACPI_MEMORY_DEVICE_HID)) + return 0; + + if (!child->handler) + return 0; + + child->handler->hotplug.demand_offline = true; + + get_device(&child->dev); + status = acpi_hotplug_schedule(child, ACPI_OST_EC_OSPM_EJECT); + if (ACPI_SUCCESS(status)) + return 0; + + put_device(&child->dev); + + return 0; +} + +static void memdev_power_off(struct acpi_device *adev) +{ + acpi_dev_for_each_child(adev, schedule_memdev_offline, NULL); +} + static ssize_t state_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { @@ -310,23 +333,33 @@ static ssize_t state_store(struct device *dev, struct device_attribute *attr, const int type = online_type_from_str(buf); int ret; + if (!mutex_trylock(&dev_lock)) + return -EBUSY; + /* Disallow pending on the mutex to avoid potential hung task*/ ret = lock_device_hotplug_sysfs(); - if (ret) + if (ret) { + mutex_unlock(&dev_lock); return ret; + } switch (type) { case STATE_ONLINE: ret = memdev_power_on(adev); break; case STATE_OFFLINE: - ret = memdev_power_off(adev); + memdev_power_off(adev); break; default: break; } + unlock_device_hotplug(); + acpi_os_wait_events_complete(); + flush_hotplug_workqueue(); + + mutex_unlock(&dev_lock); if (ret) return ret; @@ -412,6 +445,7 @@ static int __init mdev_init(void) mdev = kzalloc(sizeof(struct memory_dev), GFP_KERNEL); if (!mdev) return -ENOMEM; + mutex_init(&dev_lock); ret = container_init(); if (ret) { diff --git a/include/linux/acpi.h b/include/linux/acpi.h index acd1a9241829c..eb12ffc5e3cf8 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -1578,10 +1578,12 @@ static inline void acpi_init_ffh(void) { } #ifdef CONFIG_ACPI extern void acpi_device_notify(struct device *dev); extern void acpi_device_notify_remove(struct device *dev); +extern void flush_hotplug_workqueue(void); extern acpi_status acpi_hotplug_schedule(struct acpi_device *adev, u32 src); #else static inline void acpi_device_notify(struct device *dev) { } static inline void acpi_device_notify_remove(struct device *dev) { } +static inline void flush_hotplug_workqueue(void) {} #endif #ifdef CONFIG_ACPI_APEI_MEMORY_FAILURE int register_apei_page_offline_notifier(struct notifier_block *nb); -- 2.43.0
hulk inclusion category: feature bugzilla: https://atomgit.com/src-openeuler/kernel/issues/20607 ----------------------------------------- This reverts commit 72974c6c8455fe8245e3b215102e7c3a068d8e55. Signed-off-by: Zhang Zekun <zhangzekun11@huawei.com> Signed-off-by: Ziming Du <duziming2@huawei.com> --- drivers/soc/hisilicon/Kconfig | 10 --- drivers/soc/hisilicon/hisi_hbmdev.c | 134 ---------------------------- 2 files changed, 144 deletions(-) diff --git a/drivers/soc/hisilicon/Kconfig b/drivers/soc/hisilicon/Kconfig index 98f0e7d118dab..c4a341156580e 100644 --- a/drivers/soc/hisilicon/Kconfig +++ b/drivers/soc/hisilicon/Kconfig @@ -29,16 +29,6 @@ config HISI_HBMCACHE To compile the driver as a module, choose M here: the module will be called hisi_hbmcache. -config HISI_HBMDEV_ACLS - bool "Add support for HISI ACLS repair" - depends on HISI_HBMDEV - help - Add ACLS support for hbm device, which can be used to query and - repair hardware error in HBM devices. This feature need to work with - hardware firmwares. - - If not sure say no. - config KUNPENG_HCCS tristate "HCCS driver on Kunpeng SoC" depends on ACPI diff --git a/drivers/soc/hisilicon/hisi_hbmdev.c b/drivers/soc/hisilicon/hisi_hbmdev.c index 73f691902466f..f69446c835570 100644 --- a/drivers/soc/hisilicon/hisi_hbmdev.c +++ b/drivers/soc/hisilicon/hisi_hbmdev.c @@ -11,7 +11,6 @@ #include <linux/node.h> #include <linux/arch_topology.h> #include <linux/memory_hotplug.h> -#include <linux/mm.h> #include "hisi_internal.h" @@ -26,9 +25,6 @@ struct cdev_node { struct memory_dev { struct kobject *memdev_kobj; struct kobject *topo_kobj; -#ifdef CONFIG_HISI_HBMDEV_ACLS - struct kobject *acls_kobj; -#endif struct cdev_node cdev_list; nodemask_t cluster_cpumask[MAX_NUMNODES]; }; @@ -90,134 +86,6 @@ static void memory_topo_init(void) kobject_put(mdev->topo_kobj); } -#ifdef CONFIG_HISI_HBMDEV_ACLS -static struct acpi_device *paddr_to_acpi_device(u64 paddr) -{ - unsigned long pfn; - int nid; - - pfn = __phys_to_pfn(paddr); - if (!pfn_valid(pfn)) - return NULL; - - nid = pfn_to_nid(pfn); - if (nid < 0 && nid >= MAX_NUMNODES) - return NULL; - - return hotplug_mdev[nid]; -} - -static ssize_t acls_query_store(struct kobject *kobj, - struct kobj_attribute *attr, - const char *buf, size_t count) -{ - struct acpi_object_list arg_list; - struct acpi_device *adev; - union acpi_object obj; - acpi_status status; - u64 paddr, res; - - if (kstrtoull(buf, 16, &paddr)) - return -EINVAL; - - adev = paddr_to_acpi_device(paddr); - if (!adev) - return -EINVAL; - - obj.type = ACPI_TYPE_INTEGER; - obj.integer.value = paddr; - arg_list.count = 1; - arg_list.pointer = &obj; - - status = acpi_evaluate_integer(adev->handle, "AQRY", &arg_list, &res); - if (ACPI_FAILURE(status)) - return -ENODEV; - - /* AQRY will return a positive error code to represent error status */ - if (IS_ERR_VALUE(-res)) - return -res; - else if (res) - return -ENODEV; - - return count; -} - -static struct kobj_attribute acls_query_store_attribute = - __ATTR(acls_query, 0200, NULL, acls_query_store); - -static ssize_t acls_repair_store(struct kobject *kobj, - struct kobj_attribute *attr, - const char *buf, size_t count) -{ - struct acpi_object_list arg_list; - struct acpi_device *adev; - union acpi_object obj; - acpi_status status; - u64 paddr, res; - - if (kstrtoull(buf, 16, &paddr)) - return -EINVAL; - - adev = paddr_to_acpi_device(paddr); - if (!adev) - return -EINVAL; - - obj.type = ACPI_TYPE_INTEGER; - obj.integer.value = paddr; - arg_list.count = 1; - arg_list.pointer = &obj; - - status = acpi_evaluate_integer(adev->handle, "AREP", &arg_list, &res); - if (ACPI_FAILURE(status)) - return -ENODEV; - - /* AREP will return a positive error code to represent error status */ - if (IS_ERR_VALUE(-res)) - return -res; - else if (res) - return -ENODEV; - - return count; -} -static struct kobj_attribute acls_repair_store_attribute = - __ATTR(acls_repair, 0200, NULL, acls_repair_store); - -static struct attribute *acls_attrs[] = { - &acls_query_store_attribute.attr, - &acls_repair_store_attribute.attr, - NULL, -}; - -static struct attribute_group acls_attr_group = { - .attrs = acls_attrs, -}; - -static void acls_init(void) -{ - int ret = -ENOMEM; - - mdev->acls_kobj = kobject_create_and_add("acls", mdev->memdev_kobj); - if (!mdev->acls_kobj) - goto out; - - ret = sysfs_create_group(mdev->acls_kobj, &acls_attr_group); - if (ret) - kobject_put(mdev->acls_kobj); - -out: - if (ret) - pr_err("ACLS hot repair is not enabled\n"); -} - -static void acls_remove(void) -{ - kobject_put(mdev->acls_kobj); -} -#else -static void acls_init(void) {} -static void acls_remove(void) {} -#endif - static int get_pxm(struct acpi_device *acpi_device, void *arg) { acpi_handle handle = acpi_device->handle; @@ -461,7 +329,6 @@ static int __init mdev_init(void) } memory_topo_init(); - acls_init(); return ret; } module_init(mdev_init); @@ -471,7 +338,6 @@ static void __exit mdev_exit(void) container_remove(); kobject_put(mdev->memdev_kobj); kobject_put(mdev->topo_kobj); - acls_remove(); kfree(mdev); } module_exit(mdev_exit); -- 2.43.0
hulk inclusion category: feature bugzilla: https://atomgit.com/src-openeuler/kernel/issues/20607 ----------------------------------------- This reverts commit 7df29c8edb8e88557eeddd44310b35cad7cd8e5d. Signed-off-by: Zhang Zekun <zhangzekun11@huawei.com> Signed-off-by: Ziming Du <duziming2@huawei.com> --- drivers/soc/hisilicon/Kconfig | 9 ++--- drivers/soc/hisilicon/hisi_hbmdev.c | 61 ----------------------------- 2 files changed, 3 insertions(+), 67 deletions(-) diff --git a/drivers/soc/hisilicon/Kconfig b/drivers/soc/hisilicon/Kconfig index c4a341156580e..93be217a50dae 100644 --- a/drivers/soc/hisilicon/Kconfig +++ b/drivers/soc/hisilicon/Kconfig @@ -8,12 +8,9 @@ config HISI_HBMDEV depends on ACPI_HOTPLUG_MEMORY && ARCH_HISI select ACPI_CONTAINER help - This driver add two extra supports for memory devices. The driver - provides methods for userpace to control the power of memory devices - in a container. Besides, it provides extra locality information - between cpus and memory devices for userspace, which can take - advantage of this functionality to select the closet memory device - to a certain cpu. + This driver add extra supports for memory devices. The driver + provides methods for userpace to control the power of memory + devices in a container. To compile this driver as a module, choose M here: the module will be called hisi_hbmdev. diff --git a/drivers/soc/hisilicon/hisi_hbmdev.c b/drivers/soc/hisilicon/hisi_hbmdev.c index f69446c835570..2c8e692d20a11 100644 --- a/drivers/soc/hisilicon/hisi_hbmdev.c +++ b/drivers/soc/hisilicon/hisi_hbmdev.c @@ -8,9 +8,6 @@ #include <linux/nodemask.h> #include <linux/acpi.h> #include <linux/container.h> -#include <linux/node.h> -#include <linux/arch_topology.h> -#include <linux/memory_hotplug.h> #include "hisi_internal.h" @@ -24,68 +21,12 @@ struct cdev_node { struct memory_dev { struct kobject *memdev_kobj; - struct kobject *topo_kobj; struct cdev_node cdev_list; - nodemask_t cluster_cpumask[MAX_NUMNODES]; }; static struct mutex dev_lock; static struct memory_dev *mdev; -static ssize_t memory_locality_show(struct kobject *kobj, - struct kobj_attribute *attr, - char *buf) -{ - int i, count = 0; - - for (i = 0; i < MAX_NUMNODES; i++) { - if (hotplug_mdev[i] != NULL && !nodes_empty(mdev->cluster_cpumask[i])) { - count += sysfs_emit_at(buf, count, "%d %*pbl\n", i, - nodemask_pr_args(&mdev->cluster_cpumask[i])); - } - } - - return count; -} - -static struct kobj_attribute memory_locality_attribute = - __ATTR(memory_locality, 0444, memory_locality_show, NULL); - -static void memory_topo_init(void) -{ - int ret, nid, cluster_id, cpu; - struct acpi_device *adev; - nodemask_t mask; - - for (nid = 0; nid < MAX_NUMNODES; nid++) { - if (!hotplug_mdev[nid]) - continue; - - adev = hotplug_mdev[nid]; - ret = fwnode_property_read_u32(acpi_fwnode_handle(adev), - "cluster-id", &cluster_id); - if (ret < 0) { - pr_debug("Failed to read cluster id\n"); - return; - } - - nodes_clear(mask); - for_each_possible_cpu(cpu) { - if (topology_cluster_id(cpu) == cluster_id) - node_set(cpu, mask); - } - mdev->cluster_cpumask[nid] = mask; - } - - mdev->topo_kobj = kobject_create_and_add("memory_topo", mdev->memdev_kobj); - if (!mdev->topo_kobj) - return; - - ret = sysfs_create_file(mdev->topo_kobj, &memory_locality_attribute.attr); - if (ret) - kobject_put(mdev->topo_kobj); -} - static int get_pxm(struct acpi_device *acpi_device, void *arg) { acpi_handle handle = acpi_device->handle; @@ -328,7 +269,6 @@ static int __init mdev_init(void) return -ENOMEM; } - memory_topo_init(); return ret; } module_init(mdev_init); @@ -337,7 +277,6 @@ static void __exit mdev_exit(void) { container_remove(); kobject_put(mdev->memdev_kobj); - kobject_put(mdev->topo_kobj); kfree(mdev); } module_exit(mdev_exit); -- 2.43.0
From: Zhang Zekun <zhangzekun11@huawei.com> hulk inclusion category: feature bugzilla: https://atomgit.com/src-openeuler/kernel/issues/20607 --------------------------------------- There is no need to provide a extra state_show sysfs to query the hbm_cache state, we can use the "status" sysfs interface to query the hbm_cache state. Signed-off-by: Zhang Zekun <zhangzekun11@huawei.com> Signed-off-by: Ziming Du <duziming2@huawei.com> --- drivers/soc/hisilicon/hisi_hbmcache.c | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/drivers/soc/hisilicon/hisi_hbmcache.c b/drivers/soc/hisilicon/hisi_hbmcache.c index 2e62f914ae028..2bebb5a9e2aa2 100644 --- a/drivers/soc/hisilicon/hisi_hbmcache.c +++ b/drivers/soc/hisilicon/hisi_hbmcache.c @@ -44,25 +44,7 @@ static ssize_t state_store(struct device *d, struct device_attribute *attr, return count; } - -static ssize_t state_show(struct device *d, struct device_attribute *attr, - char *buf) -{ - struct acpi_device *adev = ACPI_COMPANION(d); - unsigned long long sta = 0; - acpi_status status; - const char *output; - - status = acpi_evaluate_integer(adev->handle, "_STA", NULL, &sta); - if (ACPI_FAILURE(status)) - return -EINVAL; - - output = (sta & 0x01) ? online_type_to_str[STATE_ONLINE] : - online_type_to_str[STATE_OFFLINE]; - - return sysfs_emit(buf, "%s\n", output); -} -static DEVICE_ATTR_RW(state); +static DEVICE_ATTR_WO(state); static ssize_t socket_id_show(struct device *d, struct device_attribute *attr, char *buf) -- 2.43.0
From: Zhang Zekun <zhangzekun11@huawei.com> hulk inclusion category: feature bugzilla: https://atomgit.com/src-openeuler/kernel/issues/20607 ---------------------------------------- Since we have remove the memory topo and acls feature in hisi_hbmdev we no longer need to create sysfs. So, remove the sysfs interface. Signed-off-by: Zhang Zekun <zhangzekun11@huawei.com> onflicts: drivers/soc/hisilicon/hisi_hbmdev.c [context conflicts] Signed-off-by: Ziming Du <duziming2@Huawei.com> --- drivers/soc/hisilicon/hisi_hbmdev.c | 46 +++++++---------------------- 1 file changed, 11 insertions(+), 35 deletions(-) diff --git a/drivers/soc/hisilicon/hisi_hbmdev.c b/drivers/soc/hisilicon/hisi_hbmdev.c index 2c8e692d20a11..1728a5859721b 100644 --- a/drivers/soc/hisilicon/hisi_hbmdev.c +++ b/drivers/soc/hisilicon/hisi_hbmdev.c @@ -19,13 +19,8 @@ struct cdev_node { struct list_head clist; }; -struct memory_dev { - struct kobject *memdev_kobj; - struct cdev_node cdev_list; -}; - static struct mutex dev_lock; -static struct memory_dev *mdev; +struct cdev_node cdev_list; static int get_pxm(struct acpi_device *acpi_device, void *arg) { @@ -201,7 +196,7 @@ static int container_add(struct device *dev, void *data) return -ENOMEM; cnode->dev = dev; - list_add_tail(&cnode->clist, &mdev->cdev_list.clist); + list_add_tail(&cnode->clist, &cdev_list.clist); return 0; } @@ -210,7 +205,7 @@ static void container_remove(void) { struct cdev_node *cnode, *tmp; - list_for_each_entry_safe(cnode, tmp, &mdev->cdev_list.clist, clist) { + list_for_each_entry_safe(cnode, tmp, &cdev_list.clist, clist) { device_remove_file(cnode->dev, &dev_attr_state); device_remove_file(cnode->dev, &dev_attr_pxms); list_del(&cnode->clist); @@ -222,17 +217,17 @@ static int container_init(void) { struct cdev_node *cnode; - INIT_LIST_HEAD(&mdev->cdev_list.clist); + INIT_LIST_HEAD(&cdev_list.clist); if (bus_for_each_dev(&container_subsys, NULL, NULL, container_add)) { container_remove(); return -ENOMEM; } - if (list_empty(&mdev->cdev_list.clist)) + if (list_empty(&cdev_list.clist)) return -ENODEV; - list_for_each_entry(cnode, &mdev->cdev_list.clist, clist) { + list_for_each_entry(cnode, &cdev_list.clist, clist) { device_create_file(cnode->dev, &dev_attr_state); device_create_file(cnode->dev, &dev_attr_pxms); } @@ -245,41 +240,22 @@ static struct acpi_platform_list hbm_plat_info[] = { { } }; -static int __init mdev_init(void) +static int __init hbmdev_init(void) { - int ret; if (acpi_match_platform_list(hbm_plat_info) < 0) return 0; - mdev = kzalloc(sizeof(struct memory_dev), GFP_KERNEL); - if (!mdev) - return -ENOMEM; mutex_init(&dev_lock); - ret = container_init(); - if (ret) { - kfree(mdev); - return ret; - } - - mdev->memdev_kobj = kobject_create_and_add("hbm_memory", kernel_kobj); - if (!mdev->memdev_kobj) { - container_remove(); - kfree(mdev); - return -ENOMEM; - } - - return ret; + return container_init(); } -module_init(mdev_init); +module_init(hbmdev_init); -static void __exit mdev_exit(void) +static void __exit hbmdev_exit(void) { container_remove(); - kobject_put(mdev->memdev_kobj); - kfree(mdev); } -module_exit(mdev_exit); +module_exit(hbmdev_exit); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Zhang Zekun <zhangzekun11@huawei.com>"); -- 2.43.0
反馈: 您发送到kernel@openeuler.org的补丁/补丁集,已成功转换为PR! PR链接地址: https://atomgit.com/openeuler/kernel/merge_requests/30018 邮件列表地址:https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/AF5... FeedBack: The patch(es) which you have sent to kernel@openeuler.org mailing list has been converted to a pull request successfully! Pull request link: https://atomgit.com/openeuler/kernel/merge_requests/30018 Mailing list address: https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/AF5...
participants (2)
-
patchwork bot -
Ziming Du