From: Jonathan Cameron <jonathan.cameron@huawei.com>
To: Chengwen Feng <fengchengwen@huawei.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>,
"Rafael J . Wysocki" <rafael@kernel.org>,
Jonathan Corbet <corbet@lwn.net>,
Shuah Khan <skhan@linuxfoundation.org>,
Huacai Chen <chenhuacai@kernel.org>,
"WANG Xuerui" <kernel@xen0n.name>, Paul Walmsley <pjw@kernel.org>,
"Palmer Dabbelt" <palmer@dabbelt.com>,
Albert Ou <aou@eecs.berkeley.edu>,
"Alexandre Ghiti" <alex@ghiti.fr>,
Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@redhat.com>,
Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>, <x86@kernel.org>,
"H . Peter Anvin" <hpa@zytor.com>,
Juergen Gross <jgross@suse.com>,
Boris Ostrovsky <boris.ostrovsky@oracle.com>,
Len Brown <lenb@kernel.org>, Sunil V L <sunilvl@ventanamicro.com>,
Mark Rutland <mark.rutland@arm.com>, Kees Cook <kees@kernel.org>,
Yanteng Si <si.yanteng@linux.dev>,
Sean Christopherson <seanjc@google.com>,
Kai Huang <kai.huang@intel.com>,
Tom Lendacky <thomas.lendacky@amd.com>,
Thomas Huth <thuth@redhat.com>,
Thorsten Blum <thorsten.blum@linux.dev>,
Kevin Loughlin <kevinloughlin@google.com>,
Zheyun Shen <szy0127@sjtu.edu.cn>,
Peter Zijlstra <peterz@infradead.org>,
Pawan Gupta <pawan.kumar.gupta@linux.intel.com>,
Xin Li <xin@zytor.com>, "Ahmed S . Darwish" <darwi@linutronix.de>,
Sohil Mehta <sohil.mehta@intel.com>,
Ilkka Koskinen <ilkka@os.amperecomputing.com>,
Robin Murphy <robin.murphy@arm.com>,
James Clark <james.clark@linaro.org>,
Besar Wicaksono <bwicaksono@nvidia.com>,
Ma Ke <make24@iscas.ac.cn>, "Wei Huang" <wei.huang2@amd.com>,
Andy Gospodarek <andrew.gospodarek@broadcom.com>,
Somnath Kotur <somnath.kotur@broadcom.com>,
<punit.agrawal@oss.qualcomm.com>, <guohanjun@huawei.com>,
<suzuki.poulose@arm.com>, <ryan.roberts@arm.com>,
<chenl311@chinatelecom.cn>, <masahiroy@kernel.org>,
<wangyuquan1236@phytium.com.cn>, <anshuman.khandual@arm.com>,
<heinrich.schuchardt@canonical.com>, <Eric.VanTassell@amd.com>,
<wangzhou1@hisilicon.com>, <wanghuiqiang@huawei.com>,
<liuyonglong@huawei.com>, <linux-pci@vger.kernel.org>,
<linux-doc@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<loongarch@lists.linux.dev>, <linux-riscv@lists.infradead.org>,
<xen-devel@lists.xenproject.org>, <linux-acpi@vger.kernel.org>,
<linux-perf-users@vger.kernel.org>, <stable@vger.kernel.org>
Subject: Re: [PATCH v6 1/3] ACPI: Rename get_acpi_id_for_cpu() to acpi_get_cpu_uid() on non-x86
Date: Thu, 12 Mar 2026 11:07:42 +0000 [thread overview]
Message-ID: <20260312110742.00002716@huawei.com> (raw)
In-Reply-To: <20260312072316.4806-2-fengchengwen@huawei.com>
On Thu, 12 Mar 2026 15:23:14 +0800
Chengwen Feng <fengchengwen@huawei.com> 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@vger.kernel.org
> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
> Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
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) {
next prev parent reply other threads:[~2026-03-12 11:07 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-12 7:23 [PATCH v6 0/3] Fix get cpu steer-tag fail on ARM64 platform Chengwen Feng
2026-03-12 7:23 ` [PATCH v6 1/3] ACPI: Rename get_acpi_id_for_cpu() to acpi_get_cpu_uid() on non-x86 Chengwen Feng
2026-03-12 11:07 ` Jonathan Cameron [this message]
2026-03-13 2:30 ` fengchengwen
2026-03-12 7:23 ` [PATCH v6 2/3] x86: Implement acpi_get_cpu_uid() Chengwen Feng
2026-03-12 10:55 ` Jonathan Cameron
2026-03-12 11:02 ` Peter Zijlstra
2026-03-13 2:32 ` fengchengwen
2026-03-12 7:23 ` [PATCH v6 3/3] PCI/TPH: Fix get cpu steer-tag fail on ARM64 platform Chengwen Feng
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260312110742.00002716@huawei.com \
--to=jonathan.cameron@huawei.com \
--cc=Eric.VanTassell@amd.com \
--cc=alex@ghiti.fr \
--cc=andrew.gospodarek@broadcom.com \
--cc=anshuman.khandual@arm.com \
--cc=aou@eecs.berkeley.edu \
--cc=bhelgaas@google.com \
--cc=boris.ostrovsky@oracle.com \
--cc=bp@alien8.de \
--cc=bwicaksono@nvidia.com \
--cc=catalin.marinas@arm.com \
--cc=chenhuacai@kernel.org \
--cc=chenl311@chinatelecom.cn \
--cc=corbet@lwn.net \
--cc=darwi@linutronix.de \
--cc=dave.hansen@linux.intel.com \
--cc=fengchengwen@huawei.com \
--cc=guohanjun@huawei.com \
--cc=heinrich.schuchardt@canonical.com \
--cc=hpa@zytor.com \
--cc=ilkka@os.amperecomputing.com \
--cc=james.clark@linaro.org \
--cc=jgross@suse.com \
--cc=kai.huang@intel.com \
--cc=kees@kernel.org \
--cc=kernel@xen0n.name \
--cc=kevinloughlin@google.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=liuyonglong@huawei.com \
--cc=loongarch@lists.linux.dev \
--cc=make24@iscas.ac.cn \
--cc=mark.rutland@arm.com \
--cc=masahiroy@kernel.org \
--cc=mingo@redhat.com \
--cc=palmer@dabbelt.com \
--cc=pawan.kumar.gupta@linux.intel.com \
--cc=peterz@infradead.org \
--cc=pjw@kernel.org \
--cc=punit.agrawal@oss.qualcomm.com \
--cc=rafael@kernel.org \
--cc=robin.murphy@arm.com \
--cc=ryan.roberts@arm.com \
--cc=seanjc@google.com \
--cc=si.yanteng@linux.dev \
--cc=skhan@linuxfoundation.org \
--cc=sohil.mehta@intel.com \
--cc=somnath.kotur@broadcom.com \
--cc=stable@vger.kernel.org \
--cc=sunilvl@ventanamicro.com \
--cc=suzuki.poulose@arm.com \
--cc=szy0127@sjtu.edu.cn \
--cc=tglx@kernel.org \
--cc=thomas.lendacky@amd.com \
--cc=thorsten.blum@linux.dev \
--cc=thuth@redhat.com \
--cc=wanghuiqiang@huawei.com \
--cc=wangyuquan1236@phytium.com.cn \
--cc=wangzhou1@hisilicon.com \
--cc=wei.huang2@amd.com \
--cc=will@kernel.org \
--cc=x86@kernel.org \
--cc=xen-devel@lists.xenproject.org \
--cc=xin@zytor.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox