
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); -- 2.17.1