Unverified Commit b7bed662 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!11337 v3 Some features and fixs for hbmdev and hbm cache

Merge Pull Request from: @ci-robot 
 
PR sync from: Zhang Zekun <zhangzekun11@huawei.com>
https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/MKBV37HA7MRYVEMHIGIVJJG3CTSZNRHR/ 
hbmdev and hbmcache new features and new fixs.

v2:
- Fix format warning

v3:
- Improve the patch subject

Zhang Zekun (4):
  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


-- 
2.17.1
 
https://gitee.com/openeuler/kernel/issues/IAO4WG 
 
Link:https://gitee.com/openeuler/kernel/pulls/11337

 

Reviewed-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: default avatarXie XiuQi <xiexiuqi@huawei.com>
Acked-by: default avatarXie XiuQi <xiexiuqi@huawei.com>
parents 02994a9b 2e1b00fc
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -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;
+1 −0
Original line number Diff line number Diff line
@@ -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_ */
+17 −0
Original line number Diff line number Diff line
@@ -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);
+13 −7
Original line number Diff line number Diff line
@@ -14,27 +14,31 @@
#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)
{
	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;

	mutex_lock(&cache_lock);
	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;
	}
	mutex_unlock(&cache_lock);

	if (ret)
		return ret;
	if (ACPI_FAILURE(status))
		return -ENODEV;

	return count;
}
@@ -90,8 +94,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 = {
@@ -111,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 −0
Original line number Diff line number Diff line
@@ -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;