hbmdev and hbmcache new features and new fixs.
v2: - Fix format warning
Zhang Zekun (4): soc:hisilicon: Use _ON and _OFF in hbmcache hisilicon/hisi_hbmcache: Add a lock to prevent conrrency hisilicon/hisi_hbmdev: Add lock to prevent correnctly ACPI/HMAT: Add missing locality information for hot-added device
drivers/acpi/acpi_memhotplug.c | 13 +++++++++++++ drivers/acpi/internal.h | 1 + drivers/acpi/numa/hmat.c | 17 +++++++++++++++++ drivers/soc/hisilicon/hisi_hbmcache.c | 20 +++++++++++++------- drivers/soc/hisilicon/hisi_hbmdev.c | 2 ++ 5 files changed, 46 insertions(+), 7 deletions(-)
hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/IAO4WG
--------------------------------------
Switch PS* ACPI interfaces to _ON and _OFF which can simplify the code logic a lot.
Signed-off-by: Zhang Zekun zhangzekun11@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 c3295a7919d1..dc403aa55b68 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; } @@ -90,8 +91,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 = {
hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/IAO4WG
--------------------------------------------------
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 --- 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 dc403aa55b68..e06f613c143b 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; @@ -112,6 +115,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);
hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/IAO4WG
--------------------------------------------------
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 --- 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 33e5f0d9dde0..4c7da1a0eb33 100644 --- a/drivers/soc/hisilicon/hisi_hbmdev.c +++ b/drivers/soc/hisilicon/hisi_hbmdev.c @@ -59,7 +59,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;
hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/IAO4WG
--------------------------------------------
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 specificed 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 --- 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 e9b9e2db32cf..1cd7b8489b62 100644 --- a/drivers/acpi/acpi_memhotplug.c +++ b/drivers/acpi/acpi_memhotplug.c @@ -224,6 +224,19 @@ static int acpi_memory_enable_device(struct acpi_memory_device *mem_device) hotplug_mdev[node] = mem_device->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 5ac34c0eeb47..82444a4cbf15 100644 --- a/drivers/acpi/internal.h +++ b/drivers/acpi/internal.h @@ -265,5 +265,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 26453a945da4..5be7334c51f3 100644 --- a/drivers/acpi/numa/hmat.c +++ b/drivers/acpi/numa/hmat.c @@ -723,6 +723,23 @@ static void hmat_register_target_devices(struct memory_target *target) } }
+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) { int nid = pxm_to_node(target->memory_pxm);
反馈: 您发送到kernel@openeuler.org的补丁/补丁集,已成功转换为PR! PR链接地址: https://gitee.com/openeuler/kernel/pulls/11334 邮件列表地址:https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/E...
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://gitee.com/openeuler/kernel/pulls/11334 Mailing list address: https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/E...