|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH v6 1/3] ACPI: Rename get_acpi_id_for_cpu() to acpi_get_cpu_uid() on non-x86
On Thu, 12 Mar 2026 15:23:14 +0800
Chengwen Feng <fengchengwen@xxxxxxxxxx> wrote:
> To unify the CPU ACPI ID retrieval interface across architectures,
> rename the existing get_acpi_id_for_cpu() function to
> acpi_get_cpu_uid() on arm64/riscv/loongarch platforms.
>
> This is a pure rename with no functional change, preparing for a
It's not just a rename. This should mention that the addition of error
checks and hence the resulting signature change.
> consistent ACPI Processor UID retrieval interface across all ACPI-enabled
> platforms.
>
> Note: Move the ARM64-specific get_cpu_for_acpi_id() implementation to
> arch/arm64/kernel/acpi_numa.c to fix compilation errors from
> circular header dependencies introduced by the rename.
>
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Chengwen Feng <fengchengwen@xxxxxxxxxx>
> Reviewed-by: Jonathan Cameron <jonathan.cameron@xxxxxxxxxx>
From a reread, a few minor style consistency things inline.
> ---
> arch/arm64/include/asm/acpi.h | 16 +---------
> arch/arm64/kernel/acpi.c | 16 ++++++++++
> arch/arm64/kernel/acpi_numa.c | 15 ++++++++++
> arch/loongarch/include/asm/acpi.h | 5 ----
> arch/loongarch/kernel/acpi.c | 9 ++++++
> arch/riscv/include/asm/acpi.h | 4 ---
> arch/riscv/kernel/acpi.c | 16 ++++++++++
> arch/riscv/kernel/acpi_numa.c | 8 +++--
> drivers/acpi/pptt.c | 47 +++++++++++++++++++++---------
> drivers/acpi/riscv/rhct.c | 7 ++++-
> drivers/perf/arm_cspmu/arm_cspmu.c | 6 ++--
> include/linux/acpi.h | 13 +++++++++
> 12 files changed, 120 insertions(+), 42 deletions(-)
> diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
> index af90128cfed5..984a11788265 100644
> --- a/arch/arm64/kernel/acpi.c
> +++ b/arch/arm64/kernel/acpi.c
> @@ -458,3 +458,19 @@ 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 == NULL)
Seems local style for null pointer checks is
if (!gicc)
Just for consistency we should follow that.
> + return -ENODEV;
> +
> + *uid = gicc->uid;
> + return 0;
> +}
> +EXPORT_SYMBOL_GPL(acpi_get_cpu_uid);
> diff --git a/arch/arm64/kernel/acpi_numa.c b/arch/arm64/kernel/acpi_numa.c
> index 2465f291c7e1..56e2e486e49b 100644
> --- a/arch/arm64/kernel/acpi_numa.c
> +++ b/arch/arm64/kernel/acpi_numa.c
> @@ -34,6 +34,21 @@ int __init acpi_numa_get_nid(unsigned int cpu)
> return acpi_early_node_map[cpu];
> }
>
> +int get_cpu_for_acpi_id(u32 uid)
> +{
> + u32 cpu_uid;
> + int cpu;
> + int ret;
> +
> + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
Given more recent acceptance of the following perhaps it is neater here.
for (int cpu = 0; cpu < nr_cpu_ids; cpu++) {
Amazingly there aren't any for loops in this file so we can do what we
like from a consistency point of view.
> + ret = acpi_get_cpu_uid(cpu, &cpu_uid);
> + if (ret == 0 && uid == cpu_uid)
> + return cpu;
> + }
> +
> + return -EINVAL;
> +}
> +
> static int __init acpi_parse_gicc_pxm(union acpi_subtable_headers *header,
> const unsigned long end)
> {
> diff --git a/arch/riscv/kernel/acpi.c b/arch/riscv/kernel/acpi.c
> index 71698ee11621..bde810d02c4f 100644
> --- a/arch/riscv/kernel/acpi.c
> +++ b/arch/riscv/kernel/acpi.c
> @@ -337,3 +337,19 @@ int raw_pci_write(unsigned int domain, unsigned int bus,
> }
>
> #endif /* CONFIG_PCI */
> +
> +int acpi_get_cpu_uid(unsigned int cpu, u32 *uid)
> +{
> + struct acpi_madt_rintc *rintc;
> +
> + if (cpu >= nr_cpu_ids)
> + return -EINVAL;
> +
> + rintc = acpi_cpu_get_madt_rintc(cpu);
> + if (rintc == NULL)
Similar to above. Local style for NULL checks is
if (!rintc)
so this should follow that.
> + return -ENODEV;
> +
> + *uid = rintc->uid;
> + return 0;
> +}
> +EXPORT_SYMBOL_GPL(acpi_get_cpu_uid);
> diff --git a/arch/riscv/kernel/acpi_numa.c b/arch/riscv/kernel/acpi_numa.c
> index 130769e3a99c..cd8adc9857e3 100644
> --- a/arch/riscv/kernel/acpi_numa.c
> +++ b/arch/riscv/kernel/acpi_numa.c
> @@ -37,11 +37,15 @@ static int __init acpi_numa_get_nid(unsigned int cpu)
>
> static inline int get_cpu_for_acpi_id(u32 uid)
> {
> + u32 cpu_uid;
> int cpu;
> + int ret;
>
> - for (cpu = 0; cpu < nr_cpu_ids; cpu++)
> - if (uid == get_acpi_id_for_cpu(cpu))
> + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
Can pull the int into the loop her as well.
> + ret = acpi_get_cpu_uid(cpu, &cpu_uid);
> + if (ret == 0 && uid == cpu_uid)
> return cpu;
> + }
>
> return -EINVAL;
> }
> diff --git a/drivers/acpi/pptt.c b/drivers/acpi/pptt.c
> index de5f8c018333..d034a217e85b 100644
> --- a/drivers/acpi/pptt.c
> +++ b/drivers/acpi/pptt.c
> 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,8 @@ 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;
I'd put a blank line here (similar to the code you added just above).
> cpu_node = acpi_find_processor_node(table, acpi_cpu_id);
> if (!cpu_node)
> return -ENOENT;
> @@ -780,8 +792,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 +810,8 @@ 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;
Again, I'd put a blank line here.
> cpu_node = acpi_find_processor_node(table, acpi_cpu_id);
> if (!cpu_node || !cpu_node->parent)
> return -ENOENT;
> @@ -872,7 +886,8 @@ 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;
and here.
> cpu_node = acpi_find_processor_node(table_hdr, acpi_id);
>
> while (cpu_node) {
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |