* [PATCH v9 1/7] arm64/acpi: Add acpi_get_cpu_uid() and switch arm_cspmu to use it
2026-03-19 6:57 [PATCH v9 0/7] ACPI: Unify CPU UID interface and fix ARM64 TPH steer-tag issue Chengwen Feng
@ 2026-03-19 6:57 ` Chengwen Feng
2026-03-19 15:46 ` Punit Agrawal
2026-03-19 6:57 ` [PATCH v9 2/7] loongarch/acpi: Add acpi_get_cpu_uid() declaration and implementation Chengwen Feng
` (6 subsequent siblings)
7 siblings, 1 reply; 14+ messages in thread
From: Chengwen Feng @ 2026-03-19 6:57 UTC (permalink / raw)
To: Bjorn Helgaas, Catalin Marinas, Will Deacon, Rafael J . Wysocki
Cc: Jonathan Corbet, Shuah Khan, Huacai Chen, WANG Xuerui,
Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
H . Peter Anvin, Juergen Gross, Boris Ostrovsky, Len Brown,
Sunil V L, Mark Rutland, Jonathan Cameron, Kees Cook, Yanteng Si,
Sean Christopherson, Kai Huang, Tom Lendacky, Thomas Huth,
Thorsten Blum, Kevin Loughlin, Zheyun Shen, Peter Zijlstra,
Pawan Gupta, Xin Li, Ahmed S . Darwish, Sohil Mehta,
Ilkka Koskinen, Robin Murphy, James Clark, Besar Wicaksono, Ma Ke,
Wei Huang, Andy Gospodarek, Somnath Kotur, punit.agrawal,
guohanjun, suzuki.poulose, ryan.roberts, chenl311, masahiroy,
wangyuquan1236, anshuman.khandual, heinrich.schuchardt,
Eric.VanTassell, wangzhou1, wanghuiqiang, liuyonglong,
fengchengwen, linux-pci, linux-doc, linux-kernel,
linux-arm-kernel, loongarch, linux-riscv, xen-devel, linux-acpi,
linux-perf-users, stable
Add arch-specific acpi_get_cpu_uid() for arm64, and update dependent
code:
- Declare acpi_get_cpu_uid() in arch/arm64/include/asm/acpi.h
- Implement acpi_get_cpu_uid() with input parameter validation
- Replace get_acpi_id_for_cpu() with acpi_get_cpu_uid() in
drivers/perf/arm_cspmu/arm_cspmu.c
- Reimplement get_cpu_for_acpi_id() based on acpi_get_cpu_uid() (to
align with new interface) and move its implementation next to
acpi_get_cpu_uid()
This is the first step towards unifying ACPI CPU UID retrieval interface
across architectures, while adding input validation for robustness.
Cc: stable@vger.kernel.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
---
arch/arm64/include/asm/acpi.h | 14 ++------------
arch/arm64/kernel/acpi.c | 30 ++++++++++++++++++++++++++++++
drivers/perf/arm_cspmu/arm_cspmu.c | 6 ++++--
3 files changed, 36 insertions(+), 14 deletions(-)
diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h
index c07a58b96329..2219a3301e72 100644
--- a/arch/arm64/include/asm/acpi.h
+++ b/arch/arm64/include/asm/acpi.h
@@ -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);
diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
index af90128cfed5..24b9d934be54 100644
--- a/arch/arm64/kernel/acpi.c
+++ b/arch/arm64/kernel/acpi.c
@@ -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;
+}
diff --git a/drivers/perf/arm_cspmu/arm_cspmu.c b/drivers/perf/arm_cspmu/arm_cspmu.c
index 34430b68f602..ed72c3d1f796 100644
--- a/drivers/perf/arm_cspmu/arm_cspmu.c
+++ b/drivers/perf/arm_cspmu/arm_cspmu.c
@@ -1107,15 +1107,17 @@ static int arm_cspmu_acpi_get_cpus(struct arm_cspmu *cspmu)
{
struct acpi_apmt_node *apmt_node;
int affinity_flag;
+ u32 cpu_uid;
int cpu;
+ int ret;
apmt_node = arm_cspmu_apmt_node(cspmu->dev);
affinity_flag = apmt_node->flags & ACPI_APMT_FLAGS_AFFINITY;
if (affinity_flag == ACPI_APMT_FLAGS_AFFINITY_PROC) {
for_each_possible_cpu(cpu) {
- if (apmt_node->proc_affinity ==
- get_acpi_id_for_cpu(cpu)) {
+ ret = acpi_get_cpu_uid(cpu, &cpu_uid);
+ if (ret == 0 && apmt_node->proc_affinity == cpu_uid) {
cpumask_set_cpu(cpu, &cspmu->associated_cpus);
break;
}
--
2.17.1
^ permalink raw reply related [flat|nested] 14+ messages in thread* Re: [PATCH v9 1/7] arm64/acpi: Add acpi_get_cpu_uid() and switch arm_cspmu to use it
2026-03-19 6:57 ` [PATCH v9 1/7] arm64/acpi: Add acpi_get_cpu_uid() and switch arm_cspmu to use it Chengwen Feng
@ 2026-03-19 15:46 ` Punit Agrawal
2026-03-20 3:20 ` fengchengwen
0 siblings, 1 reply; 14+ messages in thread
From: Punit Agrawal @ 2026-03-19 15:46 UTC (permalink / raw)
To: Chengwen Feng
Cc: Bjorn Helgaas, Catalin Marinas, Will Deacon, Rafael J . Wysocki,
Jonathan Corbet, Shuah Khan, Huacai Chen, WANG Xuerui,
Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
H . Peter Anvin, Juergen Gross, Boris Ostrovsky, Len Brown,
Sunil V L, Mark Rutland, Jonathan Cameron, Kees Cook, Yanteng Si,
Sean Christopherson, Kai Huang, Tom Lendacky, Thomas Huth,
Thorsten Blum, Kevin Loughlin, Zheyun Shen, Peter Zijlstra,
Pawan Gupta, Xin Li, Ahmed S . Darwish, Sohil Mehta,
Ilkka Koskinen, Robin Murphy, James Clark, Besar Wicaksono, Ma Ke,
Wei Huang, Andy Gospodarek, Somnath Kotur, punit.agrawal,
guohanjun, suzuki.poulose, ryan.roberts, chenl311, masahiroy,
wangyuquan1236, anshuman.khandual, heinrich.schuchardt,
Eric.VanTassell, wangzhou1, wanghuiqiang, liuyonglong, linux-pci,
linux-doc, linux-kernel, linux-arm-kernel, loongarch, linux-riscv,
xen-devel, linux-acpi, linux-perf-users, stable
Chengwen Feng <fengchengwen@huawei.com> writes:
> Add arch-specific acpi_get_cpu_uid() for arm64, and update dependent
> code:
> - Declare acpi_get_cpu_uid() in arch/arm64/include/asm/acpi.h
> - Implement acpi_get_cpu_uid() with input parameter validation
> - Replace get_acpi_id_for_cpu() with acpi_get_cpu_uid() in
> drivers/perf/arm_cspmu/arm_cspmu.c
> - Reimplement get_cpu_for_acpi_id() based on acpi_get_cpu_uid() (to
> align with new interface) and move its implementation next to
> acpi_get_cpu_uid()
There is no benefit in describing the code changes like this in the
commit log. It makes it hard to follow the intent of the patch.
> This is the first step towards unifying ACPI CPU UID retrieval interface
> across architectures, while adding input validation for robustness.
I would simplify the commit log to something along the lines of -
As a step towards unifying the interface for retrieving ACPI CPU uid
across architectures, introduce a new function
acpi_get_cpu_uid(). While at it, also add input validation to make
the code more robust.
Just my 2c.
The code changes looks fine.
> Cc: stable@vger.kernel.org
> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
> Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
> ---
> arch/arm64/include/asm/acpi.h | 14 ++------------
> arch/arm64/kernel/acpi.c | 30 ++++++++++++++++++++++++++++++
> drivers/perf/arm_cspmu/arm_cspmu.c | 6 ++++--
> 3 files changed, 36 insertions(+), 14 deletions(-)
>
> diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h
> index c07a58b96329..2219a3301e72 100644
> --- a/arch/arm64/include/asm/acpi.h
> +++ b/arch/arm64/include/asm/acpi.h
> @@ -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);
> diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
> index af90128cfed5..24b9d934be54 100644
> --- a/arch/arm64/kernel/acpi.c
> +++ b/arch/arm64/kernel/acpi.c
> @@ -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;
> +}
> diff --git a/drivers/perf/arm_cspmu/arm_cspmu.c b/drivers/perf/arm_cspmu/arm_cspmu.c
> index 34430b68f602..ed72c3d1f796 100644
> --- a/drivers/perf/arm_cspmu/arm_cspmu.c
> +++ b/drivers/perf/arm_cspmu/arm_cspmu.c
> @@ -1107,15 +1107,17 @@ static int arm_cspmu_acpi_get_cpus(struct arm_cspmu *cspmu)
> {
> struct acpi_apmt_node *apmt_node;
> int affinity_flag;
> + u32 cpu_uid;
> int cpu;
> + int ret;
>
> apmt_node = arm_cspmu_apmt_node(cspmu->dev);
> affinity_flag = apmt_node->flags & ACPI_APMT_FLAGS_AFFINITY;
>
> if (affinity_flag == ACPI_APMT_FLAGS_AFFINITY_PROC) {
> for_each_possible_cpu(cpu) {
> - if (apmt_node->proc_affinity ==
> - get_acpi_id_for_cpu(cpu)) {
> + ret = acpi_get_cpu_uid(cpu, &cpu_uid);
> + if (ret == 0 && apmt_node->proc_affinity == cpu_uid) {
> cpumask_set_cpu(cpu, &cspmu->associated_cpus);
> break;
> }
I think cspmu changes go via a separate pull request. You might have to
split this change into a separate commit.
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH v9 1/7] arm64/acpi: Add acpi_get_cpu_uid() and switch arm_cspmu to use it
2026-03-19 15:46 ` Punit Agrawal
@ 2026-03-20 3:20 ` fengchengwen
0 siblings, 0 replies; 14+ messages in thread
From: fengchengwen @ 2026-03-20 3:20 UTC (permalink / raw)
To: Punit Agrawal
Cc: Bjorn Helgaas, Catalin Marinas, Will Deacon, Rafael J . Wysocki,
Jonathan Corbet, Shuah Khan, Huacai Chen, WANG Xuerui,
Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
H . Peter Anvin, Juergen Gross, Boris Ostrovsky, Len Brown,
Sunil V L, Mark Rutland, Jonathan Cameron, Kees Cook, Yanteng Si,
Sean Christopherson, Kai Huang, Tom Lendacky, Thomas Huth,
Thorsten Blum, Kevin Loughlin, Zheyun Shen, Peter Zijlstra,
Pawan Gupta, Xin Li, Ahmed S . Darwish, Sohil Mehta,
Ilkka Koskinen, Robin Murphy, James Clark, Besar Wicaksono, Ma Ke,
Wei Huang, Andy Gospodarek, Somnath Kotur, guohanjun,
suzuki.poulose, ryan.roberts, chenl311, masahiroy, wangyuquan1236,
anshuman.khandual, heinrich.schuchardt, Eric.VanTassell,
wangzhou1, wanghuiqiang, liuyonglong, linux-pci, linux-doc,
linux-kernel, linux-arm-kernel, loongarch, linux-riscv, xen-devel,
linux-acpi, linux-perf-users, stable
On 3/19/2026 11:46 PM, Punit Agrawal wrote:
> Chengwen Feng <fengchengwen@huawei.com> writes:
>
>> Add arch-specific acpi_get_cpu_uid() for arm64, and update dependent
>> code:
>> - Declare acpi_get_cpu_uid() in arch/arm64/include/asm/acpi.h
>> - Implement acpi_get_cpu_uid() with input parameter validation
>> - Replace get_acpi_id_for_cpu() with acpi_get_cpu_uid() in
>> drivers/perf/arm_cspmu/arm_cspmu.c
>> - Reimplement get_cpu_for_acpi_id() based on acpi_get_cpu_uid() (to
>> align with new interface) and move its implementation next to
>> acpi_get_cpu_uid()
>
> There is no benefit in describing the code changes like this in the
> commit log. It makes it hard to follow the intent of the patch.
>
>> This is the first step towards unifying ACPI CPU UID retrieval interface
>> across architectures, while adding input validation for robustness.
>
> I would simplify the commit log to something along the lines of -
>
> As a step towards unifying the interface for retrieving ACPI CPU uid
> across architectures, introduce a new function
> acpi_get_cpu_uid(). While at it, also add input validation to make
> the code more robust.
Thank you for your advice.
I've reviewed all the commit logs and made some optimizations, and done in v10
>
> Just my 2c.
>
> The code changes looks fine.
>
>> Cc: stable@vger.kernel.org
>> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
>> Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
>> ---
>> arch/arm64/include/asm/acpi.h | 14 ++------------
>> arch/arm64/kernel/acpi.c | 30 ++++++++++++++++++++++++++++++
>> drivers/perf/arm_cspmu/arm_cspmu.c | 6 ++++--
>> 3 files changed, 36 insertions(+), 14 deletions(-)
>>
>> diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h
>> index c07a58b96329..2219a3301e72 100644
>> --- a/arch/arm64/include/asm/acpi.h
>> +++ b/arch/arm64/include/asm/acpi.h
>> @@ -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);
>> diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
>> index af90128cfed5..24b9d934be54 100644
>> --- a/arch/arm64/kernel/acpi.c
>> +++ b/arch/arm64/kernel/acpi.c
>> @@ -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;
>> +}
>> diff --git a/drivers/perf/arm_cspmu/arm_cspmu.c b/drivers/perf/arm_cspmu/arm_cspmu.c
>> index 34430b68f602..ed72c3d1f796 100644
>> --- a/drivers/perf/arm_cspmu/arm_cspmu.c
>> +++ b/drivers/perf/arm_cspmu/arm_cspmu.c
>> @@ -1107,15 +1107,17 @@ static int arm_cspmu_acpi_get_cpus(struct arm_cspmu *cspmu)
>> {
>> struct acpi_apmt_node *apmt_node;
>> int affinity_flag;
>> + u32 cpu_uid;
>> int cpu;
>> + int ret;
>>
>> apmt_node = arm_cspmu_apmt_node(cspmu->dev);
>> affinity_flag = apmt_node->flags & ACPI_APMT_FLAGS_AFFINITY;
>>
>> if (affinity_flag == ACPI_APMT_FLAGS_AFFINITY_PROC) {
>> for_each_possible_cpu(cpu) {
>> - if (apmt_node->proc_affinity ==
>> - get_acpi_id_for_cpu(cpu)) {
>> + ret = acpi_get_cpu_uid(cpu, &cpu_uid);
>> + if (ret == 0 && apmt_node->proc_affinity == cpu_uid) {
>> cpumask_set_cpu(cpu, &cspmu->associated_cpus);
>> break;
>> }
>
> I think cspmu changes go via a separate pull request. You might have to
> split this change into a separate commit.
done in v10
Thanks
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v9 2/7] loongarch/acpi: Add acpi_get_cpu_uid() declaration and implementation
2026-03-19 6:57 [PATCH v9 0/7] ACPI: Unify CPU UID interface and fix ARM64 TPH steer-tag issue Chengwen Feng
2026-03-19 6:57 ` [PATCH v9 1/7] arm64/acpi: Add acpi_get_cpu_uid() and switch arm_cspmu to use it Chengwen Feng
@ 2026-03-19 6:57 ` Chengwen Feng
2026-03-19 6:57 ` [PATCH v9 3/7] riscv/acpi: Add acpi_get_cpu_uid() implementation and update users Chengwen Feng
` (5 subsequent siblings)
7 siblings, 0 replies; 14+ messages in thread
From: Chengwen Feng @ 2026-03-19 6:57 UTC (permalink / raw)
To: Bjorn Helgaas, Catalin Marinas, Will Deacon, Rafael J . Wysocki
Cc: Jonathan Corbet, Shuah Khan, Huacai Chen, WANG Xuerui,
Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
H . Peter Anvin, Juergen Gross, Boris Ostrovsky, Len Brown,
Sunil V L, Mark Rutland, Jonathan Cameron, Kees Cook, Yanteng Si,
Sean Christopherson, Kai Huang, Tom Lendacky, Thomas Huth,
Thorsten Blum, Kevin Loughlin, Zheyun Shen, Peter Zijlstra,
Pawan Gupta, Xin Li, Ahmed S . Darwish, Sohil Mehta,
Ilkka Koskinen, Robin Murphy, James Clark, Besar Wicaksono, Ma Ke,
Wei Huang, Andy Gospodarek, Somnath Kotur, punit.agrawal,
guohanjun, suzuki.poulose, ryan.roberts, chenl311, masahiroy,
wangyuquan1236, anshuman.khandual, heinrich.schuchardt,
Eric.VanTassell, wangzhou1, wanghuiqiang, liuyonglong,
fengchengwen, linux-pci, linux-doc, linux-kernel,
linux-arm-kernel, loongarch, linux-riscv, xen-devel, linux-acpi,
linux-perf-users, stable
Add arch-specific acpi_get_cpu_uid() for loongarch:
- Declare acpi_get_cpu_uid() in arch/loongarch/include/asm/acpi.h
- Implement acpi_get_cpu_uid() with input parameter validation
Align loongarch with the new unified ACPI CPU UID retrieval interface,
preparing for replacement of the legacy get_acpi_id_for_cpu() (to be
removed in follow-up patches).
Cc: stable@vger.kernel.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
---
arch/loongarch/include/asm/acpi.h | 1 +
arch/loongarch/kernel/acpi.c | 9 +++++++++
2 files changed, 10 insertions(+)
diff --git a/arch/loongarch/include/asm/acpi.h b/arch/loongarch/include/asm/acpi.h
index 7376840fa9f7..8bb101b4557e 100644
--- a/arch/loongarch/include/asm/acpi.h
+++ b/arch/loongarch/include/asm/acpi.h
@@ -44,6 +44,7 @@ static inline u32 get_acpi_id_for_cpu(unsigned int cpu)
{
return acpi_core_pic[cpu_logical_map(cpu)].processor_id;
}
+int acpi_get_cpu_uid(unsigned int cpu, u32 *uid);
#endif /* !CONFIG_ACPI */
diff --git a/arch/loongarch/kernel/acpi.c b/arch/loongarch/kernel/acpi.c
index 1367ca759468..058f0dbe8e8f 100644
--- a/arch/loongarch/kernel/acpi.c
+++ b/arch/loongarch/kernel/acpi.c
@@ -385,3 +385,12 @@ 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)
+{
+ if (cpu >= nr_cpu_ids)
+ return -EINVAL;
+ *uid = acpi_core_pic[cpu_logical_map(cpu)].processor_id;
+ return 0;
+}
+EXPORT_SYMBOL_GPL(acpi_get_cpu_uid);
--
2.17.1
^ permalink raw reply related [flat|nested] 14+ messages in thread* [PATCH v9 3/7] riscv/acpi: Add acpi_get_cpu_uid() implementation and update users
2026-03-19 6:57 [PATCH v9 0/7] ACPI: Unify CPU UID interface and fix ARM64 TPH steer-tag issue Chengwen Feng
2026-03-19 6:57 ` [PATCH v9 1/7] arm64/acpi: Add acpi_get_cpu_uid() and switch arm_cspmu to use it Chengwen Feng
2026-03-19 6:57 ` [PATCH v9 2/7] loongarch/acpi: Add acpi_get_cpu_uid() declaration and implementation Chengwen Feng
@ 2026-03-19 6:57 ` Chengwen Feng
2026-03-19 6:57 ` [PATCH v9 4/7] x86/acpi: Add acpi_get_cpu_uid() implementation and update Xen users Chengwen Feng
` (4 subsequent siblings)
7 siblings, 0 replies; 14+ messages in thread
From: Chengwen Feng @ 2026-03-19 6:57 UTC (permalink / raw)
To: Bjorn Helgaas, Catalin Marinas, Will Deacon, Rafael J . Wysocki
Cc: Jonathan Corbet, Shuah Khan, Huacai Chen, WANG Xuerui,
Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
H . Peter Anvin, Juergen Gross, Boris Ostrovsky, Len Brown,
Sunil V L, Mark Rutland, Jonathan Cameron, Kees Cook, Yanteng Si,
Sean Christopherson, Kai Huang, Tom Lendacky, Thomas Huth,
Thorsten Blum, Kevin Loughlin, Zheyun Shen, Peter Zijlstra,
Pawan Gupta, Xin Li, Ahmed S . Darwish, Sohil Mehta,
Ilkka Koskinen, Robin Murphy, James Clark, Besar Wicaksono, Ma Ke,
Wei Huang, Andy Gospodarek, Somnath Kotur, punit.agrawal,
guohanjun, suzuki.poulose, ryan.roberts, chenl311, masahiroy,
wangyuquan1236, anshuman.khandual, heinrich.schuchardt,
Eric.VanTassell, wangzhou1, wanghuiqiang, liuyonglong,
fengchengwen, linux-pci, linux-doc, linux-kernel,
linux-arm-kernel, loongarch, linux-riscv, xen-devel, linux-acpi,
linux-perf-users, stable
Add arch-specific acpi_get_cpu_uid() for riscv:
- Declare acpi_get_cpu_uid() in arch/riscv/include/asm/acpi.h
- Implement acpi_get_cpu_uid() with input parameter validation
- Switch rhct.c and arch/riscv/kernel/acpi_numa.c to use
acpi_get_cpu_uid() instead of get_acpi_id_for_cpu()
This aligns riscv with the unified ACPI CPU UID interface, improving
input validation and consistency across ACPI-enabled platforms.
Cc: stable@vger.kernel.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
---
arch/riscv/include/asm/acpi.h | 1 +
arch/riscv/kernel/acpi.c | 16 ++++++++++++++++
arch/riscv/kernel/acpi_numa.c | 9 ++++++---
drivers/acpi/riscv/rhct.c | 7 ++++++-
4 files changed, 29 insertions(+), 4 deletions(-)
diff --git a/arch/riscv/include/asm/acpi.h b/arch/riscv/include/asm/acpi.h
index 6e13695120bc..f3520cc85af3 100644
--- a/arch/riscv/include/asm/acpi.h
+++ b/arch/riscv/include/asm/acpi.h
@@ -65,6 +65,7 @@ static inline u32 get_acpi_id_for_cpu(int cpu)
{
return acpi_cpu_get_madt_rintc(cpu)->uid;
}
+int acpi_get_cpu_uid(unsigned int cpu, u32 *uid);
int acpi_get_riscv_isa(struct acpi_table_header *table,
unsigned int cpu, const char **isa);
diff --git a/arch/riscv/kernel/acpi.c b/arch/riscv/kernel/acpi.c
index 71698ee11621..322ea92aa39f 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)
+ 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..6a2d4289f806 100644
--- a/arch/riscv/kernel/acpi_numa.c
+++ b/arch/riscv/kernel/acpi_numa.c
@@ -37,11 +37,14 @@ static int __init acpi_numa_get_nid(unsigned int cpu)
static inline int get_cpu_for_acpi_id(u32 uid)
{
- int cpu;
+ u32 cpu_uid;
+ int ret;
- for (cpu = 0; cpu < nr_cpu_ids; cpu++)
- if (uid == get_acpi_id_for_cpu(cpu))
+ 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;
}
diff --git a/drivers/acpi/riscv/rhct.c b/drivers/acpi/riscv/rhct.c
index caa2c16e1697..8f3f38c64a88 100644
--- a/drivers/acpi/riscv/rhct.c
+++ b/drivers/acpi/riscv/rhct.c
@@ -44,10 +44,15 @@ int acpi_get_riscv_isa(struct acpi_table_header *table, unsigned int cpu, const
struct acpi_rhct_isa_string *isa_node;
struct acpi_table_rhct *rhct;
u32 *hart_info_node_offset;
- u32 acpi_cpu_id = get_acpi_id_for_cpu(cpu);
+ u32 acpi_cpu_id;
+ int ret;
BUG_ON(acpi_disabled);
+ ret = acpi_get_cpu_uid(cpu, &acpi_cpu_id);
+ if (ret != 0)
+ return ret;
+
if (!table) {
rhct = acpi_get_rhct();
if (!rhct)
--
2.17.1
^ permalink raw reply related [flat|nested] 14+ messages in thread* [PATCH v9 4/7] x86/acpi: Add acpi_get_cpu_uid() implementation and update Xen users
2026-03-19 6:57 [PATCH v9 0/7] ACPI: Unify CPU UID interface and fix ARM64 TPH steer-tag issue Chengwen Feng
` (2 preceding siblings ...)
2026-03-19 6:57 ` [PATCH v9 3/7] riscv/acpi: Add acpi_get_cpu_uid() implementation and update users Chengwen Feng
@ 2026-03-19 6:57 ` Chengwen Feng
2026-03-19 7:05 ` Jürgen Groß
2026-03-19 6:57 ` [PATCH v9 5/7] ACPI: Centralize acpi_get_cpu_uid() declaration in include/linux/acpi.h Chengwen Feng
` (3 subsequent siblings)
7 siblings, 1 reply; 14+ messages in thread
From: Chengwen Feng @ 2026-03-19 6:57 UTC (permalink / raw)
To: Bjorn Helgaas, Catalin Marinas, Will Deacon, Rafael J . Wysocki
Cc: Jonathan Corbet, Shuah Khan, Huacai Chen, WANG Xuerui,
Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
H . Peter Anvin, Juergen Gross, Boris Ostrovsky, Len Brown,
Sunil V L, Mark Rutland, Jonathan Cameron, Kees Cook, Yanteng Si,
Sean Christopherson, Kai Huang, Tom Lendacky, Thomas Huth,
Thorsten Blum, Kevin Loughlin, Zheyun Shen, Peter Zijlstra,
Pawan Gupta, Xin Li, Ahmed S . Darwish, Sohil Mehta,
Ilkka Koskinen, Robin Murphy, James Clark, Besar Wicaksono, Ma Ke,
Wei Huang, Andy Gospodarek, Somnath Kotur, punit.agrawal,
guohanjun, suzuki.poulose, ryan.roberts, chenl311, masahiroy,
wangyuquan1236, anshuman.khandual, heinrich.schuchardt,
Eric.VanTassell, wangzhou1, wanghuiqiang, liuyonglong,
fengchengwen, linux-pci, linux-doc, linux-kernel,
linux-arm-kernel, loongarch, linux-riscv, xen-devel, linux-acpi,
linux-perf-users, stable
Add arch-specific acpi_get_cpu_uid() for x86:
- Declare acpi_get_cpu_uid() in arch/x86/include/asm/acpi.h
- Implement acpi_get_cpu_uid() with input parameter validation
- Replace cpu_acpi_id() with acpi_get_cpu_uid() in Xen-related code
- Remove the now-unused cpu_acpi_id() function
Extend the unified ACPI CPU UID interface to x86, ensuring consistent
error handling and input validation across all ACPI-enabled
architectures.
Cc: stable@vger.kernel.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
---
arch/x86/include/asm/acpi.h | 2 ++
arch/x86/include/asm/cpu.h | 1 -
arch/x86/include/asm/smp.h | 1 -
arch/x86/kernel/acpi/boot.c | 20 ++++++++++++++++++++
arch/x86/xen/enlighten_hvm.c | 5 +++--
5 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/arch/x86/include/asm/acpi.h b/arch/x86/include/asm/acpi.h
index a03aa6f999d1..92b5c27c4fea 100644
--- a/arch/x86/include/asm/acpi.h
+++ b/arch/x86/include/asm/acpi.h
@@ -157,6 +157,8 @@ static inline bool acpi_has_cpu_in_madt(void)
return !!acpi_lapic;
}
+int acpi_get_cpu_uid(unsigned int cpu, u32 *uid);
+
#define ACPI_HAVE_ARCH_SET_ROOT_POINTER
static __always_inline void acpi_arch_set_root_pointer(u64 addr)
{
diff --git a/arch/x86/include/asm/cpu.h b/arch/x86/include/asm/cpu.h
index ad235dda1ded..57a0786dfd75 100644
--- a/arch/x86/include/asm/cpu.h
+++ b/arch/x86/include/asm/cpu.h
@@ -11,7 +11,6 @@
#ifndef CONFIG_SMP
#define cpu_physical_id(cpu) boot_cpu_physical_apicid
-#define cpu_acpi_id(cpu) 0
#endif /* CONFIG_SMP */
#ifdef CONFIG_HOTPLUG_CPU
diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
index 84951572ab81..05d1d479b4cf 100644
--- a/arch/x86/include/asm/smp.h
+++ b/arch/x86/include/asm/smp.h
@@ -130,7 +130,6 @@ __visible void smp_call_function_interrupt(struct pt_regs *regs);
__visible void smp_call_function_single_interrupt(struct pt_regs *r);
#define cpu_physical_id(cpu) per_cpu(x86_cpu_to_apicid, cpu)
-#define cpu_acpi_id(cpu) per_cpu(x86_cpu_to_acpiid, cpu)
/*
* This function is needed by all SMP systems. It must _always_ be valid
diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index a3f2fb1fea1b..ceba24f65ae3 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -1848,3 +1848,23 @@ void __iomem * (*acpi_os_ioremap)(acpi_physical_address phys, acpi_size size) =
x86_acpi_os_ioremap;
EXPORT_SYMBOL_GPL(acpi_os_ioremap);
#endif
+
+int acpi_get_cpu_uid(unsigned int cpu, u32 *uid)
+{
+ u32 acpi_id;
+
+ if (cpu >= nr_cpu_ids)
+ return -EINVAL;
+
+#ifdef CONFIG_SMP
+ acpi_id = per_cpu(x86_cpu_to_acpiid, cpu);
+ if (acpi_id == CPU_ACPIID_INVALID)
+ return -ENODEV;
+#else
+ acpi_id = 0;
+#endif
+
+ *uid = acpi_id;
+ return 0;
+}
+EXPORT_SYMBOL_GPL(acpi_get_cpu_uid);
diff --git a/arch/x86/xen/enlighten_hvm.c b/arch/x86/xen/enlighten_hvm.c
index fe57ff85d004..2f9fa27e5a3c 100644
--- a/arch/x86/xen/enlighten_hvm.c
+++ b/arch/x86/xen/enlighten_hvm.c
@@ -151,6 +151,7 @@ static void xen_hvm_crash_shutdown(struct pt_regs *regs)
static int xen_cpu_up_prepare_hvm(unsigned int cpu)
{
+ u32 cpu_uid;
int rc = 0;
/*
@@ -161,8 +162,8 @@ static int xen_cpu_up_prepare_hvm(unsigned int cpu)
*/
xen_uninit_lock_cpu(cpu);
- if (cpu_acpi_id(cpu) != CPU_ACPIID_INVALID)
- per_cpu(xen_vcpu_id, cpu) = cpu_acpi_id(cpu);
+ if (acpi_get_cpu_uid(cpu, &cpu_uid) == 0)
+ per_cpu(xen_vcpu_id, cpu) = cpu_uid;
else
per_cpu(xen_vcpu_id, cpu) = cpu;
xen_vcpu_setup(cpu);
--
2.17.1
^ permalink raw reply related [flat|nested] 14+ messages in thread* Re: [PATCH v9 4/7] x86/acpi: Add acpi_get_cpu_uid() implementation and update Xen users
2026-03-19 6:57 ` [PATCH v9 4/7] x86/acpi: Add acpi_get_cpu_uid() implementation and update Xen users Chengwen Feng
@ 2026-03-19 7:05 ` Jürgen Groß
0 siblings, 0 replies; 14+ messages in thread
From: Jürgen Groß @ 2026-03-19 7:05 UTC (permalink / raw)
To: Chengwen Feng, Bjorn Helgaas, Catalin Marinas, Will Deacon,
Rafael J . Wysocki
Cc: Jonathan Corbet, Shuah Khan, Huacai Chen, WANG Xuerui,
Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
H . Peter Anvin, Boris Ostrovsky, Len Brown, Sunil V L,
Mark Rutland, Jonathan Cameron, Kees Cook, Yanteng Si,
Sean Christopherson, Kai Huang, Tom Lendacky, Thomas Huth,
Thorsten Blum, Kevin Loughlin, Zheyun Shen, Peter Zijlstra,
Pawan Gupta, Xin Li, Ahmed S . Darwish, Sohil Mehta,
Ilkka Koskinen, Robin Murphy, James Clark, Besar Wicaksono, Ma Ke,
Wei Huang, Andy Gospodarek, Somnath Kotur, punit.agrawal,
guohanjun, suzuki.poulose, ryan.roberts, chenl311, masahiroy,
wangyuquan1236, anshuman.khandual, heinrich.schuchardt,
Eric.VanTassell, wangzhou1, wanghuiqiang, liuyonglong, linux-pci,
linux-doc, linux-kernel, linux-arm-kernel, loongarch, linux-riscv,
xen-devel, linux-acpi, linux-perf-users, stable
[-- Attachment #1.1.1: Type: text/plain, Size: 714 bytes --]
On 19.03.26 07:57, Chengwen Feng wrote:
> Add arch-specific acpi_get_cpu_uid() for x86:
> - Declare acpi_get_cpu_uid() in arch/x86/include/asm/acpi.h
> - Implement acpi_get_cpu_uid() with input parameter validation
> - Replace cpu_acpi_id() with acpi_get_cpu_uid() in Xen-related code
> - Remove the now-unused cpu_acpi_id() function
>
> Extend the unified ACPI CPU UID interface to x86, ensuring consistent
> error handling and input validation across all ACPI-enabled
> architectures.
>
> Cc: stable@vger.kernel.org
> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
> Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
Juergen
[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 3743 bytes --]
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v9 5/7] ACPI: Centralize acpi_get_cpu_uid() declaration in include/linux/acpi.h
2026-03-19 6:57 [PATCH v9 0/7] ACPI: Unify CPU UID interface and fix ARM64 TPH steer-tag issue Chengwen Feng
` (3 preceding siblings ...)
2026-03-19 6:57 ` [PATCH v9 4/7] x86/acpi: Add acpi_get_cpu_uid() implementation and update Xen users Chengwen Feng
@ 2026-03-19 6:57 ` Chengwen Feng
2026-03-19 6:57 ` [PATCH v9 6/7] ACPI: PPTT: Use acpi_get_cpu_uid() and remove get_acpi_id_for_cpu() Chengwen Feng
` (2 subsequent siblings)
7 siblings, 0 replies; 14+ messages in thread
From: Chengwen Feng @ 2026-03-19 6:57 UTC (permalink / raw)
To: Bjorn Helgaas, Catalin Marinas, Will Deacon, Rafael J . Wysocki
Cc: Jonathan Corbet, Shuah Khan, Huacai Chen, WANG Xuerui,
Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
H . Peter Anvin, Juergen Gross, Boris Ostrovsky, Len Brown,
Sunil V L, Mark Rutland, Jonathan Cameron, Kees Cook, Yanteng Si,
Sean Christopherson, Kai Huang, Tom Lendacky, Thomas Huth,
Thorsten Blum, Kevin Loughlin, Zheyun Shen, Peter Zijlstra,
Pawan Gupta, Xin Li, Ahmed S . Darwish, Sohil Mehta,
Ilkka Koskinen, Robin Murphy, James Clark, Besar Wicaksono, Ma Ke,
Wei Huang, Andy Gospodarek, Somnath Kotur, punit.agrawal,
guohanjun, suzuki.poulose, ryan.roberts, chenl311, masahiroy,
wangyuquan1236, anshuman.khandual, heinrich.schuchardt,
Eric.VanTassell, wangzhou1, wanghuiqiang, liuyonglong,
fengchengwen, linux-pci, linux-doc, linux-kernel,
linux-arm-kernel, loongarch, linux-riscv, xen-devel, linux-acpi,
linux-perf-users, stable
- Add acpi_get_cpu_uid() prototype to include/linux/acpi.h (global
scope)
- Remove arch-specific acpi_get_cpu_uid() declarations from
arm64/loongarch/riscv/x86 asm/acpi.h
This centralizes the interface declaration for consistency, avoiding
duplicate prototypes across architectures and simplifying future
maintenance.
Cc: stable@vger.kernel.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
---
arch/arm64/include/asm/acpi.h | 1 -
arch/loongarch/include/asm/acpi.h | 1 -
arch/riscv/include/asm/acpi.h | 1 -
arch/x86/include/asm/acpi.h | 2 --
include/linux/acpi.h | 11 +++++++++++
5 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h
index 2219a3301e72..bdb0ecf95b5c 100644
--- a/arch/arm64/include/asm/acpi.h
+++ b/arch/arm64/include/asm/acpi.h
@@ -118,7 +118,6 @@ static inline u32 get_acpi_id_for_cpu(unsigned int cpu)
{
return acpi_cpu_get_madt_gicc(cpu)->uid;
}
-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) { }
diff --git a/arch/loongarch/include/asm/acpi.h b/arch/loongarch/include/asm/acpi.h
index 8bb101b4557e..7376840fa9f7 100644
--- a/arch/loongarch/include/asm/acpi.h
+++ b/arch/loongarch/include/asm/acpi.h
@@ -44,7 +44,6 @@ static inline u32 get_acpi_id_for_cpu(unsigned int cpu)
{
return acpi_core_pic[cpu_logical_map(cpu)].processor_id;
}
-int acpi_get_cpu_uid(unsigned int cpu, u32 *uid);
#endif /* !CONFIG_ACPI */
diff --git a/arch/riscv/include/asm/acpi.h b/arch/riscv/include/asm/acpi.h
index f3520cc85af3..6e13695120bc 100644
--- a/arch/riscv/include/asm/acpi.h
+++ b/arch/riscv/include/asm/acpi.h
@@ -65,7 +65,6 @@ static inline u32 get_acpi_id_for_cpu(int cpu)
{
return acpi_cpu_get_madt_rintc(cpu)->uid;
}
-int acpi_get_cpu_uid(unsigned int cpu, u32 *uid);
int acpi_get_riscv_isa(struct acpi_table_header *table,
unsigned int cpu, const char **isa);
diff --git a/arch/x86/include/asm/acpi.h b/arch/x86/include/asm/acpi.h
index 92b5c27c4fea..a03aa6f999d1 100644
--- a/arch/x86/include/asm/acpi.h
+++ b/arch/x86/include/asm/acpi.h
@@ -157,8 +157,6 @@ static inline bool acpi_has_cpu_in_madt(void)
return !!acpi_lapic;
}
-int acpi_get_cpu_uid(unsigned int cpu, u32 *uid);
-
#define ACPI_HAVE_ARCH_SET_ROOT_POINTER
static __always_inline void acpi_arch_set_root_pointer(u64 addr)
{
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 4d2f0bed7a06..74a73f0e5944 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -324,6 +324,17 @@ int acpi_unmap_cpu(int cpu);
acpi_handle acpi_get_processor_handle(int cpu);
+/**
+ * acpi_get_cpu_uid() - Get ACPI Processor UID of from MADT table
+ * @cpu: Logical CPU number (0-based)
+ * @uid: Pointer to store ACPI Processor UID
+ *
+ * Return: 0 on success (ACPI Processor ID stored in *uid);
+ * -EINVAL if CPU number is invalid or out of range;
+ * -ENODEV if ACPI Processor UID for the CPU is not found.
+ */
+int acpi_get_cpu_uid(unsigned int cpu, u32 *uid);
+
#ifdef CONFIG_ACPI_HOTPLUG_IOAPIC
int acpi_get_ioapic_id(acpi_handle handle, u32 gsi_base, u64 *phys_addr);
#endif
--
2.17.1
^ permalink raw reply related [flat|nested] 14+ messages in thread* [PATCH v9 6/7] ACPI: PPTT: Use acpi_get_cpu_uid() and remove get_acpi_id_for_cpu()
2026-03-19 6:57 [PATCH v9 0/7] ACPI: Unify CPU UID interface and fix ARM64 TPH steer-tag issue Chengwen Feng
` (4 preceding siblings ...)
2026-03-19 6:57 ` [PATCH v9 5/7] ACPI: Centralize acpi_get_cpu_uid() declaration in include/linux/acpi.h Chengwen Feng
@ 2026-03-19 6:57 ` Chengwen Feng
2026-03-19 6:57 ` [PATCH v9 7/7] PCI/TPH: Fix get cpu steer-tag fail on ARM64 platform Chengwen Feng
2026-03-19 10:58 ` [PATCH v9 0/7] ACPI: Unify CPU UID interface and fix ARM64 TPH steer-tag issue Jonathan Cameron
7 siblings, 0 replies; 14+ messages in thread
From: Chengwen Feng @ 2026-03-19 6:57 UTC (permalink / raw)
To: Bjorn Helgaas, Catalin Marinas, Will Deacon, Rafael J . Wysocki
Cc: Jonathan Corbet, Shuah Khan, Huacai Chen, WANG Xuerui,
Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
H . Peter Anvin, Juergen Gross, Boris Ostrovsky, Len Brown,
Sunil V L, Mark Rutland, Jonathan Cameron, Kees Cook, Yanteng Si,
Sean Christopherson, Kai Huang, Tom Lendacky, Thomas Huth,
Thorsten Blum, Kevin Loughlin, Zheyun Shen, Peter Zijlstra,
Pawan Gupta, Xin Li, Ahmed S . Darwish, Sohil Mehta,
Ilkka Koskinen, Robin Murphy, James Clark, Besar Wicaksono, Ma Ke,
Wei Huang, Andy Gospodarek, Somnath Kotur, punit.agrawal,
guohanjun, suzuki.poulose, ryan.roberts, chenl311, masahiroy,
wangyuquan1236, anshuman.khandual, heinrich.schuchardt,
Eric.VanTassell, wangzhou1, wanghuiqiang, liuyonglong,
fengchengwen, linux-pci, linux-doc, linux-kernel,
linux-arm-kernel, loongarch, linux-riscv, xen-devel, linux-acpi,
linux-perf-users, stable
- Convert acpi/pptt.c to use acpi_get_cpu_uid() instead of
get_acpi_id_for_cpu()
- Remove unused get_acpi_id_for_cpu() implementations from
arm64/loongarch/riscv
This completes the migration to the unified ACPI CPU UID interface for
PPTT code, and cleans up legacy unused functions to reduce technical
debt.
Cc: stable@vger.kernel.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
---
arch/arm64/include/asm/acpi.h | 4 ---
arch/loongarch/include/asm/acpi.h | 5 ----
arch/riscv/include/asm/acpi.h | 4 ---
drivers/acpi/pptt.c | 50 +++++++++++++++++++++++--------
4 files changed, 37 insertions(+), 26 deletions(-)
diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h
index bdb0ecf95b5c..8a54ca6ba602 100644
--- a/arch/arm64/include/asm/acpi.h
+++ b/arch/arm64/include/asm/acpi.h
@@ -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) { }
diff --git a/arch/loongarch/include/asm/acpi.h b/arch/loongarch/include/asm/acpi.h
index 7376840fa9f7..eda9d4d0a493 100644
--- a/arch/loongarch/include/asm/acpi.h
+++ b/arch/loongarch/include/asm/acpi.h
@@ -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
diff --git a/arch/riscv/include/asm/acpi.h b/arch/riscv/include/asm/acpi.h
index 6e13695120bc..26ab37c171bc 100644
--- a/arch/riscv/include/asm/acpi.h
+++ b/arch/riscv/include/asm/acpi.h
@@ -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);
diff --git a/drivers/acpi/pptt.c b/drivers/acpi/pptt.c
index de5f8c018333..7bd5bc1f225a 100644
--- a/drivers/acpi/pptt.c
+++ b/drivers/acpi/pptt.c
@@ -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;
--
2.17.1
^ permalink raw reply related [flat|nested] 14+ messages in thread* [PATCH v9 7/7] PCI/TPH: Fix get cpu steer-tag fail on ARM64 platform
2026-03-19 6:57 [PATCH v9 0/7] ACPI: Unify CPU UID interface and fix ARM64 TPH steer-tag issue Chengwen Feng
` (5 preceding siblings ...)
2026-03-19 6:57 ` [PATCH v9 6/7] ACPI: PPTT: Use acpi_get_cpu_uid() and remove get_acpi_id_for_cpu() Chengwen Feng
@ 2026-03-19 6:57 ` Chengwen Feng
2026-03-19 18:32 ` Bjorn Helgaas
2026-03-19 10:58 ` [PATCH v9 0/7] ACPI: Unify CPU UID interface and fix ARM64 TPH steer-tag issue Jonathan Cameron
7 siblings, 1 reply; 14+ messages in thread
From: Chengwen Feng @ 2026-03-19 6:57 UTC (permalink / raw)
To: Bjorn Helgaas, Catalin Marinas, Will Deacon, Rafael J . Wysocki
Cc: Jonathan Corbet, Shuah Khan, Huacai Chen, WANG Xuerui,
Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
H . Peter Anvin, Juergen Gross, Boris Ostrovsky, Len Brown,
Sunil V L, Mark Rutland, Jonathan Cameron, Kees Cook, Yanteng Si,
Sean Christopherson, Kai Huang, Tom Lendacky, Thomas Huth,
Thorsten Blum, Kevin Loughlin, Zheyun Shen, Peter Zijlstra,
Pawan Gupta, Xin Li, Ahmed S . Darwish, Sohil Mehta,
Ilkka Koskinen, Robin Murphy, James Clark, Besar Wicaksono, Ma Ke,
Wei Huang, Andy Gospodarek, Somnath Kotur, punit.agrawal,
guohanjun, suzuki.poulose, ryan.roberts, chenl311, masahiroy,
wangyuquan1236, anshuman.khandual, heinrich.schuchardt,
Eric.VanTassell, wangzhou1, wanghuiqiang, liuyonglong,
fengchengwen, linux-pci, linux-doc, linux-kernel,
linux-arm-kernel, loongarch, linux-riscv, xen-devel, linux-acpi,
linux-perf-users, stable
pcie_tph_get_cpu_st() is broken on ARM64:
1. pcie_tph_get_cpu_st() passes cpu_uid to the PCI ACPI DSM method.
cpu_uid should be the ACPI Processor UID [1].
2. In BNXT, pcie_tph_get_cpu_st() is passed a cpu_uid obtained via
cpumask_first(irq->cpu_mask) - the logical CPU ID of a CPU core,
generated and managed by kernel (e.g., [0,255] for a system with 256
logical CPU cores).
3. On ARM64 platforms, ACPI assigns Processor UID to cores listed in the
MADT table, and this UID may not match the kernel's logical CPU ID.
When this occurs, the mismatch results in the wrong CPU steer-tag.
4. On AMD x86 the logical CPU ID is identical to the ACPI Processor UID
so the mismatch is not seen.
Resolution:
1. Use acpi_get_cpu_uid() in pcie_tph_get_cpu_st() to translate from
logical CPU ID to ACPI Processor UID needed for the DSM call.
2. Rename pcie_tpu_get_cpu_st() parameter from cpu_uid to cpu to
reflect that it is a logical CPU_ID.
[1] According to ECN_TPH-ST_Revision_20200924
(https://members.pcisig.com/wg/PCI-SIG/document/15470), the input
is defined as: "If the target is a processor, then this field
represents the ACPI Processor UID of the processor as specified in
the MADT. If the target is a processor container, then this field
represents the ACPI Processor UID of the processor container as
specified in the PPTT."
Fixes: d2e8a34876ce ("PCI/TPH: Add Steering Tag support")
Cc: stable@vger.kernel.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
---
Documentation/PCI/tph.rst | 4 ++--
drivers/pci/tph.c | 16 +++++++++++-----
include/linux/pci-tph.h | 4 ++--
3 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/Documentation/PCI/tph.rst b/Documentation/PCI/tph.rst
index e8993be64fd6..b6cf22b9bd90 100644
--- a/Documentation/PCI/tph.rst
+++ b/Documentation/PCI/tph.rst
@@ -79,10 +79,10 @@ To retrieve a Steering Tag for a target memory associated with a specific
CPU, use the following function::
int pcie_tph_get_cpu_st(struct pci_dev *pdev, enum tph_mem_type type,
- unsigned int cpu_uid, u16 *tag);
+ unsigned int cpu, u16 *tag);
The `type` argument is used to specify the memory type, either volatile
-or persistent, of the target memory. The `cpu_uid` argument specifies the
+or persistent, of the target memory. The `cpu` argument specifies the
CPU where the memory is associated to.
After the ST value is retrieved, the device driver can use the following
diff --git a/drivers/pci/tph.c b/drivers/pci/tph.c
index ca4f97be7538..b67c9ad14bda 100644
--- a/drivers/pci/tph.c
+++ b/drivers/pci/tph.c
@@ -236,21 +236,27 @@ static int write_tag_to_st_table(struct pci_dev *pdev, int index, u16 tag)
* with a specific CPU
* @pdev: PCI device
* @mem_type: target memory type (volatile or persistent RAM)
- * @cpu_uid: associated CPU id
+ * @cpu: associated CPU id
* @tag: Steering Tag to be returned
*
* Return the Steering Tag for a target memory that is associated with a
- * specific CPU as indicated by cpu_uid.
+ * specific CPU as indicated by cpu.
*
* Return: 0 if success, otherwise negative value (-errno)
*/
int pcie_tph_get_cpu_st(struct pci_dev *pdev, enum tph_mem_type mem_type,
- unsigned int cpu_uid, u16 *tag)
+ unsigned int cpu, u16 *tag)
{
#ifdef CONFIG_ACPI
struct pci_dev *rp;
acpi_handle rp_acpi_handle;
union st_info info;
+ u32 cpu_uid;
+ int ret;
+
+ ret = acpi_get_cpu_uid(cpu, &cpu_uid);
+ if (ret != 0)
+ return ret;
rp = pcie_find_root_port(pdev);
if (!rp || !rp->bus || !rp->bus->bridge)
@@ -265,9 +271,9 @@ int pcie_tph_get_cpu_st(struct pci_dev *pdev, enum tph_mem_type mem_type,
*tag = tph_extract_tag(mem_type, pdev->tph_req_type, &info);
- pci_dbg(pdev, "get steering tag: mem_type=%s, cpu_uid=%d, tag=%#04x\n",
+ pci_dbg(pdev, "get steering tag: mem_type=%s, cpu=%d, tag=%#04x\n",
(mem_type == TPH_MEM_TYPE_VM) ? "volatile" : "persistent",
- cpu_uid, *tag);
+ cpu, *tag);
return 0;
#else
diff --git a/include/linux/pci-tph.h b/include/linux/pci-tph.h
index ba28140ce670..be68cd17f2f8 100644
--- a/include/linux/pci-tph.h
+++ b/include/linux/pci-tph.h
@@ -25,7 +25,7 @@ int pcie_tph_set_st_entry(struct pci_dev *pdev,
unsigned int index, u16 tag);
int pcie_tph_get_cpu_st(struct pci_dev *dev,
enum tph_mem_type mem_type,
- unsigned int cpu_uid, u16 *tag);
+ unsigned int cpu, u16 *tag);
void pcie_disable_tph(struct pci_dev *pdev);
int pcie_enable_tph(struct pci_dev *pdev, int mode);
u16 pcie_tph_get_st_table_size(struct pci_dev *pdev);
@@ -36,7 +36,7 @@ static inline int pcie_tph_set_st_entry(struct pci_dev *pdev,
{ return -EINVAL; }
static inline int pcie_tph_get_cpu_st(struct pci_dev *dev,
enum tph_mem_type mem_type,
- unsigned int cpu_uid, u16 *tag)
+ unsigned int cpu, u16 *tag)
{ return -EINVAL; }
static inline void pcie_disable_tph(struct pci_dev *pdev) { }
static inline int pcie_enable_tph(struct pci_dev *pdev, int mode)
--
2.17.1
^ permalink raw reply related [flat|nested] 14+ messages in thread* Re: [PATCH v9 7/7] PCI/TPH: Fix get cpu steer-tag fail on ARM64 platform
2026-03-19 6:57 ` [PATCH v9 7/7] PCI/TPH: Fix get cpu steer-tag fail on ARM64 platform Chengwen Feng
@ 2026-03-19 18:32 ` Bjorn Helgaas
2026-03-20 3:26 ` fengchengwen
0 siblings, 1 reply; 14+ messages in thread
From: Bjorn Helgaas @ 2026-03-19 18:32 UTC (permalink / raw)
To: Chengwen Feng
Cc: Bjorn Helgaas, Catalin Marinas, Will Deacon, Rafael J . Wysocki,
Jonathan Corbet, Shuah Khan, Huacai Chen, WANG Xuerui,
Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
H . Peter Anvin, Juergen Gross, Boris Ostrovsky, Len Brown,
Sunil V L, Mark Rutland, Jonathan Cameron, Kees Cook, Yanteng Si,
Sean Christopherson, Kai Huang, Tom Lendacky, Thomas Huth,
Thorsten Blum, Kevin Loughlin, Zheyun Shen, Peter Zijlstra,
Pawan Gupta, Xin Li, Ahmed S . Darwish, Sohil Mehta,
Ilkka Koskinen, Robin Murphy, James Clark, Besar Wicaksono, Ma Ke,
Wei Huang, Andy Gospodarek, Somnath Kotur, punit.agrawal,
guohanjun, suzuki.poulose, ryan.roberts, chenl311, masahiroy,
wangyuquan1236, anshuman.khandual, heinrich.schuchardt,
Eric.VanTassell, wangzhou1, wanghuiqiang, liuyonglong, linux-pci,
linux-doc, linux-kernel, linux-arm-kernel, loongarch, linux-riscv,
xen-devel, linux-acpi, linux-perf-users, stable
Let's make the subject a little more specific, e.g.,
PCI/TPH: Pass ACPI Processor UID to Cache Locality _DSM
On Thu, Mar 19, 2026 at 02:57:35PM +0800, Chengwen Feng wrote:
> pcie_tph_get_cpu_st() is broken on ARM64:
> 1. pcie_tph_get_cpu_st() passes cpu_uid to the PCI ACPI DSM method.
> cpu_uid should be the ACPI Processor UID [1].
> 2. In BNXT, pcie_tph_get_cpu_st() is passed a cpu_uid obtained via
> cpumask_first(irq->cpu_mask) - the logical CPU ID of a CPU core,
> generated and managed by kernel (e.g., [0,255] for a system with 256
> logical CPU cores).
> 3. On ARM64 platforms, ACPI assigns Processor UID to cores listed in the
> MADT table, and this UID may not match the kernel's logical CPU ID.
> When this occurs, the mismatch results in the wrong CPU steer-tag.
> 4. On AMD x86 the logical CPU ID is identical to the ACPI Processor UID
> so the mismatch is not seen.
>
> Resolution:
> 1. Use acpi_get_cpu_uid() in pcie_tph_get_cpu_st() to translate from
> logical CPU ID to ACPI Processor UID needed for the DSM call.
> 2. Rename pcie_tpu_get_cpu_st() parameter from cpu_uid to cpu to
> reflect that it is a logical CPU_ID.
And simplify this, e.g.,
pcie_tph_get_cpu_st() uses the Query Cache Locality Features _DSM
[1] to retrieve the TPH Steering Tag for memory associated with the
CPU identified by its "cpu_uid" parameter, a Linux logical CPU ID.
The _DSM requires a ACPI Processor UID, which pcie_tph_get_cpu_st()
previously assumed was the same as the Linux logical CPU ID. This
is true on x86 but not on arm64, so pcie_tph_get_cpu_st() failed on
arm64.
Convert the Linux logical CPU ID to the ACPI Processor UID with
acpi_get_cpu_uid() before passing it to the _DSM.
If there's a specific error message from BNXT or similar that is a
symptom of this problem, it'd be nice to include that. Or if the
problem was just poor performance because the _DSM returned the wrong
Steering Tag, you could say something like:
... so pcie_tph_get_cpu_st() returned the wrong Steering Tag,
resulting in poor network performance.
> [1] According to ECN_TPH-ST_Revision_20200924
> (https://members.pcisig.com/wg/PCI-SIG/document/15470), the input
> is defined as: "If the target is a processor, then this field
> represents the ACPI Processor UID of the processor as specified in
> the MADT. If the target is a processor container, then this field
> represents the ACPI Processor UID of the processor container as
> specified in the PPTT."
>
> Fixes: d2e8a34876ce ("PCI/TPH: Add Steering Tag support")
> Cc: stable@vger.kernel.org
> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
> Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
The patch looks good to me. Thanks for all your work on this!
Reviewed-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
> Documentation/PCI/tph.rst | 4 ++--
> drivers/pci/tph.c | 16 +++++++++++-----
> include/linux/pci-tph.h | 4 ++--
> 3 files changed, 15 insertions(+), 9 deletions(-)
>
> diff --git a/Documentation/PCI/tph.rst b/Documentation/PCI/tph.rst
> index e8993be64fd6..b6cf22b9bd90 100644
> --- a/Documentation/PCI/tph.rst
> +++ b/Documentation/PCI/tph.rst
> @@ -79,10 +79,10 @@ To retrieve a Steering Tag for a target memory associated with a specific
> CPU, use the following function::
>
> int pcie_tph_get_cpu_st(struct pci_dev *pdev, enum tph_mem_type type,
> - unsigned int cpu_uid, u16 *tag);
> + unsigned int cpu, u16 *tag);
>
> The `type` argument is used to specify the memory type, either volatile
> -or persistent, of the target memory. The `cpu_uid` argument specifies the
> +or persistent, of the target memory. The `cpu` argument specifies the
> CPU where the memory is associated to.
>
> After the ST value is retrieved, the device driver can use the following
> diff --git a/drivers/pci/tph.c b/drivers/pci/tph.c
> index ca4f97be7538..b67c9ad14bda 100644
> --- a/drivers/pci/tph.c
> +++ b/drivers/pci/tph.c
> @@ -236,21 +236,27 @@ static int write_tag_to_st_table(struct pci_dev *pdev, int index, u16 tag)
> * with a specific CPU
> * @pdev: PCI device
> * @mem_type: target memory type (volatile or persistent RAM)
> - * @cpu_uid: associated CPU id
> + * @cpu: associated CPU id
> * @tag: Steering Tag to be returned
> *
> * Return the Steering Tag for a target memory that is associated with a
> - * specific CPU as indicated by cpu_uid.
> + * specific CPU as indicated by cpu.
> *
> * Return: 0 if success, otherwise negative value (-errno)
> */
> int pcie_tph_get_cpu_st(struct pci_dev *pdev, enum tph_mem_type mem_type,
> - unsigned int cpu_uid, u16 *tag)
> + unsigned int cpu, u16 *tag)
> {
> #ifdef CONFIG_ACPI
> struct pci_dev *rp;
> acpi_handle rp_acpi_handle;
> union st_info info;
> + u32 cpu_uid;
> + int ret;
> +
> + ret = acpi_get_cpu_uid(cpu, &cpu_uid);
> + if (ret != 0)
> + return ret;
>
> rp = pcie_find_root_port(pdev);
> if (!rp || !rp->bus || !rp->bus->bridge)
> @@ -265,9 +271,9 @@ int pcie_tph_get_cpu_st(struct pci_dev *pdev, enum tph_mem_type mem_type,
>
> *tag = tph_extract_tag(mem_type, pdev->tph_req_type, &info);
>
> - pci_dbg(pdev, "get steering tag: mem_type=%s, cpu_uid=%d, tag=%#04x\n",
> + pci_dbg(pdev, "get steering tag: mem_type=%s, cpu=%d, tag=%#04x\n",
> (mem_type == TPH_MEM_TYPE_VM) ? "volatile" : "persistent",
> - cpu_uid, *tag);
> + cpu, *tag);
>
> return 0;
> #else
> diff --git a/include/linux/pci-tph.h b/include/linux/pci-tph.h
> index ba28140ce670..be68cd17f2f8 100644
> --- a/include/linux/pci-tph.h
> +++ b/include/linux/pci-tph.h
> @@ -25,7 +25,7 @@ int pcie_tph_set_st_entry(struct pci_dev *pdev,
> unsigned int index, u16 tag);
> int pcie_tph_get_cpu_st(struct pci_dev *dev,
> enum tph_mem_type mem_type,
> - unsigned int cpu_uid, u16 *tag);
> + unsigned int cpu, u16 *tag);
> void pcie_disable_tph(struct pci_dev *pdev);
> int pcie_enable_tph(struct pci_dev *pdev, int mode);
> u16 pcie_tph_get_st_table_size(struct pci_dev *pdev);
> @@ -36,7 +36,7 @@ static inline int pcie_tph_set_st_entry(struct pci_dev *pdev,
> { return -EINVAL; }
> static inline int pcie_tph_get_cpu_st(struct pci_dev *dev,
> enum tph_mem_type mem_type,
> - unsigned int cpu_uid, u16 *tag)
> + unsigned int cpu, u16 *tag)
> { return -EINVAL; }
> static inline void pcie_disable_tph(struct pci_dev *pdev) { }
> static inline int pcie_enable_tph(struct pci_dev *pdev, int mode)
> --
> 2.17.1
>
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH v9 7/7] PCI/TPH: Fix get cpu steer-tag fail on ARM64 platform
2026-03-19 18:32 ` Bjorn Helgaas
@ 2026-03-20 3:26 ` fengchengwen
0 siblings, 0 replies; 14+ messages in thread
From: fengchengwen @ 2026-03-20 3:26 UTC (permalink / raw)
To: Bjorn Helgaas
Cc: Bjorn Helgaas, Catalin Marinas, Will Deacon, Rafael J . Wysocki,
Jonathan Corbet, Shuah Khan, Huacai Chen, WANG Xuerui,
Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
H . Peter Anvin, Juergen Gross, Boris Ostrovsky, Len Brown,
Sunil V L, Mark Rutland, Jonathan Cameron, Kees Cook, Yanteng Si,
Sean Christopherson, Kai Huang, Tom Lendacky, Thomas Huth,
Thorsten Blum, Kevin Loughlin, Zheyun Shen, Peter Zijlstra,
Pawan Gupta, Xin Li, Ahmed S . Darwish, Sohil Mehta,
Ilkka Koskinen, Robin Murphy, James Clark, Besar Wicaksono, Ma Ke,
Wei Huang, Andy Gospodarek, Somnath Kotur, punit.agrawal,
guohanjun, suzuki.poulose, ryan.roberts, chenl311, masahiroy,
wangyuquan1236, anshuman.khandual, heinrich.schuchardt,
Eric.VanTassell, wangzhou1, wanghuiqiang, liuyonglong, linux-pci,
linux-doc, linux-kernel, linux-arm-kernel, loongarch, linux-riscv,
xen-devel, linux-acpi, linux-perf-users, stable
On 3/20/2026 2:32 AM, Bjorn Helgaas wrote:
> Let's make the subject a little more specific, e.g.,
>
> PCI/TPH: Pass ACPI Processor UID to Cache Locality _DSM
done in v10
>
> On Thu, Mar 19, 2026 at 02:57:35PM +0800, Chengwen Feng wrote:
>> pcie_tph_get_cpu_st() is broken on ARM64:
>> 1. pcie_tph_get_cpu_st() passes cpu_uid to the PCI ACPI DSM method.
>> cpu_uid should be the ACPI Processor UID [1].
>> 2. In BNXT, pcie_tph_get_cpu_st() is passed a cpu_uid obtained via
>> cpumask_first(irq->cpu_mask) - the logical CPU ID of a CPU core,
>> generated and managed by kernel (e.g., [0,255] for a system with 256
>> logical CPU cores).
>> 3. On ARM64 platforms, ACPI assigns Processor UID to cores listed in the
>> MADT table, and this UID may not match the kernel's logical CPU ID.
>> When this occurs, the mismatch results in the wrong CPU steer-tag.
>> 4. On AMD x86 the logical CPU ID is identical to the ACPI Processor UID
>> so the mismatch is not seen.
>>
>> Resolution:
>> 1. Use acpi_get_cpu_uid() in pcie_tph_get_cpu_st() to translate from
>> logical CPU ID to ACPI Processor UID needed for the DSM call.
>> 2. Rename pcie_tpu_get_cpu_st() parameter from cpu_uid to cpu to
>> reflect that it is a logical CPU_ID.
>
> And simplify this, e.g.,
>
> pcie_tph_get_cpu_st() uses the Query Cache Locality Features _DSM
> [1] to retrieve the TPH Steering Tag for memory associated with the
> CPU identified by its "cpu_uid" parameter, a Linux logical CPU ID.
>
> The _DSM requires a ACPI Processor UID, which pcie_tph_get_cpu_st()
> previously assumed was the same as the Linux logical CPU ID. This
> is true on x86 but not on arm64, so pcie_tph_get_cpu_st() failed on
> arm64.
>
> Convert the Linux logical CPU ID to the ACPI Processor UID with
> acpi_get_cpu_uid() before passing it to the _DSM.
>
> If there's a specific error message from BNXT or similar that is a
> symptom of this problem, it'd be nice to include that. Or if the
> problem was just poor performance because the _DSM returned the wrong
> Steering Tag, you could say something like:
>
> ... so pcie_tph_get_cpu_st() returned the wrong Steering Tag,
> resulting in poor network performance.
It is indeed simplified, done in v10
>
>> [1] According to ECN_TPH-ST_Revision_20200924
>> (https://members.pcisig.com/wg/PCI-SIG/document/15470), the input
>> is defined as: "If the target is a processor, then this field
>> represents the ACPI Processor UID of the processor as specified in
>> the MADT. If the target is a processor container, then this field
>> represents the ACPI Processor UID of the processor container as
>> specified in the PPTT."
>>
>> Fixes: d2e8a34876ce ("PCI/TPH: Add Steering Tag support")
>> Cc: stable@vger.kernel.org
>> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
>> Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
>
> The patch looks good to me. Thanks for all your work on this!
>
> Reviewed-by: Bjorn Helgaas <bhelgaas@google.com>
Thanks Bjorn for your review and kind words! I really appreciate it.
>
>> ---
>> Documentation/PCI/tph.rst | 4 ++--
>> drivers/pci/tph.c | 16 +++++++++++-----
>> include/linux/pci-tph.h | 4 ++--
>> 3 files changed, 15 insertions(+), 9 deletions(-)
>>
>> diff --git a/Documentation/PCI/tph.rst b/Documentation/PCI/tph.rst
>> index e8993be64fd6..b6cf22b9bd90 100644
>> --- a/Documentation/PCI/tph.rst
>> +++ b/Documentation/PCI/tph.rst
>> @@ -79,10 +79,10 @@ To retrieve a Steering Tag for a target memory associated with a specific
>> CPU, use the following function::
>>
>> int pcie_tph_get_cpu_st(struct pci_dev *pdev, enum tph_mem_type type,
>> - unsigned int cpu_uid, u16 *tag);
>> + unsigned int cpu, u16 *tag);
>>
>> The `type` argument is used to specify the memory type, either volatile
>> -or persistent, of the target memory. The `cpu_uid` argument specifies the
>> +or persistent, of the target memory. The `cpu` argument specifies the
>> CPU where the memory is associated to.
>>
>> After the ST value is retrieved, the device driver can use the following
>> diff --git a/drivers/pci/tph.c b/drivers/pci/tph.c
>> index ca4f97be7538..b67c9ad14bda 100644
>> --- a/drivers/pci/tph.c
>> +++ b/drivers/pci/tph.c
>> @@ -236,21 +236,27 @@ static int write_tag_to_st_table(struct pci_dev *pdev, int index, u16 tag)
>> * with a specific CPU
>> * @pdev: PCI device
>> * @mem_type: target memory type (volatile or persistent RAM)
>> - * @cpu_uid: associated CPU id
>> + * @cpu: associated CPU id
>> * @tag: Steering Tag to be returned
>> *
>> * Return the Steering Tag for a target memory that is associated with a
>> - * specific CPU as indicated by cpu_uid.
>> + * specific CPU as indicated by cpu.
>> *
>> * Return: 0 if success, otherwise negative value (-errno)
>> */
>> int pcie_tph_get_cpu_st(struct pci_dev *pdev, enum tph_mem_type mem_type,
>> - unsigned int cpu_uid, u16 *tag)
>> + unsigned int cpu, u16 *tag)
>> {
>> #ifdef CONFIG_ACPI
>> struct pci_dev *rp;
>> acpi_handle rp_acpi_handle;
>> union st_info info;
>> + u32 cpu_uid;
>> + int ret;
>> +
>> + ret = acpi_get_cpu_uid(cpu, &cpu_uid);
>> + if (ret != 0)
>> + return ret;
>>
>> rp = pcie_find_root_port(pdev);
>> if (!rp || !rp->bus || !rp->bus->bridge)
>> @@ -265,9 +271,9 @@ int pcie_tph_get_cpu_st(struct pci_dev *pdev, enum tph_mem_type mem_type,
>>
>> *tag = tph_extract_tag(mem_type, pdev->tph_req_type, &info);
>>
>> - pci_dbg(pdev, "get steering tag: mem_type=%s, cpu_uid=%d, tag=%#04x\n",
>> + pci_dbg(pdev, "get steering tag: mem_type=%s, cpu=%d, tag=%#04x\n",
>> (mem_type == TPH_MEM_TYPE_VM) ? "volatile" : "persistent",
>> - cpu_uid, *tag);
>> + cpu, *tag);
>>
>> return 0;
>> #else
>> diff --git a/include/linux/pci-tph.h b/include/linux/pci-tph.h
>> index ba28140ce670..be68cd17f2f8 100644
>> --- a/include/linux/pci-tph.h
>> +++ b/include/linux/pci-tph.h
>> @@ -25,7 +25,7 @@ int pcie_tph_set_st_entry(struct pci_dev *pdev,
>> unsigned int index, u16 tag);
>> int pcie_tph_get_cpu_st(struct pci_dev *dev,
>> enum tph_mem_type mem_type,
>> - unsigned int cpu_uid, u16 *tag);
>> + unsigned int cpu, u16 *tag);
>> void pcie_disable_tph(struct pci_dev *pdev);
>> int pcie_enable_tph(struct pci_dev *pdev, int mode);
>> u16 pcie_tph_get_st_table_size(struct pci_dev *pdev);
>> @@ -36,7 +36,7 @@ static inline int pcie_tph_set_st_entry(struct pci_dev *pdev,
>> { return -EINVAL; }
>> static inline int pcie_tph_get_cpu_st(struct pci_dev *dev,
>> enum tph_mem_type mem_type,
>> - unsigned int cpu_uid, u16 *tag)
>> + unsigned int cpu, u16 *tag)
>> { return -EINVAL; }
>> static inline void pcie_disable_tph(struct pci_dev *pdev) { }
>> static inline int pcie_enable_tph(struct pci_dev *pdev, int mode)
>> --
>> 2.17.1
>>
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v9 0/7] ACPI: Unify CPU UID interface and fix ARM64 TPH steer-tag issue
2026-03-19 6:57 [PATCH v9 0/7] ACPI: Unify CPU UID interface and fix ARM64 TPH steer-tag issue Chengwen Feng
` (6 preceding siblings ...)
2026-03-19 6:57 ` [PATCH v9 7/7] PCI/TPH: Fix get cpu steer-tag fail on ARM64 platform Chengwen Feng
@ 2026-03-19 10:58 ` Jonathan Cameron
7 siblings, 0 replies; 14+ messages in thread
From: Jonathan Cameron @ 2026-03-19 10:58 UTC (permalink / raw)
To: Chengwen Feng
Cc: Bjorn Helgaas, Catalin Marinas, Will Deacon, Rafael J . Wysocki,
Jonathan Corbet, Shuah Khan, Huacai Chen, WANG Xuerui,
Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
H . Peter Anvin, Juergen Gross, Boris Ostrovsky, Len Brown,
Sunil V L, Mark Rutland, Kees Cook, Yanteng Si,
Sean Christopherson, Kai Huang, Tom Lendacky, Thomas Huth,
Thorsten Blum, Kevin Loughlin, Zheyun Shen, Peter Zijlstra,
Pawan Gupta, Xin Li, Ahmed S . Darwish, Sohil Mehta,
Ilkka Koskinen, Robin Murphy, James Clark, Besar Wicaksono, Ma Ke,
Wei Huang, Andy Gospodarek, Somnath Kotur, punit.agrawal,
guohanjun, suzuki.poulose, ryan.roberts, chenl311, masahiroy,
wangyuquan1236, anshuman.khandual, heinrich.schuchardt,
Eric.VanTassell, wangzhou1, wanghuiqiang, liuyonglong, linux-pci,
linux-doc, linux-kernel, linux-arm-kernel, loongarch, linux-riscv,
xen-devel, linux-acpi, linux-perf-users, stable
On Thu, 19 Mar 2026 14:57:28 +0800
Chengwen Feng <fengchengwen@huawei.com> wrote:
> This patchset unifies ACPI Processor UID retrieval across
> arm64/loongarch/riscv/x86 via acpi_get_cpu_uid() (with input validation)
> and fixes ARM64 CPU steer-tag retrieval failure in PCI/TPH:
>
> 1-4: Add acpi_get_cpu_uid() for arm64/loongarch/riscv/x86 (update
> respective users)
> 5: Centralize acpi_get_cpu_uid() declaration in include/linux/acpi.h
> 6: Clean up ACPI/PPTT and remove unused get_acpi_id_for_cpu()
> 7: Fix ARM64 platform CPU steer-tag retrieval failure
>
> The interface refactor ensures consistent CPU UID retrieval across
> architectures (no functional changes for valid inputs) and provides the
> unified interface required for the ARM64 TPH fix.
Given the structure of the series has slowly evolved since I gave
tags, I took another look. All looks good to me.
Nice work.
Jonathan
^ permalink raw reply [flat|nested] 14+ messages in thread