mirror of
https://github.com/torvalds/linux.git
synced 2026-05-31 18:43:33 +02:00
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>
This commit is contained in:
parent
591cd656a1
commit
7cd5f5659a
|
|
@ -118,18 +118,8 @@ static inline u32 get_acpi_id_for_cpu(unsigned int cpu)
|
|||
{
|
||||
return acpi_cpu_get_madt_gicc(cpu)->uid;
|
||||
}
|
||||
|
||||
static inline int get_cpu_for_acpi_id(u32 uid)
|
||||
{
|
||||
int cpu;
|
||||
|
||||
for (cpu = 0; cpu < nr_cpu_ids; cpu++)
|
||||
if (acpi_cpu_get_madt_gicc(cpu) &&
|
||||
uid == get_acpi_id_for_cpu(cpu))
|
||||
return cpu;
|
||||
|
||||
return -EINVAL;
|
||||
}
|
||||
int acpi_get_cpu_uid(unsigned int cpu, u32 *uid);
|
||||
int get_cpu_for_acpi_id(u32 uid);
|
||||
|
||||
static inline void arch_fix_phys_package_id(int num, u32 slot) { }
|
||||
void __init acpi_init_cpus(void);
|
||||
|
|
|
|||
|
|
@ -458,3 +458,33 @@ int acpi_unmap_cpu(int cpu)
|
|||
}
|
||||
EXPORT_SYMBOL(acpi_unmap_cpu);
|
||||
#endif /* CONFIG_ACPI_HOTPLUG_CPU */
|
||||
|
||||
int acpi_get_cpu_uid(unsigned int cpu, u32 *uid)
|
||||
{
|
||||
struct acpi_madt_generic_interrupt *gicc;
|
||||
|
||||
if (cpu >= nr_cpu_ids)
|
||||
return -EINVAL;
|
||||
|
||||
gicc = acpi_cpu_get_madt_gicc(cpu);
|
||||
if (!gicc)
|
||||
return -ENODEV;
|
||||
|
||||
*uid = gicc->uid;
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(acpi_get_cpu_uid);
|
||||
|
||||
int get_cpu_for_acpi_id(u32 uid)
|
||||
{
|
||||
u32 cpu_uid;
|
||||
int ret;
|
||||
|
||||
for (int cpu = 0; cpu < nr_cpu_ids; cpu++) {
|
||||
ret = acpi_get_cpu_uid(cpu, &cpu_uid);
|
||||
if (ret == 0 && uid == cpu_uid)
|
||||
return cpu;
|
||||
}
|
||||
|
||||
return -EINVAL;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user