Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

arm64: acpi: Add acpi_get_cpu_uid() for unified ACPI CPU UID retrieval

As a step towards unifying the interface for retrieving ACPI CPU UID
across architectures, introduce a new function acpi_get_cpu_uid() for
arm64. While at it, add input validation to make the code more robust.

Reimplement get_cpu_for_acpi_id() based on acpi_get_cpu_uid() for
consistency, and move its implementation next to the new function for
code coherence.

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Link: https://patch.msgid.link/20260401081640.26875-2-fengchengwen@huawei.com
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

authored by

Chengwen Feng and committed by
Rafael J. Wysocki
7cd5f565 591cd656

+32 -12
+2 -12
arch/arm64/include/asm/acpi.h
··· 118 118 { 119 119 return acpi_cpu_get_madt_gicc(cpu)->uid; 120 120 } 121 - 122 - static inline int get_cpu_for_acpi_id(u32 uid) 123 - { 124 - int cpu; 125 - 126 - for (cpu = 0; cpu < nr_cpu_ids; cpu++) 127 - if (acpi_cpu_get_madt_gicc(cpu) && 128 - uid == get_acpi_id_for_cpu(cpu)) 129 - return cpu; 130 - 131 - return -EINVAL; 132 - } 121 + int acpi_get_cpu_uid(unsigned int cpu, u32 *uid); 122 + int get_cpu_for_acpi_id(u32 uid); 133 123 134 124 static inline void arch_fix_phys_package_id(int num, u32 slot) { } 135 125 void __init acpi_init_cpus(void);
+30
arch/arm64/kernel/acpi.c
··· 458 458 } 459 459 EXPORT_SYMBOL(acpi_unmap_cpu); 460 460 #endif /* CONFIG_ACPI_HOTPLUG_CPU */ 461 + 462 + int acpi_get_cpu_uid(unsigned int cpu, u32 *uid) 463 + { 464 + struct acpi_madt_generic_interrupt *gicc; 465 + 466 + if (cpu >= nr_cpu_ids) 467 + return -EINVAL; 468 + 469 + gicc = acpi_cpu_get_madt_gicc(cpu); 470 + if (!gicc) 471 + return -ENODEV; 472 + 473 + *uid = gicc->uid; 474 + return 0; 475 + } 476 + EXPORT_SYMBOL_GPL(acpi_get_cpu_uid); 477 + 478 + int get_cpu_for_acpi_id(u32 uid) 479 + { 480 + u32 cpu_uid; 481 + int ret; 482 + 483 + for (int cpu = 0; cpu < nr_cpu_ids; cpu++) { 484 + ret = acpi_get_cpu_uid(cpu, &cpu_uid); 485 + if (ret == 0 && uid == cpu_uid) 486 + return cpu; 487 + } 488 + 489 + return -EINVAL; 490 + }