Commit a7034e9e authored by Chengwen Feng's avatar Chengwen Feng Committed by Rafael J. Wysocki
Browse files

ACPI: PPTT: Use acpi_get_cpu_uid() and remove get_acpi_id_for_cpu()



Update acpi/pptt.c to use acpi_get_cpu_uid() and remove unused
get_acpi_id_for_cpu() from arm64/loongarch/riscv, completing PPTT's
migration to the unified ACPI CPU UID interface

Signed-off-by: default avatarChengwen Feng <fengchengwen@huawei.com>
Reviewed-by: default avatarJonathan Cameron <jonathan.cameron@huawei.com>
Link: https://patch.msgid.link/20260401081640.26875-8-fengchengwen@huawei.com


Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 1ab03189
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -114,10 +114,6 @@ static inline bool acpi_has_cpu_in_madt(void)
}

struct acpi_madt_generic_interrupt *acpi_cpu_get_madt_gicc(int cpu);
static inline u32 get_acpi_id_for_cpu(unsigned int cpu)
{
	return	acpi_cpu_get_madt_gicc(cpu)->uid;
}
int get_cpu_for_acpi_id(u32 uid);

static inline void arch_fix_phys_package_id(int num, u32 slot) { }
+0 −5
Original line number Diff line number Diff line
@@ -40,11 +40,6 @@ extern struct acpi_madt_core_pic acpi_core_pic[MAX_CORE_PIC];

extern int __init parse_acpi_topology(void);

static inline u32 get_acpi_id_for_cpu(unsigned int cpu)
{
	return acpi_core_pic[cpu_logical_map(cpu)].processor_id;
}

#endif /* !CONFIG_ACPI */

#define ACPI_TABLE_UPGRADE_MAX_PHYS ARCH_LOW_ADDRESS_LIMIT
+0 −4
Original line number Diff line number Diff line
@@ -61,10 +61,6 @@ static inline void arch_fix_phys_package_id(int num, u32 slot) { }

void acpi_init_rintc_map(void);
struct acpi_madt_rintc *acpi_cpu_get_madt_rintc(int cpu);
static inline u32 get_acpi_id_for_cpu(int cpu)
{
	return acpi_cpu_get_madt_rintc(cpu)->uid;
}

int acpi_get_riscv_isa(struct acpi_table_header *table,
		       unsigned int cpu, const char **isa);
+37 −13
Original line number Diff line number Diff line
@@ -459,11 +459,14 @@ static void cache_setup_acpi_cpu(struct acpi_table_header *table,
{
	struct acpi_pptt_cache *found_cache;
	struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu);
	u32 acpi_cpu_id = get_acpi_id_for_cpu(cpu);
	u32 acpi_cpu_id;
	struct cacheinfo *this_leaf;
	unsigned int index = 0;
	struct acpi_pptt_processor *cpu_node = NULL;

	if (acpi_get_cpu_uid(cpu, &acpi_cpu_id) != 0)
		return;

	while (index < get_cpu_cacheinfo(cpu)->num_leaves) {
		this_leaf = this_cpu_ci->info_list + index;
		found_cache = acpi_find_cache_node(table, acpi_cpu_id,
@@ -546,7 +549,10 @@ static int topology_get_acpi_cpu_tag(struct acpi_table_header *table,
				     unsigned int cpu, int level, int flag)
{
	struct acpi_pptt_processor *cpu_node;
	u32 acpi_cpu_id = get_acpi_id_for_cpu(cpu);
	u32 acpi_cpu_id;

	if (acpi_get_cpu_uid(cpu, &acpi_cpu_id) != 0)
		return -ENOENT;

	cpu_node = acpi_find_processor_node(table, acpi_cpu_id);
	if (cpu_node) {
@@ -614,18 +620,22 @@ static int find_acpi_cpu_topology_tag(unsigned int cpu, int level, int flag)
 *
 * Check the node representing a CPU for a given flag.
 *
 * Return: -ENOENT if the PPTT doesn't exist, the CPU cannot be found or
 *	   the table revision isn't new enough.
 * Return: -ENOENT if can't get CPU's ACPI Processor UID, the PPTT doesn't
 *	   exist, the CPU cannot be found or the table revision isn't new
 *	   enough.
 *	   1, any passed flag set
 *	   0, flag unset
 */
static int check_acpi_cpu_flag(unsigned int cpu, int rev, u32 flag)
{
	struct acpi_table_header *table;
	u32 acpi_cpu_id = get_acpi_id_for_cpu(cpu);
	u32 acpi_cpu_id;
	struct acpi_pptt_processor *cpu_node = NULL;
	int ret = -ENOENT;

	if (acpi_get_cpu_uid(cpu, &acpi_cpu_id) != 0)
		return -ENOENT;

	table = acpi_get_pptt();
	if (!table)
		return -ENOENT;
@@ -651,7 +661,8 @@ static int check_acpi_cpu_flag(unsigned int cpu, int rev, u32 flag)
 * in the PPTT. Errors caused by lack of a PPTT table, or otherwise, return 0
 * indicating we didn't find any cache levels.
 *
 * Return: -ENOENT if no PPTT table or no PPTT processor struct found.
 * Return: -ENOENT if no PPTT table, can't get CPU's ACPI Process UID or no PPTT
 *	   processor struct found.
 *	   0 on success.
 */
int acpi_get_cache_info(unsigned int cpu, unsigned int *levels,
@@ -671,7 +682,9 @@ int acpi_get_cache_info(unsigned int cpu, unsigned int *levels,

	pr_debug("Cache Setup: find cache levels for CPU=%d\n", cpu);

	acpi_cpu_id = get_acpi_id_for_cpu(cpu);
	if (acpi_get_cpu_uid(cpu, &acpi_cpu_id))
		return -ENOENT;

	cpu_node = acpi_find_processor_node(table, acpi_cpu_id);
	if (!cpu_node)
		return -ENOENT;
@@ -780,8 +793,9 @@ int find_acpi_cpu_topology_package(unsigned int cpu)
 * It may not exist in single CPU systems. In simple multi-CPU systems,
 * it may be equal to the package topology level.
 *
 * Return: -ENOENT if the PPTT doesn't exist, the CPU cannot be found
 * or there is no toplogy level above the CPU..
 * Return: -ENOENT if the PPTT doesn't exist, can't get CPU's ACPI
 * Processor UID, the CPU cannot be found or there is no toplogy level
 * above the CPU.
 * Otherwise returns a value which represents the package for this CPU.
 */

@@ -797,7 +811,9 @@ int find_acpi_cpu_topology_cluster(unsigned int cpu)
	if (!table)
		return -ENOENT;

	acpi_cpu_id = get_acpi_id_for_cpu(cpu);
	if (acpi_get_cpu_uid(cpu, &acpi_cpu_id) != 0)
		return -ENOENT;

	cpu_node = acpi_find_processor_node(table, acpi_cpu_id);
	if (!cpu_node || !cpu_node->parent)
		return -ENOENT;
@@ -872,7 +888,9 @@ static void acpi_pptt_get_child_cpus(struct acpi_table_header *table_hdr,
	cpumask_clear(cpus);

	for_each_possible_cpu(cpu) {
		acpi_id = get_acpi_id_for_cpu(cpu);
		if (acpi_get_cpu_uid(cpu, &acpi_id) != 0)
			continue;

		cpu_node = acpi_find_processor_node(table_hdr, acpi_id);

		while (cpu_node) {
@@ -966,10 +984,13 @@ int find_acpi_cache_level_from_id(u32 cache_id)
	for_each_possible_cpu(cpu) {
		bool empty;
		int level = 1;
		u32 acpi_cpu_id = get_acpi_id_for_cpu(cpu);
		u32 acpi_cpu_id;
		struct acpi_pptt_cache *cache;
		struct acpi_pptt_processor *cpu_node;

		if (acpi_get_cpu_uid(cpu, &acpi_cpu_id) != 0)
			continue;

		cpu_node = acpi_find_processor_node(table, acpi_cpu_id);
		if (!cpu_node)
			continue;
@@ -1030,10 +1051,13 @@ int acpi_pptt_get_cpumask_from_cache_id(u32 cache_id, cpumask_t *cpus)
	for_each_possible_cpu(cpu) {
		bool empty;
		int level = 1;
		u32 acpi_cpu_id = get_acpi_id_for_cpu(cpu);
		u32 acpi_cpu_id;
		struct acpi_pptt_cache *cache;
		struct acpi_pptt_processor *cpu_node;

		if (acpi_get_cpu_uid(cpu, &acpi_cpu_id) != 0)
			continue;

		cpu_node = acpi_find_processor_node(table, acpi_cpu_id);
		if (!cpu_node)
			continue;