Commit 2e1b00fc authored by Zhang Zekun's avatar Zhang Zekun
Browse files

ACPI/HMAT: Add missing locality information for hot-added device

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: default avatarZhang Zekun <zhangzekun11@huawei.com>
parent 74411d6b
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);