Commit 8d7c8662 authored by Zhang Zekun's avatar Zhang Zekun
Browse files

hisilicon/hisi_hbmcache: Add a lock to protect pcc operation region

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: 24856a36 ("soc: hbmcache: Add support for online and offline the hbm cache")
Signed-off-by: default avatarZhang Zekun <zhangzekun11@huawei.com>
parent 0a41d510
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -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);