public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] PCI/TPH: Fix get cpu steer-tag fail on ARM64 platform
@ 2026-03-03  0:36 Chengwen Feng
  2026-03-03 19:02 ` Bjorn Helgaas
                   ` (7 more replies)
  0 siblings, 8 replies; 26+ messages in thread
From: Chengwen Feng @ 2026-03-03  0:36 UTC (permalink / raw)
  To: linux-pci, bhelgaas
  Cc: linux-acpi, rafael, lenb, wei.huang2, Eric.VanTassell,
	jonathan.cameron, wangzhou1, wanghuiqiang, liuyonglong,
	Chengwen Feng, stable

Currently the pcie_tph_get_cpu_st() has a problem on ARM64 platform:
1. The pcie_tph_get_cpu_st() function directly uses cpu_uid as the input
   parameter to call the PCI ACPI DSM method. According to the DSM
   definition, the input value should be the ACPI Processor UID. For
   details, please see [1].
2. In the Broadcom driver implementation [2] (which invoke
   pcie_tph_get_cpu_st()), cpu_uid is obtained based on
   cpumask_first(irq->cpu_mask), that is the logical ID of a CPU core,
   which is generated and managed by the kernel. For example, [0,255]
   if the system has 256 logical CPU cores.
3. Unfortunately, on ARM64 platform, ACPI assigns Processor UID to the
   core which listed in the MADT table, the Processor UID may not equal
   the logical ID of a CPU core in the kernel. So the current
   implementation cannot obtain the cpu's real steer-tag in such case.
4. The reason why it can run on the AMD platform is that the mapping
   between the logical ID and ACPI Processor UID is similar.

This commit fixes it by:
1. Introduce config ARCH_HAS_GET_CPU_ACPI_ID_API and its corresponding
   API acpi_get_cpu_acpi_id() to obtain the ACPI Processor UID of a CPU
   core. This API invokes get_acpi_id_for_cpu() to obtain the UID on
   ARM64 platform.
2. Because using the logical ID as the ACPI Processor UID directly on
   X86 platform is not standard. This commit uses cpu_acpi_id() to
   obtain the UID.
3. At the same time, the input parameter cpu_uid of
   pcie_tph_get_cpu_st() is renamed to cpu for clarity.

[1] According to the _DSM ECN, 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."
[2] commit c214410c47d6e ("bnxt_en: Add TPH support in BNXT driver")

Fixes: d2e8a34876ce ("PCI/TPH: Add Steering Tag support")
Cc: stable@vger.kernel.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
 Documentation/PCI/tph.rst     |  4 ++--
 drivers/acpi/Kconfig          |  8 ++++++++
 drivers/acpi/processor_core.c | 13 +++++++++++++
 drivers/pci/tph.c             | 13 +++++++------
 include/linux/acpi.h          |  4 ++++
 include/linux/pci-tph.h       |  4 ++--
 6 files changed, 36 insertions(+), 10 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/acpi/Kconfig b/drivers/acpi/Kconfig
index df0ff0764d0d..9d851a017cd1 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -606,6 +606,14 @@ config ACPI_PRMT
 	  substantially increase computational overhead related to the
 	  initialization of some server systems.
 
+config ARCH_HAS_GET_CPU_ACPI_ID_API
+	bool "Architecture supports get cpu's ACPI Processor UID"
+	depends on (X86 || ARM64)
+	default y
+	help
+	  This config indicates whether the architecture provides a standard
+	  API to get ACPI Processor UID of a cpu from MADT table.
+
 endif	# ACPI
 
 config X86_PM_TIMER
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
index a4498357bd16..6150f5bdb62e 100644
--- a/drivers/acpi/processor_core.c
+++ b/drivers/acpi/processor_core.c
@@ -335,6 +335,19 @@ int acpi_get_cpuid(acpi_handle handle, int type, u32 acpi_id)
 }
 EXPORT_SYMBOL_GPL(acpi_get_cpuid);
 
+#ifdef CONFIG_ARCH_HAS_GET_CPU_ACPI_ID_API
+unsigned int acpi_get_cpu_acpi_id(unsigned int cpu)
+{
+	if (cpu >= nr_cpu_ids)
+		return 0;
+#ifdef CONFIG_X86
+	return cpu_acpi_id(cpu);
+#elif CONFIG_ARM64
+	return get_acpi_id_for_cpu(cpu);
+#endif
+}
+#endif /* CONFIG_ARCH_HAS_GET_CPU_ACPI_ID_API */
+
 #ifdef CONFIG_ACPI_HOTPLUG_IOAPIC
 static int get_ioapic_id(struct acpi_subtable_header *entry, u32 gsi_base,
 			 u64 *phys_addr, int *ioapic_id)
diff --git a/drivers/pci/tph.c b/drivers/pci/tph.c
index ca4f97be7538..a47c2fbb6148 100644
--- a/drivers/pci/tph.c
+++ b/drivers/pci/tph.c
@@ -236,18 +236,19 @@ 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
+#ifdef CONFIG_ARCH_HAS_GET_CPU_ACPI_ID_API
+	unsigned int cpu_uid = acpi_get_cpu_acpi_id(cpu);
 	struct pci_dev *rp;
 	acpi_handle rp_acpi_handle;
 	union st_info info;
@@ -265,9 +266,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/acpi.h b/include/linux/acpi.h
index 4d2f0bed7a06..789bfcb8e0f3 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -324,6 +324,10 @@ int acpi_unmap_cpu(int cpu);
 
 acpi_handle acpi_get_processor_handle(int cpu);
 
+#ifdef CONFIG_ARCH_HAS_GET_CPU_ACPI_ID_API
+unsigned int acpi_get_cpu_acpi_id(unsigned int cpu);
+#endif
+
 #ifdef CONFIG_ACPI_HOTPLUG_IOAPIC
 int acpi_get_ioapic_id(acpi_handle handle, u32 gsi_base, u64 *phys_addr);
 #endif
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] 26+ messages in thread

* Re: [PATCH] PCI/TPH: Fix get cpu steer-tag fail on ARM64 platform
  2026-03-03  0:36 [PATCH] PCI/TPH: Fix get cpu steer-tag fail on ARM64 platform Chengwen Feng
@ 2026-03-03 19:02 ` Bjorn Helgaas
  2026-03-04  9:28   ` fengchengwen
  2026-03-04 13:50 ` kernel test robot
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 26+ messages in thread
From: Bjorn Helgaas @ 2026-03-03 19:02 UTC (permalink / raw)
  To: Chengwen Feng
  Cc: linux-pci, bhelgaas, linux-acpi, rafael, lenb, wei.huang2,
	Eric.VanTassell, jonathan.cameron, wangzhou1, wanghuiqiang,
	liuyonglong, stable, Jeremy Linton, Sunil V L, Sunil V L,
	Huacai Chen, Liupu Wang

[+cc Jeremy, Sunil, Huacai, Liupu, authors of get_acpi_id_for_cpu()
for arm64, riscv, loongson]

On Tue, Mar 03, 2026 at 08:36:25AM +0800, Chengwen Feng wrote:
> Currently the pcie_tph_get_cpu_st() has a problem on ARM64 platform:
> 1. The pcie_tph_get_cpu_st() function directly uses cpu_uid as the input
>    parameter to call the PCI ACPI DSM method. According to the DSM
>    definition, the input value should be the ACPI Processor UID. For
>    details, please see [1].
>
> 2. In the Broadcom driver implementation [2] (which invoke
>    pcie_tph_get_cpu_st()), cpu_uid is obtained based on
>    cpumask_first(irq->cpu_mask), that is the logical ID of a CPU core,
>    which is generated and managed by the kernel. For example, [0,255]
>    if the system has 256 logical CPU cores.
> 3. Unfortunately, on ARM64 platform, ACPI assigns Processor UID to the
>    core which listed in the MADT table, the Processor UID may not equal
>    the logical ID of a CPU core in the kernel. So the current
>    implementation cannot obtain the cpu's real steer-tag in such case.
> 4. The reason why it can run on the AMD platform is that the mapping
>    between the logical ID and ACPI Processor UID is similar.
> 
> This commit fixes it by:
> 1. Introduce config ARCH_HAS_GET_CPU_ACPI_ID_API and its corresponding
>    API acpi_get_cpu_acpi_id() to obtain the ACPI Processor UID of a CPU
>    core. This API invokes get_acpi_id_for_cpu() to obtain the UID on
>    ARM64 platform.
> 2. Because using the logical ID as the ACPI Processor UID directly on
>    X86 platform is not standard. This commit uses cpu_acpi_id() to
>    obtain the UID.
> 3. At the same time, the input parameter cpu_uid of
>    pcie_tph_get_cpu_st() is renamed to cpu for clarity.

Thanks for raising this issue!

TLP Processing Hints (TPH) and Steering Tags are generic PCIe features
that we should support for both ACPI and non-ACPI systems.

The current implementation of pcie_tph_get_cpu_st() only supports
ACPI, and it assumes the cpu_uid parameter is an ACPI CPU UID that can
be passed directly to the _DSM.  But since we want this to be a
generic interface, I think the "cpu" parameter should be the Linux
logical CPU ID, not an ACPI UID, as you point out.

> [1] According to the _DSM ECN, 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."

This needs a specific spec citation for the _DSM function.  Ideally it
would be "PCI Firmware spec r3.3, sec xx", but I don't think there's a
revision of the spec that includes this ECN.  But we can at least
include the actual name and URL for the approved ECN.

> [2] commit c214410c47d6e ("bnxt_en: Add TPH support in BNXT driver")
> 
> Fixes: d2e8a34876ce ("PCI/TPH: Add Steering Tag support")
> Cc: stable@vger.kernel.org
> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
> ---
>  Documentation/PCI/tph.rst     |  4 ++--
>  drivers/acpi/Kconfig          |  8 ++++++++
>  drivers/acpi/processor_core.c | 13 +++++++++++++
>  drivers/pci/tph.c             | 13 +++++++------
>  include/linux/acpi.h          |  4 ++++
>  include/linux/pci-tph.h       |  4 ++--
>  6 files changed, 36 insertions(+), 10 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/acpi/Kconfig b/drivers/acpi/Kconfig
> index df0ff0764d0d..9d851a017cd1 100644
> --- a/drivers/acpi/Kconfig
> +++ b/drivers/acpi/Kconfig
> @@ -606,6 +606,14 @@ config ACPI_PRMT
>  	  substantially increase computational overhead related to the
>  	  initialization of some server systems.
>  
> +config ARCH_HAS_GET_CPU_ACPI_ID_API
> +	bool "Architecture supports get cpu's ACPI Processor UID"
> +	depends on (X86 || ARM64)
> +	default y
> +	help
> +	  This config indicates whether the architecture provides a standard
> +	  API to get ACPI Processor UID of a cpu from MADT table.
> +
>  endif	# ACPI
>  
>  config X86_PM_TIMER
> diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
> index a4498357bd16..6150f5bdb62e 100644
> --- a/drivers/acpi/processor_core.c
> +++ b/drivers/acpi/processor_core.c
> @@ -335,6 +335,19 @@ int acpi_get_cpuid(acpi_handle handle, int type, u32 acpi_id)
>  }
>  EXPORT_SYMBOL_GPL(acpi_get_cpuid);
>  
> +#ifdef CONFIG_ARCH_HAS_GET_CPU_ACPI_ID_API
> +unsigned int acpi_get_cpu_acpi_id(unsigned int cpu)
> +{
> +	if (cpu >= nr_cpu_ids)
> +		return 0;
> +#ifdef CONFIG_X86
> +	return cpu_acpi_id(cpu);
> +#elif CONFIG_ARM64
> +	return get_acpi_id_for_cpu(cpu);
> +#endif
> +}
> +#endif /* CONFIG_ARCH_HAS_GET_CPU_ACPI_ID_API */
> +
>  #ifdef CONFIG_ACPI_HOTPLUG_IOAPIC
>  static int get_ioapic_id(struct acpi_subtable_header *entry, u32 gsi_base,
>  			 u64 *phys_addr, int *ioapic_id)
> diff --git a/drivers/pci/tph.c b/drivers/pci/tph.c
> index ca4f97be7538..a47c2fbb6148 100644
> --- a/drivers/pci/tph.c
> +++ b/drivers/pci/tph.c
> @@ -236,18 +236,19 @@ 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
> +#ifdef CONFIG_ARCH_HAS_GET_CPU_ACPI_ID_API
> +	unsigned int cpu_uid = acpi_get_cpu_acpi_id(cpu);

Any required conversion between Linux logical CPU and ACPI CPU UID
should be internal to pcie_tph_get_cpu_st(), as you're doing here.

But rather than adding CONFIG_ARCH_HAS_GET_CPU_ACPI_ID_API and the
ifdefs in acpi_get_cpu_acpi_id(), I think there should be a generic
ACPI interface that converts logical CPU ID to ACPI UID, and every
arch supporting ACPI should have to implement it.

We already have get_acpi_id_for_cpu(), implemented for arm64, riscv,
and loongarch:

  30d87bfacbee ("arm64/acpi: Create arch specific cpu to acpi id helper")
  f99561199470 ("RISC-V: ACPI: Cache and retrieve the RINTC structure")
  f6f0c9a74a48 ("LoongArch: Add SMT (Simultaneous Multi-Threading) support")

What if we just implemented it for x86 as well and moved it to
include/linux/acpi.h or similar?

>  	struct pci_dev *rp;
>  	acpi_handle rp_acpi_handle;
>  	union st_info info;
> @@ -265,9 +266,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/acpi.h b/include/linux/acpi.h
> index 4d2f0bed7a06..789bfcb8e0f3 100644
> --- a/include/linux/acpi.h
> +++ b/include/linux/acpi.h
> @@ -324,6 +324,10 @@ int acpi_unmap_cpu(int cpu);
>  
>  acpi_handle acpi_get_processor_handle(int cpu);
>  
> +#ifdef CONFIG_ARCH_HAS_GET_CPU_ACPI_ID_API
> +unsigned int acpi_get_cpu_acpi_id(unsigned int cpu);
> +#endif
> +
>  #ifdef CONFIG_ACPI_HOTPLUG_IOAPIC
>  int acpi_get_ioapic_id(acpi_handle handle, u32 gsi_base, u64 *phys_addr);
>  #endif
> 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] 26+ messages in thread

* Re: [PATCH] PCI/TPH: Fix get cpu steer-tag fail on ARM64 platform
  2026-03-03 19:02 ` Bjorn Helgaas
@ 2026-03-04  9:28   ` fengchengwen
  2026-03-04 15:38     ` Bjorn Helgaas
  0 siblings, 1 reply; 26+ messages in thread
From: fengchengwen @ 2026-03-04  9:28 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: linux-pci, bhelgaas, linux-acpi, rafael, lenb, wei.huang2,
	Eric.VanTassell, jonathan.cameron, wangzhou1, wanghuiqiang,
	liuyonglong, stable, Jeremy Linton, Sunil V L, Sunil V L,
	Huacai Chen, Liupu Wang

Thanks for your feedback and suggestions. Replies inline.

On 3/4/2026 3:02 AM, Bjorn Helgaas wrote:
> [+cc Jeremy, Sunil, Huacai, Liupu, authors of get_acpi_id_for_cpu()
> for arm64, riscv, loongson]
> 
> On Tue, Mar 03, 2026 at 08:36:25AM +0800, Chengwen Feng wrote:
>> Currently the pcie_tph_get_cpu_st() has a problem on ARM64 platform:
>> 1. The pcie_tph_get_cpu_st() function directly uses cpu_uid as the input
>>    parameter to call the PCI ACPI DSM method. According to the DSM
>>    definition, the input value should be the ACPI Processor UID. For
>>    details, please see [1].
>>
>> 2. In the Broadcom driver implementation [2] (which invoke
>>    pcie_tph_get_cpu_st()), cpu_uid is obtained based on
>>    cpumask_first(irq->cpu_mask), that is the logical ID of a CPU core,
>>    which is generated and managed by the kernel. For example, [0,255]
>>    if the system has 256 logical CPU cores.
>> 3. Unfortunately, on ARM64 platform, ACPI assigns Processor UID to the
>>    core which listed in the MADT table, the Processor UID may not equal
>>    the logical ID of a CPU core in the kernel. So the current
>>    implementation cannot obtain the cpu's real steer-tag in such case.
>> 4. The reason why it can run on the AMD platform is that the mapping
>>    between the logical ID and ACPI Processor UID is similar.
>>
>> This commit fixes it by:
>> 1. Introduce config ARCH_HAS_GET_CPU_ACPI_ID_API and its corresponding
>>    API acpi_get_cpu_acpi_id() to obtain the ACPI Processor UID of a CPU
>>    core. This API invokes get_acpi_id_for_cpu() to obtain the UID on
>>    ARM64 platform.
>> 2. Because using the logical ID as the ACPI Processor UID directly on
>>    X86 platform is not standard. This commit uses cpu_acpi_id() to
>>    obtain the UID.
>> 3. At the same time, the input parameter cpu_uid of
>>    pcie_tph_get_cpu_st() is renamed to cpu for clarity.
> 
> Thanks for raising this issue!
> 
> TLP Processing Hints (TPH) and Steering Tags are generic PCIe features
> that we should support for both ACPI and non-ACPI systems.
> 
> The current implementation of pcie_tph_get_cpu_st() only supports
> ACPI, and it assumes the cpu_uid parameter is an ACPI CPU UID that can
> be passed directly to the _DSM.  But since we want this to be a
> generic interface, I think the "cpu" parameter should be the Linux
> logical CPU ID, not an ACPI UID, as you point out.
> 
>> [1] According to the _DSM ECN, 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."
> 
> This needs a specific spec citation for the _DSM function.  Ideally it
> would be "PCI Firmware spec r3.3, sec xx", but I don't think there's a
> revision of the spec that includes this ECN.  But we can at least
> include the actual name and URL for the approved ECN.

OK, will do in v2

> 
>> [2] commit c214410c47d6e ("bnxt_en: Add TPH support in BNXT driver")
>>
>> Fixes: d2e8a34876ce ("PCI/TPH: Add Steering Tag support")
>> Cc: stable@vger.kernel.org
>> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
>> ---
>>  Documentation/PCI/tph.rst     |  4 ++--
>>  drivers/acpi/Kconfig          |  8 ++++++++
>>  drivers/acpi/processor_core.c | 13 +++++++++++++
>>  drivers/pci/tph.c             | 13 +++++++------
>>  include/linux/acpi.h          |  4 ++++
>>  include/linux/pci-tph.h       |  4 ++--
>>  6 files changed, 36 insertions(+), 10 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/acpi/Kconfig b/drivers/acpi/Kconfig
>> index df0ff0764d0d..9d851a017cd1 100644
>> --- a/drivers/acpi/Kconfig
>> +++ b/drivers/acpi/Kconfig
>> @@ -606,6 +606,14 @@ config ACPI_PRMT
>>  	  substantially increase computational overhead related to the
>>  	  initialization of some server systems.
>>  
>> +config ARCH_HAS_GET_CPU_ACPI_ID_API
>> +	bool "Architecture supports get cpu's ACPI Processor UID"
>> +	depends on (X86 || ARM64)
>> +	default y
>> +	help
>> +	  This config indicates whether the architecture provides a standard
>> +	  API to get ACPI Processor UID of a cpu from MADT table.
>> +
>>  endif	# ACPI
>>  
>>  config X86_PM_TIMER
>> diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
>> index a4498357bd16..6150f5bdb62e 100644
>> --- a/drivers/acpi/processor_core.c
>> +++ b/drivers/acpi/processor_core.c
>> @@ -335,6 +335,19 @@ int acpi_get_cpuid(acpi_handle handle, int type, u32 acpi_id)
>>  }
>>  EXPORT_SYMBOL_GPL(acpi_get_cpuid);
>>  
>> +#ifdef CONFIG_ARCH_HAS_GET_CPU_ACPI_ID_API
>> +unsigned int acpi_get_cpu_acpi_id(unsigned int cpu)
>> +{
>> +	if (cpu >= nr_cpu_ids)
>> +		return 0;
>> +#ifdef CONFIG_X86
>> +	return cpu_acpi_id(cpu);
>> +#elif CONFIG_ARM64
>> +	return get_acpi_id_for_cpu(cpu);
>> +#endif
>> +}
>> +#endif /* CONFIG_ARCH_HAS_GET_CPU_ACPI_ID_API */
>> +
>>  #ifdef CONFIG_ACPI_HOTPLUG_IOAPIC
>>  static int get_ioapic_id(struct acpi_subtable_header *entry, u32 gsi_base,
>>  			 u64 *phys_addr, int *ioapic_id)
>> diff --git a/drivers/pci/tph.c b/drivers/pci/tph.c
>> index ca4f97be7538..a47c2fbb6148 100644
>> --- a/drivers/pci/tph.c
>> +++ b/drivers/pci/tph.c
>> @@ -236,18 +236,19 @@ 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
>> +#ifdef CONFIG_ARCH_HAS_GET_CPU_ACPI_ID_API
>> +	unsigned int cpu_uid = acpi_get_cpu_acpi_id(cpu);
> 
> Any required conversion between Linux logical CPU and ACPI CPU UID
> should be internal to pcie_tph_get_cpu_st(), as you're doing here.
> 
> But rather than adding CONFIG_ARCH_HAS_GET_CPU_ACPI_ID_API and the
> ifdefs in acpi_get_cpu_acpi_id(), I think there should be a generic
> ACPI interface that converts logical CPU ID to ACPI UID, and every
> arch supporting ACPI should have to implement it.
> 
> We already have get_acpi_id_for_cpu(), implemented for arm64, riscv,
> and loongarch:
> 
>   30d87bfacbee ("arm64/acpi: Create arch specific cpu to acpi id helper")
>   f99561199470 ("RISC-V: ACPI: Cache and retrieve the RINTC structure")
>   f6f0c9a74a48 ("LoongArch: Add SMT (Simultaneous Multi-Threading) support")
> 
> What if we just implemented it for x86 as well and moved it to
> include/linux/acpi.h or similar?

Your idea to unify the ACPI CPU ID function across architectures is great. I noticed
that all exported ACPI functions use the `acpi_` prefix, so I think we shouldn’t
simply modify x86’s implementation directly – we should also align the naming
convention for other platforms.

Since only x86, arm64, risc-v, and loongarch currently support ACPI, how about we
remove the new config and instead use this approach:

unsigned int acpi_get_cpu_acpi_id(unsigned int cpu)
{
        if (cpu >= nr_cpu_ids)
                return 0;
#ifdef CONFIG_X86
        return cpu_acpi_id(cpu);
#elif defined(CONFIG_ARM64) || defined(CONFIG_RISCV) || defined(CONFIG_LOONGARCH)
        return get_acpi_id_for_cpu(cpu);
#endif
}

For any new platform that plans to support ACPI in the future, this will trigger a
compile error – which is intentional. It will prompt the maintainers of that platform
to add their own implementation of either `get_acpi_id_for_cpu` or `cpu_acpi_id` as
needed.

> 
>>  	struct pci_dev *rp;
>>  	acpi_handle rp_acpi_handle;
>>  	union st_info info;
>> @@ -265,9 +266,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/acpi.h b/include/linux/acpi.h
>> index 4d2f0bed7a06..789bfcb8e0f3 100644
>> --- a/include/linux/acpi.h
>> +++ b/include/linux/acpi.h
>> @@ -324,6 +324,10 @@ int acpi_unmap_cpu(int cpu);
>>  
>>  acpi_handle acpi_get_processor_handle(int cpu);
>>  
>> +#ifdef CONFIG_ARCH_HAS_GET_CPU_ACPI_ID_API
>> +unsigned int acpi_get_cpu_acpi_id(unsigned int cpu);
>> +#endif
>> +
>>  #ifdef CONFIG_ACPI_HOTPLUG_IOAPIC
>>  int acpi_get_ioapic_id(acpi_handle handle, u32 gsi_base, u64 *phys_addr);
>>  #endif
>> 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] 26+ messages in thread

* Re: [PATCH] PCI/TPH: Fix get cpu steer-tag fail on ARM64 platform
  2026-03-03  0:36 [PATCH] PCI/TPH: Fix get cpu steer-tag fail on ARM64 platform Chengwen Feng
  2026-03-03 19:02 ` Bjorn Helgaas
@ 2026-03-04 13:50 ` kernel test robot
  2026-03-04 23:18 ` kernel test robot
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 26+ messages in thread
From: kernel test robot @ 2026-03-04 13:50 UTC (permalink / raw)
  To: Chengwen Feng, linux-pci, bhelgaas
  Cc: oe-kbuild-all, linux-acpi, rafael, lenb, wei.huang2,
	Eric.VanTassell, jonathan.cameron, wangzhou1, wanghuiqiang,
	liuyonglong, Chengwen Feng, stable

Hi Chengwen,

kernel test robot noticed the following build errors:

[auto build test ERROR on pci/next]
[also build test ERROR on pci/for-linus rafael-pm/linux-next rafael-pm/bleeding-edge linus/master v7.0-rc2 next-20260303]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Chengwen-Feng/PCI-TPH-Fix-get-cpu-steer-tag-fail-on-ARM64-platform/20260303-084305
base:   https://git.kernel.org/pub/scm/linux/kernel/git/pci/pci.git next
patch link:    https://lore.kernel.org/r/20260303003625.39035-1-fengchengwen%40huawei.com
patch subject: [PATCH] PCI/TPH: Fix get cpu steer-tag fail on ARM64 platform
config: i386-randconfig-2006-20250804 (https://download.01.org/0day-ci/archive/20260304/202603041459.Mw33vD7S-lkp@intel.com/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260304/202603041459.Mw33vD7S-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202603041459.Mw33vD7S-lkp@intel.com/

All errors (new ones prefixed by >>):

   drivers/acpi/processor_core.c: In function 'acpi_get_cpu_acpi_id':
>> drivers/acpi/processor_core.c:344:16: error: implicit declaration of function 'cpu_acpi_id' [-Wimplicit-function-declaration]
     344 |         return cpu_acpi_id(cpu);
         |                ^~~~~~~~~~~


vim +/cpu_acpi_id +344 drivers/acpi/processor_core.c

   337	
   338	#ifdef CONFIG_ARCH_HAS_GET_CPU_ACPI_ID_API
   339	unsigned int acpi_get_cpu_acpi_id(unsigned int cpu)
   340	{
   341		if (cpu >= nr_cpu_ids)
   342			return 0;
   343	#ifdef CONFIG_X86
 > 344		return cpu_acpi_id(cpu);
   345	#elif CONFIG_ARM64
   346		return get_acpi_id_for_cpu(cpu);
   347	#endif
   348	}
   349	#endif /* CONFIG_ARCH_HAS_GET_CPU_ACPI_ID_API */
   350	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH] PCI/TPH: Fix get cpu steer-tag fail on ARM64 platform
  2026-03-04  9:28   ` fengchengwen
@ 2026-03-04 15:38     ` Bjorn Helgaas
  2026-03-05  8:40       ` fengchengwen
  0 siblings, 1 reply; 26+ messages in thread
From: Bjorn Helgaas @ 2026-03-04 15:38 UTC (permalink / raw)
  To: fengchengwen
  Cc: linux-pci, bhelgaas, linux-acpi, rafael, lenb, wei.huang2,
	Eric.VanTassell, jonathan.cameron, wangzhou1, wanghuiqiang,
	liuyonglong, stable, Jeremy Linton, Sunil V L, Sunil V L,
	Huacai Chen, Liupu Wang

On Wed, Mar 04, 2026 at 05:28:36PM +0800, fengchengwen wrote:
> On 3/4/2026 3:02 AM, Bjorn Helgaas wrote:
> > [+cc Jeremy, Sunil, Huacai, Liupu, authors of get_acpi_id_for_cpu()
> > for arm64, riscv, loongson]
> > 
> > On Tue, Mar 03, 2026 at 08:36:25AM +0800, Chengwen Feng wrote:
> >> Currently the pcie_tph_get_cpu_st() has a problem on ARM64 platform:
> >> 1. The pcie_tph_get_cpu_st() function directly uses cpu_uid as the input
> >>    parameter to call the PCI ACPI DSM method. According to the DSM
> >>    definition, the input value should be the ACPI Processor UID. For
> >>    details, please see [1].
> >>
> >> 2. In the Broadcom driver implementation [2] (which invoke
> >>    pcie_tph_get_cpu_st()), cpu_uid is obtained based on
> >>    cpumask_first(irq->cpu_mask), that is the logical ID of a CPU core,
> >>    which is generated and managed by the kernel. For example, [0,255]
> >>    if the system has 256 logical CPU cores.
> >> 3. Unfortunately, on ARM64 platform, ACPI assigns Processor UID to the
> >>    core which listed in the MADT table, the Processor UID may not equal
> >>    the logical ID of a CPU core in the kernel. So the current
> >>    implementation cannot obtain the cpu's real steer-tag in such case.
> >> 4. The reason why it can run on the AMD platform is that the mapping
> >>    between the logical ID and ACPI Processor UID is similar.
> >>
> >> This commit fixes it by:
> >> 1. Introduce config ARCH_HAS_GET_CPU_ACPI_ID_API and its corresponding
> >>    API acpi_get_cpu_acpi_id() to obtain the ACPI Processor UID of a CPU
> >>    core. This API invokes get_acpi_id_for_cpu() to obtain the UID on
> >>    ARM64 platform.
> >> 2. Because using the logical ID as the ACPI Processor UID directly on
> >>    X86 platform is not standard. This commit uses cpu_acpi_id() to
> >>    obtain the UID.
> >> 3. At the same time, the input parameter cpu_uid of
> >>    pcie_tph_get_cpu_st() is renamed to cpu for clarity.
> > 
> > Thanks for raising this issue!
> > 
> > TLP Processing Hints (TPH) and Steering Tags are generic PCIe features
> > that we should support for both ACPI and non-ACPI systems.
> > 
> > The current implementation of pcie_tph_get_cpu_st() only supports
> > ACPI, and it assumes the cpu_uid parameter is an ACPI CPU UID that can
> > be passed directly to the _DSM.  But since we want this to be a
> > generic interface, I think the "cpu" parameter should be the Linux
> > logical CPU ID, not an ACPI UID, as you point out.
> ...

> >>  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
> >> +#ifdef CONFIG_ARCH_HAS_GET_CPU_ACPI_ID_API
> >> +	unsigned int cpu_uid = acpi_get_cpu_acpi_id(cpu);
> > 
> > Any required conversion between Linux logical CPU and ACPI CPU UID
> > should be internal to pcie_tph_get_cpu_st(), as you're doing here.
> > 
> > But rather than adding CONFIG_ARCH_HAS_GET_CPU_ACPI_ID_API and the
> > ifdefs in acpi_get_cpu_acpi_id(), I think there should be a generic
> > ACPI interface that converts logical CPU ID to ACPI UID, and every
> > arch supporting ACPI should have to implement it.
> > 
> > We already have get_acpi_id_for_cpu(), implemented for arm64, riscv,
> > and loongarch:
> > 
> >   30d87bfacbee ("arm64/acpi: Create arch specific cpu to acpi id helper")
> >   f99561199470 ("RISC-V: ACPI: Cache and retrieve the RINTC structure")
> >   f6f0c9a74a48 ("LoongArch: Add SMT (Simultaneous Multi-Threading) support")
> > 
> > What if we just implemented it for x86 as well and moved it to
> > include/linux/acpi.h or similar?
> 
> Your idea to unify the ACPI CPU ID function across architectures is
> great. I noticed that all exported ACPI functions use the `acpi_`
> prefix, so I think we shouldn’t simply modify x86’s implementation
> directly – we should also align the naming convention for other
> platforms.
> 
> Since only x86, arm64, risc-v, and loongarch currently support ACPI,
> how about we remove the new config and instead use this approach:
> 
> unsigned int acpi_get_cpu_acpi_id(unsigned int cpu)
> {
>         if (cpu >= nr_cpu_ids)
>                 return 0;
> #ifdef CONFIG_X86
>         return cpu_acpi_id(cpu);
> #elif defined(CONFIG_ARM64) || defined(CONFIG_RISCV) || defined(CONFIG_LOONGARCH)
>         return get_acpi_id_for_cpu(cpu);
> #endif
> }
> 
> For any new platform that plans to support ACPI in the future, this
> will trigger a compile error – which is intentional. It will prompt
> the maintainers of that platform to add their own implementation of
> either `get_acpi_id_for_cpu` or `cpu_acpi_id` as needed.

I agree that an "acpi_" prefix would be appropriate.  I'd suggest
separate implementations in arch/*/kernel/acpi.c instead of #ifdefs in
a common version.

Maybe users of cpu_acpi_id() and get_acpi_id_for_cpu() could be
converted to use the generic interface.

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH] PCI/TPH: Fix get cpu steer-tag fail on ARM64 platform
  2026-03-03  0:36 [PATCH] PCI/TPH: Fix get cpu steer-tag fail on ARM64 platform Chengwen Feng
  2026-03-03 19:02 ` Bjorn Helgaas
  2026-03-04 13:50 ` kernel test robot
@ 2026-03-04 23:18 ` kernel test robot
  2026-03-05  0:02 ` kernel test robot
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 26+ messages in thread
From: kernel test robot @ 2026-03-04 23:18 UTC (permalink / raw)
  To: Chengwen Feng, linux-pci, bhelgaas
  Cc: oe-kbuild-all, linux-acpi, rafael, lenb, wei.huang2,
	Eric.VanTassell, jonathan.cameron, wangzhou1, wanghuiqiang,
	liuyonglong, Chengwen Feng, stable

Hi Chengwen,

kernel test robot noticed the following build errors:

[auto build test ERROR on pci/next]
[also build test ERROR on pci/for-linus rafael-pm/linux-next rafael-pm/bleeding-edge linus/master v7.0-rc2 next-20260304]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Chengwen-Feng/PCI-TPH-Fix-get-cpu-steer-tag-fail-on-ARM64-platform/20260303-084305
base:   https://git.kernel.org/pub/scm/linux/kernel/git/pci/pci.git next
patch link:    https://lore.kernel.org/r/20260303003625.39035-1-fengchengwen%40huawei.com
patch subject: [PATCH] PCI/TPH: Fix get cpu steer-tag fail on ARM64 platform
config: x86_64-randconfig-r072-20260305 (https://download.01.org/0day-ci/archive/20260305/202603050711.whqDobKh-lkp@intel.com/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
smatch: v0.5.0-9004-gb810ac53
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260305/202603050711.whqDobKh-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202603050711.whqDobKh-lkp@intel.com/

All errors (new ones prefixed by >>):

   drivers/acpi/processor_core.c: In function 'acpi_get_cpu_acpi_id':
>> drivers/acpi/processor_core.c:344:16: error: implicit declaration of function 'cpu_acpi_id' [-Wimplicit-function-declaration]
     344 |         return cpu_acpi_id(cpu);
         |                ^~~~~~~~~~~


vim +/cpu_acpi_id +344 drivers/acpi/processor_core.c

   337	
   338	#ifdef CONFIG_ARCH_HAS_GET_CPU_ACPI_ID_API
   339	unsigned int acpi_get_cpu_acpi_id(unsigned int cpu)
   340	{
   341		if (cpu >= nr_cpu_ids)
   342			return 0;
   343	#ifdef CONFIG_X86
 > 344		return cpu_acpi_id(cpu);
   345	#elif CONFIG_ARM64
   346		return get_acpi_id_for_cpu(cpu);
   347	#endif
   348	}
   349	#endif /* CONFIG_ARCH_HAS_GET_CPU_ACPI_ID_API */
   350	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH] PCI/TPH: Fix get cpu steer-tag fail on ARM64 platform
  2026-03-03  0:36 [PATCH] PCI/TPH: Fix get cpu steer-tag fail on ARM64 platform Chengwen Feng
                   ` (2 preceding siblings ...)
  2026-03-04 23:18 ` kernel test robot
@ 2026-03-05  0:02 ` kernel test robot
  2026-03-05  1:29 ` kernel test robot
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 26+ messages in thread
From: kernel test robot @ 2026-03-05  0:02 UTC (permalink / raw)
  To: Chengwen Feng, linux-pci, bhelgaas
  Cc: oe-kbuild-all, linux-acpi, rafael, lenb, wei.huang2,
	Eric.VanTassell, jonathan.cameron, wangzhou1, wanghuiqiang,
	liuyonglong, Chengwen Feng, stable

Hi Chengwen,

kernel test robot noticed the following build errors:

[auto build test ERROR on pci/next]
[also build test ERROR on pci/for-linus rafael-pm/linux-next rafael-pm/bleeding-edge linus/master v7.0-rc2 next-20260303]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Chengwen-Feng/PCI-TPH-Fix-get-cpu-steer-tag-fail-on-ARM64-platform/20260303-084305
base:   https://git.kernel.org/pub/scm/linux/kernel/git/pci/pci.git next
patch link:    https://lore.kernel.org/r/20260303003625.39035-1-fengchengwen%40huawei.com
patch subject: [PATCH] PCI/TPH: Fix get cpu steer-tag fail on ARM64 platform
config: i386-randconfig-141-20260305 (https://download.01.org/0day-ci/archive/20260305/202603050748.kO9QwTCh-lkp@intel.com/config)
compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
smatch: v0.5.0-9004-gb810ac53
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260305/202603050748.kO9QwTCh-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202603050748.kO9QwTCh-lkp@intel.com/

All errors (new ones prefixed by >>):

>> drivers/acpi/processor_core.c:344:9: error: call to undeclared function 'cpu_acpi_id'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
     344 |         return cpu_acpi_id(cpu);
         |                ^
   1 error generated.


vim +/cpu_acpi_id +344 drivers/acpi/processor_core.c

   337	
   338	#ifdef CONFIG_ARCH_HAS_GET_CPU_ACPI_ID_API
   339	unsigned int acpi_get_cpu_acpi_id(unsigned int cpu)
   340	{
   341		if (cpu >= nr_cpu_ids)
   342			return 0;
   343	#ifdef CONFIG_X86
 > 344		return cpu_acpi_id(cpu);
   345	#elif CONFIG_ARM64
   346		return get_acpi_id_for_cpu(cpu);
   347	#endif
   348	}
   349	#endif /* CONFIG_ARCH_HAS_GET_CPU_ACPI_ID_API */
   350	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH] PCI/TPH: Fix get cpu steer-tag fail on ARM64 platform
  2026-03-03  0:36 [PATCH] PCI/TPH: Fix get cpu steer-tag fail on ARM64 platform Chengwen Feng
                   ` (3 preceding siblings ...)
  2026-03-05  0:02 ` kernel test robot
@ 2026-03-05  1:29 ` kernel test robot
  2026-03-05  8:36 ` [PATCH v2] " Chengwen Feng
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 26+ messages in thread
From: kernel test robot @ 2026-03-05  1:29 UTC (permalink / raw)
  To: Chengwen Feng, linux-pci, bhelgaas
  Cc: oe-kbuild-all, linux-acpi, rafael, lenb, wei.huang2,
	Eric.VanTassell, jonathan.cameron, wangzhou1, wanghuiqiang,
	liuyonglong, Chengwen Feng, stable

Hi Chengwen,

kernel test robot noticed the following build warnings:

[auto build test WARNING on pci/next]
[also build test WARNING on pci/for-linus rafael-pm/linux-next rafael-pm/bleeding-edge linus/master v7.0-rc2 next-20260303]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Chengwen-Feng/PCI-TPH-Fix-get-cpu-steer-tag-fail-on-ARM64-platform/20260303-084305
base:   https://git.kernel.org/pub/scm/linux/kernel/git/pci/pci.git next
patch link:    https://lore.kernel.org/r/20260303003625.39035-1-fengchengwen%40huawei.com
patch subject: [PATCH] PCI/TPH: Fix get cpu steer-tag fail on ARM64 platform
config: loongarch-randconfig-002-20260305 (https://download.01.org/0day-ci/archive/20260305/202603050927.IVSflNry-lkp@intel.com/config)
compiler: loongarch64-linux-gcc (GCC) 15.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260305/202603050927.IVSflNry-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202603050927.IVSflNry-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> drivers/pci/tph.c:92:20: warning: 'tph_invoke_dsm' defined but not used [-Wunused-function]
      92 | static acpi_status tph_invoke_dsm(acpi_handle handle, u32 cpu_uid,
         |                    ^~~~~~~~~~~~~~
>> drivers/pci/tph.c:56:12: warning: 'tph_extract_tag' defined but not used [-Wunused-function]
      56 | static u16 tph_extract_tag(enum tph_mem_type mem_type, u8 req_type,
         |            ^~~~~~~~~~~~~~~


vim +/tph_invoke_dsm +92 drivers/pci/tph.c

d2e8a34876ce69b Wei Huang 2024-10-02   55  
d2e8a34876ce69b Wei Huang 2024-10-02  @56  static u16 tph_extract_tag(enum tph_mem_type mem_type, u8 req_type,
d2e8a34876ce69b Wei Huang 2024-10-02   57  			   union st_info *info)
d2e8a34876ce69b Wei Huang 2024-10-02   58  {
d2e8a34876ce69b Wei Huang 2024-10-02   59  	switch (req_type) {
d2e8a34876ce69b Wei Huang 2024-10-02   60  	case PCI_TPH_REQ_TPH_ONLY: /* 8-bit tag */
d2e8a34876ce69b Wei Huang 2024-10-02   61  		switch (mem_type) {
d2e8a34876ce69b Wei Huang 2024-10-02   62  		case TPH_MEM_TYPE_VM:
d2e8a34876ce69b Wei Huang 2024-10-02   63  			if (info->vm_st_valid)
d2e8a34876ce69b Wei Huang 2024-10-02   64  				return info->vm_st;
d2e8a34876ce69b Wei Huang 2024-10-02   65  			break;
d2e8a34876ce69b Wei Huang 2024-10-02   66  		case TPH_MEM_TYPE_PM:
d2e8a34876ce69b Wei Huang 2024-10-02   67  			if (info->pm_st_valid)
d2e8a34876ce69b Wei Huang 2024-10-02   68  				return info->pm_st;
d2e8a34876ce69b Wei Huang 2024-10-02   69  			break;
d2e8a34876ce69b Wei Huang 2024-10-02   70  		}
d2e8a34876ce69b Wei Huang 2024-10-02   71  		break;
d2e8a34876ce69b Wei Huang 2024-10-02   72  	case PCI_TPH_REQ_EXT_TPH: /* 16-bit tag */
d2e8a34876ce69b Wei Huang 2024-10-02   73  		switch (mem_type) {
d2e8a34876ce69b Wei Huang 2024-10-02   74  		case TPH_MEM_TYPE_VM:
d2e8a34876ce69b Wei Huang 2024-10-02   75  			if (info->vm_xst_valid)
d2e8a34876ce69b Wei Huang 2024-10-02   76  				return info->vm_xst;
d2e8a34876ce69b Wei Huang 2024-10-02   77  			break;
d2e8a34876ce69b Wei Huang 2024-10-02   78  		case TPH_MEM_TYPE_PM:
d2e8a34876ce69b Wei Huang 2024-10-02   79  			if (info->pm_xst_valid)
d2e8a34876ce69b Wei Huang 2024-10-02   80  				return info->pm_xst;
d2e8a34876ce69b Wei Huang 2024-10-02   81  			break;
d2e8a34876ce69b Wei Huang 2024-10-02   82  		}
d2e8a34876ce69b Wei Huang 2024-10-02   83  		break;
d2e8a34876ce69b Wei Huang 2024-10-02   84  	default:
d2e8a34876ce69b Wei Huang 2024-10-02   85  		return 0;
d2e8a34876ce69b Wei Huang 2024-10-02   86  	}
d2e8a34876ce69b Wei Huang 2024-10-02   87  
d2e8a34876ce69b Wei Huang 2024-10-02   88  	return 0;
d2e8a34876ce69b Wei Huang 2024-10-02   89  }
d2e8a34876ce69b Wei Huang 2024-10-02   90  
d2e8a34876ce69b Wei Huang 2024-10-02   91  #define TPH_ST_DSM_FUNC_INDEX	0xF
d2e8a34876ce69b Wei Huang 2024-10-02  @92  static acpi_status tph_invoke_dsm(acpi_handle handle, u32 cpu_uid,
d2e8a34876ce69b Wei Huang 2024-10-02   93  				  union st_info *st_out)
d2e8a34876ce69b Wei Huang 2024-10-02   94  {
d2e8a34876ce69b Wei Huang 2024-10-02   95  	union acpi_object arg3[3], in_obj, *out_obj;
d2e8a34876ce69b Wei Huang 2024-10-02   96  
d2e8a34876ce69b Wei Huang 2024-10-02   97  	if (!acpi_check_dsm(handle, &pci_acpi_dsm_guid, 7,
d2e8a34876ce69b Wei Huang 2024-10-02   98  			    BIT(TPH_ST_DSM_FUNC_INDEX)))
d2e8a34876ce69b Wei Huang 2024-10-02   99  		return AE_ERROR;
d2e8a34876ce69b Wei Huang 2024-10-02  100  
d2e8a34876ce69b Wei Huang 2024-10-02  101  	/* DWORD: feature ID (0 for processor cache ST query) */
d2e8a34876ce69b Wei Huang 2024-10-02  102  	arg3[0].integer.type = ACPI_TYPE_INTEGER;
d2e8a34876ce69b Wei Huang 2024-10-02  103  	arg3[0].integer.value = 0;
d2e8a34876ce69b Wei Huang 2024-10-02  104  
d2e8a34876ce69b Wei Huang 2024-10-02  105  	/* DWORD: target UID */
d2e8a34876ce69b Wei Huang 2024-10-02  106  	arg3[1].integer.type = ACPI_TYPE_INTEGER;
d2e8a34876ce69b Wei Huang 2024-10-02  107  	arg3[1].integer.value = cpu_uid;
d2e8a34876ce69b Wei Huang 2024-10-02  108  
d2e8a34876ce69b Wei Huang 2024-10-02  109  	/* QWORD: properties, all 0's */
d2e8a34876ce69b Wei Huang 2024-10-02  110  	arg3[2].integer.type = ACPI_TYPE_INTEGER;
d2e8a34876ce69b Wei Huang 2024-10-02  111  	arg3[2].integer.value = 0;
d2e8a34876ce69b Wei Huang 2024-10-02  112  
d2e8a34876ce69b Wei Huang 2024-10-02  113  	in_obj.type = ACPI_TYPE_PACKAGE;
d2e8a34876ce69b Wei Huang 2024-10-02  114  	in_obj.package.count = ARRAY_SIZE(arg3);
d2e8a34876ce69b Wei Huang 2024-10-02  115  	in_obj.package.elements = arg3;
d2e8a34876ce69b Wei Huang 2024-10-02  116  
d2e8a34876ce69b Wei Huang 2024-10-02  117  	out_obj = acpi_evaluate_dsm(handle, &pci_acpi_dsm_guid, 7,
d2e8a34876ce69b Wei Huang 2024-10-02  118  				    TPH_ST_DSM_FUNC_INDEX, &in_obj);
d2e8a34876ce69b Wei Huang 2024-10-02  119  	if (!out_obj)
d2e8a34876ce69b Wei Huang 2024-10-02  120  		return AE_ERROR;
d2e8a34876ce69b Wei Huang 2024-10-02  121  
d2e8a34876ce69b Wei Huang 2024-10-02  122  	if (out_obj->type != ACPI_TYPE_BUFFER) {
d2e8a34876ce69b Wei Huang 2024-10-02  123  		ACPI_FREE(out_obj);
d2e8a34876ce69b Wei Huang 2024-10-02  124  		return AE_ERROR;
d2e8a34876ce69b Wei Huang 2024-10-02  125  	}
d2e8a34876ce69b Wei Huang 2024-10-02  126  
d2e8a34876ce69b Wei Huang 2024-10-02  127  	st_out->value = *((u64 *)(out_obj->buffer.pointer));
d2e8a34876ce69b Wei Huang 2024-10-02  128  
d2e8a34876ce69b Wei Huang 2024-10-02  129  	ACPI_FREE(out_obj);
d2e8a34876ce69b Wei Huang 2024-10-02  130  
d2e8a34876ce69b Wei Huang 2024-10-02  131  	return AE_OK;
d2e8a34876ce69b Wei Huang 2024-10-02  132  }
d2e8a34876ce69b Wei Huang 2024-10-02  133  #endif
d2e8a34876ce69b Wei Huang 2024-10-02  134  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [PATCH v2] PCI/TPH: Fix get cpu steer-tag fail on ARM64 platform
  2026-03-03  0:36 [PATCH] PCI/TPH: Fix get cpu steer-tag fail on ARM64 platform Chengwen Feng
                   ` (4 preceding siblings ...)
  2026-03-05  1:29 ` kernel test robot
@ 2026-03-05  8:36 ` Chengwen Feng
  2026-03-05  8:53   ` Huacai Chen
  2026-03-06  2:19 ` [PATCH v3] " Chengwen Feng
  2026-03-09  4:16 ` [PATCH v4 0/2] " Chengwen Feng
  7 siblings, 1 reply; 26+ messages in thread
From: Chengwen Feng @ 2026-03-05  8:36 UTC (permalink / raw)
  To: linux-pci, bhelgaas, Jonathan Corbet, Shuah Khan, Catalin Marinas,
	Will Deacon, Huacai Chen, WANG Xuerui, Paul Walmsley,
	Palmer Dabbelt, Albert Ou, Alexandre Ghiti, Thomas Gleixner,
	Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
	Rafael J. Wysocki, Len Brown, Andy Gospodarek, Eric Van Tassell,
	Ajit Khaparde, Somnath Kotur
  Cc: linux-acpi, wei.huang2, jonathan.cameron, wangzhou1, wanghuiqiang,
	liuyonglong, stable, jeremy.linton, sunilvl, sunilvl, chenhuacai,
	wangliupu, Chengwen Feng, linux-doc, linux-kernel,
	linux-arm-kernel, loongarch, linux-riscv

Currently the pcie_tph_get_cpu_st() has an issue on ARM64 platform:
1. The pcie_tph_get_cpu_st() function directly uses cpu_uid as the input
   parameter to call the PCI ACPI DSM method. According to the DSM
   definition, the input value should be the ACPI Processor UID (see [1]
   for details).
2. In the Broadcom driver implementation [2] (which invokes
   pcie_tph_get_cpu_st()), cpu_uid is obtained via
   cpumask_first(irq->cpu_mask) - this is 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.
   As a result, the current implementation fails to retrieve the correct
   CPU steer-tag in such cases.
4. The function works on AMD x86 platforms only because the logical CPU
   ID is identical to the ACPI Processor UID on those systems.

This commit fixes it by:
1. Introducing acpi_get_cpu_acpi_id() in all ACPI-enabled platforms.
   This new API calls get_acpi_id_for_cpu() to retrieve the ACPI
   Processor UID on arm64/riscv/loongarch arch, and it calls
   cpu_acpi_id() on x86 arch.
2. Renaming pcie_tph_get_cpu_st()'s input parameter cpu_uid to cpu for
   clarity, as the parameter now represents a logical CPU ID (not a
   UID).

[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."
[2] commit c214410c47d6e ("bnxt_en: Add TPH support in BNXT driver")

Fixes: d2e8a34876ce ("PCI/TPH: Add Steering Tag support")
Cc: stable@vger.kernel.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>

---
Changes in v2:
- Add ECN _DSM reference doc name and its URL.
- Separate implement acpi_get_cpu_acpi_id() in each arch which supports
  ACPI.
- Refine commit-log.

---
 Documentation/PCI/tph.rst    |  4 ++--
 arch/arm64/kernel/acpi.c     |  9 +++++++++
 arch/loongarch/kernel/acpi.c |  9 +++++++++
 arch/riscv/kernel/acpi.c     | 10 ++++++++++
 arch/x86/kernel/cpu/common.c | 17 +++++++++++++++++
 drivers/pci/tph.c            | 17 ++++++++++++-----
 include/linux/acpi.h         | 10 ++++++++++
 include/linux/pci-tph.h      |  4 ++--
 8 files changed, 71 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/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
index af90128cfed5..e7d4d9bd3036 100644
--- a/arch/arm64/kernel/acpi.c
+++ b/arch/arm64/kernel/acpi.c
@@ -29,6 +29,7 @@
 #include <linux/suspend.h>
 #include <linux/pgtable.h>
 
+#include <acpi/acpi.h>
 #include <acpi/ghes.h>
 #include <acpi/processor.h>
 #include <asm/cputype.h>
@@ -458,3 +459,11 @@ int acpi_unmap_cpu(int cpu)
 }
 EXPORT_SYMBOL(acpi_unmap_cpu);
 #endif /* CONFIG_ACPI_HOTPLUG_CPU */
+
+int acpi_get_cpu_acpi_id(unsigned int cpu)
+{
+	if (cpu >= nr_cpu_ids || !cpu_possible(cpu))
+		return -EINVAL;
+	return get_acpi_id_for_cpu(cpu);
+}
+EXPORT_SYMBOL_GPL(acpi_get_cpu_acpi_id);
diff --git a/arch/loongarch/kernel/acpi.c b/arch/loongarch/kernel/acpi.c
index 1367ca759468..db28747a18e8 100644
--- a/arch/loongarch/kernel/acpi.c
+++ b/arch/loongarch/kernel/acpi.c
@@ -16,6 +16,7 @@
 #include <linux/memblock.h>
 #include <linux/of_fdt.h>
 #include <linux/serial_core.h>
+#include <asm/acpi.h>
 #include <asm/io.h>
 #include <asm/numa.h>
 #include <asm/loongson.h>
@@ -385,3 +386,11 @@ int acpi_unmap_cpu(int cpu)
 EXPORT_SYMBOL(acpi_unmap_cpu);
 
 #endif /* CONFIG_ACPI_HOTPLUG_CPU */
+
+int acpi_get_cpu_acpi_id(unsigned int cpu)
+{
+	if (cpu >= nr_cpu_ids || !cpu_possible(cpu))
+		return -EINVAL;
+	return get_acpi_id_for_cpu(cpu);
+}
+EXPORT_SYMBOL_GPL(acpi_get_cpu_acpi_id);
diff --git a/arch/riscv/kernel/acpi.c b/arch/riscv/kernel/acpi.c
index 71698ee11621..287c25e79347 100644
--- a/arch/riscv/kernel/acpi.c
+++ b/arch/riscv/kernel/acpi.c
@@ -22,6 +22,8 @@
 #include <linux/pci.h>
 #include <linux/serial_core.h>
 
+#include <asm/acpi.h>
+
 int acpi_noirq = 1;		/* skip ACPI IRQ initialization */
 int acpi_disabled = 1;
 EXPORT_SYMBOL(acpi_disabled);
@@ -337,3 +339,11 @@ int raw_pci_write(unsigned int domain, unsigned int bus,
 }
 
 #endif	/* CONFIG_PCI */
+
+int acpi_get_cpu_acpi_id(unsigned int cpu)
+{
+	if (cpu >= nr_cpu_ids || !cpu_possible(cpu))
+		return -EINVAL;
+	return get_acpi_id_for_cpu(cpu);
+}
+EXPORT_SYMBOL_GPL(acpi_get_cpu_acpi_id);
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index 1c3261cae40c..9b06c76d5c0c 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -28,6 +28,7 @@
 #include <linux/stackprotector.h>
 #include <linux/utsname.h>
 #include <linux/efi.h>
+#include <linux/acpi.h>
 
 #include <asm/alternative.h>
 #include <asm/cmdline.h>
@@ -57,6 +58,7 @@
 #include <asm/asm.h>
 #include <asm/bugs.h>
 #include <asm/cpu.h>
+#include <asm/smp.h>
 #include <asm/mce.h>
 #include <asm/msr.h>
 #include <asm/cacheinfo.h>
@@ -2643,3 +2645,18 @@ void __init arch_cpu_finalize_init(void)
 	 */
 	mem_encrypt_init();
 }
+
+int acpi_get_cpu_acpi_id(unsigned int cpu)
+{
+	u32 acpi_id;
+
+	if (cpu >= nr_cpu_ids || !cpu_possible(cpu))
+		return -EINVAL;
+
+	acpi_id = cpu_acpi_id(cpu);
+	if (acpi_id == CPU_ACPIID_INVALID)
+		return -ENODEV;
+
+	return (int)acpi_id;
+}
+EXPORT_SYMBOL_GPL(acpi_get_cpu_acpi_id);
diff --git a/drivers/pci/tph.c b/drivers/pci/tph.c
index ca4f97be7538..3cd38972fcb1 100644
--- a/drivers/pci/tph.c
+++ b/drivers/pci/tph.c
@@ -236,21 +236,28 @@ 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
+	unsigned int cpu_uid;
 	struct pci_dev *rp;
 	acpi_handle rp_acpi_handle;
 	union st_info info;
+	int ret;
+
+	ret = acpi_get_cpu_acpi_id(cpu);
+	if (ret < 0)
+		return ret;
+	cpu_uid = (unsigned int)ret;
 
 	rp = pcie_find_root_port(pdev);
 	if (!rp || !rp->bus || !rp->bus->bridge)
@@ -265,9 +272,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/acpi.h b/include/linux/acpi.h
index 4d2f0bed7a06..426fb4dca333 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -324,6 +324,16 @@ int acpi_unmap_cpu(int cpu);
 
 acpi_handle acpi_get_processor_handle(int cpu);
 
+/*
+ * acpi_get_cpu_acpi_id() - Get ACPI Processor UID of a specified CPU from MADT table
+ * @cpu: Logical CPU number (0-based)
+ *
+ * Return: ACPI Processor ID of the CPU on success (non-negative);
+ *         -EINVAL if the CPU number is invalid or not possible;
+ *         -ENODEV if the ACPI ID of the CPU is invalid.
+ */
+int acpi_get_cpu_acpi_id(unsigned int cpu);
+
 #ifdef CONFIG_ACPI_HOTPLUG_IOAPIC
 int acpi_get_ioapic_id(acpi_handle handle, u32 gsi_base, u64 *phys_addr);
 #endif
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] 26+ messages in thread

* Re: [PATCH] PCI/TPH: Fix get cpu steer-tag fail on ARM64 platform
  2026-03-04 15:38     ` Bjorn Helgaas
@ 2026-03-05  8:40       ` fengchengwen
  0 siblings, 0 replies; 26+ messages in thread
From: fengchengwen @ 2026-03-05  8:40 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: linux-pci, bhelgaas, linux-acpi, rafael, lenb, wei.huang2,
	Eric.VanTassell, jonathan.cameron, wangzhou1, wanghuiqiang,
	liuyonglong, stable, Jeremy Linton, Sunil V L, Sunil V L,
	Huacai Chen, Liupu Wang

On 3/4/2026 11:38 PM, Bjorn Helgaas wrote:
> On Wed, Mar 04, 2026 at 05:28:36PM +0800, fengchengwen wrote:
>> On 3/4/2026 3:02 AM, Bjorn Helgaas wrote:
>>> [+cc Jeremy, Sunil, Huacai, Liupu, authors of get_acpi_id_for_cpu()
>>> for arm64, riscv, loongson]
>>>
>>> On Tue, Mar 03, 2026 at 08:36:25AM +0800, Chengwen Feng wrote:
>>>> Currently the pcie_tph_get_cpu_st() has a problem on ARM64 platform:
>>>> 1. The pcie_tph_get_cpu_st() function directly uses cpu_uid as the input
>>>>    parameter to call the PCI ACPI DSM method. According to the DSM
>>>>    definition, the input value should be the ACPI Processor UID. For
>>>>    details, please see [1].
>>>>
>>>> 2. In the Broadcom driver implementation [2] (which invoke
>>>>    pcie_tph_get_cpu_st()), cpu_uid is obtained based on
>>>>    cpumask_first(irq->cpu_mask), that is the logical ID of a CPU core,
>>>>    which is generated and managed by the kernel. For example, [0,255]
>>>>    if the system has 256 logical CPU cores.
>>>> 3. Unfortunately, on ARM64 platform, ACPI assigns Processor UID to the
>>>>    core which listed in the MADT table, the Processor UID may not equal
>>>>    the logical ID of a CPU core in the kernel. So the current
>>>>    implementation cannot obtain the cpu's real steer-tag in such case.
>>>> 4. The reason why it can run on the AMD platform is that the mapping
>>>>    between the logical ID and ACPI Processor UID is similar.
>>>>
>>>> This commit fixes it by:
>>>> 1. Introduce config ARCH_HAS_GET_CPU_ACPI_ID_API and its corresponding
>>>>    API acpi_get_cpu_acpi_id() to obtain the ACPI Processor UID of a CPU
>>>>    core. This API invokes get_acpi_id_for_cpu() to obtain the UID on
>>>>    ARM64 platform.
>>>> 2. Because using the logical ID as the ACPI Processor UID directly on
>>>>    X86 platform is not standard. This commit uses cpu_acpi_id() to
>>>>    obtain the UID.
>>>> 3. At the same time, the input parameter cpu_uid of
>>>>    pcie_tph_get_cpu_st() is renamed to cpu for clarity.
>>>
>>> Thanks for raising this issue!
>>>
>>> TLP Processing Hints (TPH) and Steering Tags are generic PCIe features
>>> that we should support for both ACPI and non-ACPI systems.
>>>
>>> The current implementation of pcie_tph_get_cpu_st() only supports
>>> ACPI, and it assumes the cpu_uid parameter is an ACPI CPU UID that can
>>> be passed directly to the _DSM.  But since we want this to be a
>>> generic interface, I think the "cpu" parameter should be the Linux
>>> logical CPU ID, not an ACPI UID, as you point out.
>> ...
> 
>>>>  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
>>>> +#ifdef CONFIG_ARCH_HAS_GET_CPU_ACPI_ID_API
>>>> +	unsigned int cpu_uid = acpi_get_cpu_acpi_id(cpu);
>>>
>>> Any required conversion between Linux logical CPU and ACPI CPU UID
>>> should be internal to pcie_tph_get_cpu_st(), as you're doing here.
>>>
>>> But rather than adding CONFIG_ARCH_HAS_GET_CPU_ACPI_ID_API and the
>>> ifdefs in acpi_get_cpu_acpi_id(), I think there should be a generic
>>> ACPI interface that converts logical CPU ID to ACPI UID, and every
>>> arch supporting ACPI should have to implement it.
>>>
>>> We already have get_acpi_id_for_cpu(), implemented for arm64, riscv,
>>> and loongarch:
>>>
>>>   30d87bfacbee ("arm64/acpi: Create arch specific cpu to acpi id helper")
>>>   f99561199470 ("RISC-V: ACPI: Cache and retrieve the RINTC structure")
>>>   f6f0c9a74a48 ("LoongArch: Add SMT (Simultaneous Multi-Threading) support")
>>>
>>> What if we just implemented it for x86 as well and moved it to
>>> include/linux/acpi.h or similar?
>>
>> Your idea to unify the ACPI CPU ID function across architectures is
>> great. I noticed that all exported ACPI functions use the `acpi_`
>> prefix, so I think we shouldn’t simply modify x86’s implementation
>> directly – we should also align the naming convention for other
>> platforms.
>>
>> Since only x86, arm64, risc-v, and loongarch currently support ACPI,
>> how about we remove the new config and instead use this approach:
>>
>> unsigned int acpi_get_cpu_acpi_id(unsigned int cpu)
>> {
>>         if (cpu >= nr_cpu_ids)
>>                 return 0;
>> #ifdef CONFIG_X86
>>         return cpu_acpi_id(cpu);
>> #elif defined(CONFIG_ARM64) || defined(CONFIG_RISCV) || defined(CONFIG_LOONGARCH)
>>         return get_acpi_id_for_cpu(cpu);
>> #endif
>> }
>>
>> For any new platform that plans to support ACPI in the future, this
>> will trigger a compile error – which is intentional. It will prompt
>> the maintainers of that platform to add their own implementation of
>> either `get_acpi_id_for_cpu` or `cpu_acpi_id` as needed.
> 
> I agree that an "acpi_" prefix would be appropriate.  I'd suggest
> separate implementations in arch/*/kernel/acpi.c instead of #ifdefs in
> a common version.

Hi, I have sent out v2 as requested. Please review, thanks.

> 
> Maybe users of cpu_acpi_id() and get_acpi_id_for_cpu() could be
> converted to use the generic interface.
> 


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v2] PCI/TPH: Fix get cpu steer-tag fail on ARM64 platform
  2026-03-05  8:36 ` [PATCH v2] " Chengwen Feng
@ 2026-03-05  8:53   ` Huacai Chen
  2026-03-05  9:07     ` fengchengwen
  0 siblings, 1 reply; 26+ messages in thread
From: Huacai Chen @ 2026-03-05  8:53 UTC (permalink / raw)
  To: Chengwen Feng
  Cc: linux-pci, bhelgaas, Jonathan Corbet, Shuah Khan, Catalin Marinas,
	Will Deacon, WANG Xuerui, Paul Walmsley, Palmer Dabbelt,
	Albert Ou, Alexandre Ghiti, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
	Rafael J. Wysocki, Len Brown, Andy Gospodarek, Eric Van Tassell,
	Ajit Khaparde, Somnath Kotur, linux-acpi, wei.huang2,
	jonathan.cameron, wangzhou1, wanghuiqiang, liuyonglong, stable,
	jeremy.linton, sunilvl, sunilvl, chenhuacai, wangliupu, linux-doc,
	linux-kernel, linux-arm-kernel, loongarch, linux-riscv

Hi, Chengwen,

On Thu, Mar 5, 2026 at 4:37 PM Chengwen Feng <fengchengwen@huawei.com> wrote:
>
> Currently the pcie_tph_get_cpu_st() has an issue on ARM64 platform:
> 1. The pcie_tph_get_cpu_st() function directly uses cpu_uid as the input
>    parameter to call the PCI ACPI DSM method. According to the DSM
>    definition, the input value should be the ACPI Processor UID (see [1]
>    for details).
> 2. In the Broadcom driver implementation [2] (which invokes
>    pcie_tph_get_cpu_st()), cpu_uid is obtained via
>    cpumask_first(irq->cpu_mask) - this is 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.
>    As a result, the current implementation fails to retrieve the correct
>    CPU steer-tag in such cases.
> 4. The function works on AMD x86 platforms only because the logical CPU
>    ID is identical to the ACPI Processor UID on those systems.
>
> This commit fixes it by:
> 1. Introducing acpi_get_cpu_acpi_id() in all ACPI-enabled platforms.
>    This new API calls get_acpi_id_for_cpu() to retrieve the ACPI
>    Processor UID on arm64/riscv/loongarch arch, and it calls
>    cpu_acpi_id() on x86 arch.
> 2. Renaming pcie_tph_get_cpu_st()'s input parameter cpu_uid to cpu for
>    clarity, as the parameter now represents a logical CPU ID (not a
>    UID).
>
> [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."
> [2] commit c214410c47d6e ("bnxt_en: Add TPH support in BNXT driver")
>
> Fixes: d2e8a34876ce ("PCI/TPH: Add Steering Tag support")
> Cc: stable@vger.kernel.org
> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
>
> ---
> Changes in v2:
> - Add ECN _DSM reference doc name and its URL.
> - Separate implement acpi_get_cpu_acpi_id() in each arch which supports
>   ACPI.
> - Refine commit-log.
>
> ---
>  Documentation/PCI/tph.rst    |  4 ++--
>  arch/arm64/kernel/acpi.c     |  9 +++++++++
>  arch/loongarch/kernel/acpi.c |  9 +++++++++
>  arch/riscv/kernel/acpi.c     | 10 ++++++++++
>  arch/x86/kernel/cpu/common.c | 17 +++++++++++++++++
>  drivers/pci/tph.c            | 17 ++++++++++++-----
>  include/linux/acpi.h         | 10 ++++++++++
>  include/linux/pci-tph.h      |  4 ++--
>  8 files changed, 71 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/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
> index af90128cfed5..e7d4d9bd3036 100644
> --- a/arch/arm64/kernel/acpi.c
> +++ b/arch/arm64/kernel/acpi.c
> @@ -29,6 +29,7 @@
>  #include <linux/suspend.h>
>  #include <linux/pgtable.h>
>
> +#include <acpi/acpi.h>
>  #include <acpi/ghes.h>
>  #include <acpi/processor.h>
>  #include <asm/cputype.h>
> @@ -458,3 +459,11 @@ int acpi_unmap_cpu(int cpu)
>  }
>  EXPORT_SYMBOL(acpi_unmap_cpu);
>  #endif /* CONFIG_ACPI_HOTPLUG_CPU */
> +
> +int acpi_get_cpu_acpi_id(unsigned int cpu)
> +{
> +       if (cpu >= nr_cpu_ids || !cpu_possible(cpu))
> +               return -EINVAL;
> +       return get_acpi_id_for_cpu(cpu);
> +}
> +EXPORT_SYMBOL_GPL(acpi_get_cpu_acpi_id);
> diff --git a/arch/loongarch/kernel/acpi.c b/arch/loongarch/kernel/acpi.c
> index 1367ca759468..db28747a18e8 100644
> --- a/arch/loongarch/kernel/acpi.c
> +++ b/arch/loongarch/kernel/acpi.c
> @@ -16,6 +16,7 @@
>  #include <linux/memblock.h>
>  #include <linux/of_fdt.h>
>  #include <linux/serial_core.h>
> +#include <asm/acpi.h>
>  #include <asm/io.h>
>  #include <asm/numa.h>
>  #include <asm/loongson.h>
> @@ -385,3 +386,11 @@ int acpi_unmap_cpu(int cpu)
>  EXPORT_SYMBOL(acpi_unmap_cpu);
>
>  #endif /* CONFIG_ACPI_HOTPLUG_CPU */
> +
> +int acpi_get_cpu_acpi_id(unsigned int cpu)
> +{
> +       if (cpu >= nr_cpu_ids || !cpu_possible(cpu))
> +               return -EINVAL;
> +       return get_acpi_id_for_cpu(cpu);
> +}
> +EXPORT_SYMBOL_GPL(acpi_get_cpu_acpi_id);
> diff --git a/arch/riscv/kernel/acpi.c b/arch/riscv/kernel/acpi.c
> index 71698ee11621..287c25e79347 100644
> --- a/arch/riscv/kernel/acpi.c
> +++ b/arch/riscv/kernel/acpi.c
> @@ -22,6 +22,8 @@
>  #include <linux/pci.h>
>  #include <linux/serial_core.h>
>
> +#include <asm/acpi.h>
> +
>  int acpi_noirq = 1;            /* skip ACPI IRQ initialization */
>  int acpi_disabled = 1;
>  EXPORT_SYMBOL(acpi_disabled);
> @@ -337,3 +339,11 @@ int raw_pci_write(unsigned int domain, unsigned int bus,
>  }
>
>  #endif /* CONFIG_PCI */
> +
> +int acpi_get_cpu_acpi_id(unsigned int cpu)
> +{
> +       if (cpu >= nr_cpu_ids || !cpu_possible(cpu))
> +               return -EINVAL;
> +       return get_acpi_id_for_cpu(cpu);
> +}
> +EXPORT_SYMBOL_GPL(acpi_get_cpu_acpi_id);
> diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
> index 1c3261cae40c..9b06c76d5c0c 100644
> --- a/arch/x86/kernel/cpu/common.c
> +++ b/arch/x86/kernel/cpu/common.c
> @@ -28,6 +28,7 @@
>  #include <linux/stackprotector.h>
>  #include <linux/utsname.h>
>  #include <linux/efi.h>
> +#include <linux/acpi.h>
>
>  #include <asm/alternative.h>
>  #include <asm/cmdline.h>
> @@ -57,6 +58,7 @@
>  #include <asm/asm.h>
>  #include <asm/bugs.h>
>  #include <asm/cpu.h>
> +#include <asm/smp.h>
>  #include <asm/mce.h>
>  #include <asm/msr.h>
>  #include <asm/cacheinfo.h>
> @@ -2643,3 +2645,18 @@ void __init arch_cpu_finalize_init(void)
>          */
>         mem_encrypt_init();
>  }
> +
> +int acpi_get_cpu_acpi_id(unsigned int cpu)
> +{
> +       u32 acpi_id;
> +
> +       if (cpu >= nr_cpu_ids || !cpu_possible(cpu))
> +               return -EINVAL;
> +
> +       acpi_id = cpu_acpi_id(cpu);
> +       if (acpi_id == CPU_ACPIID_INVALID)
> +               return -ENODEV;
> +
> +       return (int)acpi_id;
> +}
> +EXPORT_SYMBOL_GPL(acpi_get_cpu_acpi_id);
> diff --git a/drivers/pci/tph.c b/drivers/pci/tph.c
> index ca4f97be7538..3cd38972fcb1 100644
> --- a/drivers/pci/tph.c
> +++ b/drivers/pci/tph.c
> @@ -236,21 +236,28 @@ 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
> +       unsigned int cpu_uid;
>         struct pci_dev *rp;
>         acpi_handle rp_acpi_handle;
>         union st_info info;
> +       int ret;
> +
> +       ret = acpi_get_cpu_acpi_id(cpu);
Can we use get_acpi_id_for_cpu() directly? Then just x86 needs a wrapper.

Huacai

> +       if (ret < 0)
> +               return ret;
> +       cpu_uid = (unsigned int)ret;
>
>         rp = pcie_find_root_port(pdev);
>         if (!rp || !rp->bus || !rp->bus->bridge)
> @@ -265,9 +272,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/acpi.h b/include/linux/acpi.h
> index 4d2f0bed7a06..426fb4dca333 100644
> --- a/include/linux/acpi.h
> +++ b/include/linux/acpi.h
> @@ -324,6 +324,16 @@ int acpi_unmap_cpu(int cpu);
>
>  acpi_handle acpi_get_processor_handle(int cpu);
>
> +/*
> + * acpi_get_cpu_acpi_id() - Get ACPI Processor UID of a specified CPU from MADT table
> + * @cpu: Logical CPU number (0-based)
> + *
> + * Return: ACPI Processor ID of the CPU on success (non-negative);
> + *         -EINVAL if the CPU number is invalid or not possible;
> + *         -ENODEV if the ACPI ID of the CPU is invalid.
> + */
> +int acpi_get_cpu_acpi_id(unsigned int cpu);
> +
>  #ifdef CONFIG_ACPI_HOTPLUG_IOAPIC
>  int acpi_get_ioapic_id(acpi_handle handle, u32 gsi_base, u64 *phys_addr);
>  #endif
> 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] 26+ messages in thread

* Re: [PATCH v2] PCI/TPH: Fix get cpu steer-tag fail on ARM64 platform
  2026-03-05  8:53   ` Huacai Chen
@ 2026-03-05  9:07     ` fengchengwen
  2026-03-05 14:54       ` Jonathan Cameron
  0 siblings, 1 reply; 26+ messages in thread
From: fengchengwen @ 2026-03-05  9:07 UTC (permalink / raw)
  To: Huacai Chen
  Cc: linux-pci, bhelgaas, Jonathan Corbet, Shuah Khan, Catalin Marinas,
	Will Deacon, WANG Xuerui, Paul Walmsley, Palmer Dabbelt,
	Albert Ou, Alexandre Ghiti, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
	Rafael J. Wysocki, Len Brown, Andy Gospodarek, Eric Van Tassell,
	Ajit Khaparde, Somnath Kotur, linux-acpi, wei.huang2,
	jonathan.cameron, wangzhou1, wanghuiqiang, liuyonglong, stable,
	jeremy.linton, sunilvl, sunilvl, chenhuacai, wangliupu, linux-doc,
	linux-kernel, linux-arm-kernel, loongarch, linux-riscv

Hi Huacai,

On 3/5/2026 4:53 PM, Huacai Chen wrote:
> Hi, Chengwen,
> 
> On Thu, Mar 5, 2026 at 4:37 PM Chengwen Feng <fengchengwen@huawei.com> wrote:
>>
>> Currently the pcie_tph_get_cpu_st() has an issue on ARM64 platform:
>> 1. The pcie_tph_get_cpu_st() function directly uses cpu_uid as the input
>>    parameter to call the PCI ACPI DSM method. According to the DSM
>>    definition, the input value should be the ACPI Processor UID (see [1]
>>    for details).
>> 2. In the Broadcom driver implementation [2] (which invokes
>>    pcie_tph_get_cpu_st()), cpu_uid is obtained via
>>    cpumask_first(irq->cpu_mask) - this is 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.
>>    As a result, the current implementation fails to retrieve the correct
>>    CPU steer-tag in such cases.
>> 4. The function works on AMD x86 platforms only because the logical CPU
>>    ID is identical to the ACPI Processor UID on those systems.
>>
>> This commit fixes it by:
>> 1. Introducing acpi_get_cpu_acpi_id() in all ACPI-enabled platforms.
>>    This new API calls get_acpi_id_for_cpu() to retrieve the ACPI
>>    Processor UID on arm64/riscv/loongarch arch, and it calls
>>    cpu_acpi_id() on x86 arch.
>> 2. Renaming pcie_tph_get_cpu_st()'s input parameter cpu_uid to cpu for
>>    clarity, as the parameter now represents a logical CPU ID (not a
>>    UID).
>>
>> [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."
>> [2] commit c214410c47d6e ("bnxt_en: Add TPH support in BNXT driver")
>>
>> Fixes: d2e8a34876ce ("PCI/TPH: Add Steering Tag support")
>> Cc: stable@vger.kernel.org
>> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
>>
>> ---
>> Changes in v2:
>> - Add ECN _DSM reference doc name and its URL.
>> - Separate implement acpi_get_cpu_acpi_id() in each arch which supports
>>   ACPI.
>> - Refine commit-log.
>>
>> ---
>>  Documentation/PCI/tph.rst    |  4 ++--
>>  arch/arm64/kernel/acpi.c     |  9 +++++++++
>>  arch/loongarch/kernel/acpi.c |  9 +++++++++
>>  arch/riscv/kernel/acpi.c     | 10 ++++++++++
>>  arch/x86/kernel/cpu/common.c | 17 +++++++++++++++++
>>  drivers/pci/tph.c            | 17 ++++++++++++-----
>>  include/linux/acpi.h         | 10 ++++++++++
>>  include/linux/pci-tph.h      |  4 ++--
>>  8 files changed, 71 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/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
>> index af90128cfed5..e7d4d9bd3036 100644
>> --- a/arch/arm64/kernel/acpi.c
>> +++ b/arch/arm64/kernel/acpi.c
>> @@ -29,6 +29,7 @@
>>  #include <linux/suspend.h>
>>  #include <linux/pgtable.h>
>>
>> +#include <acpi/acpi.h>
>>  #include <acpi/ghes.h>
>>  #include <acpi/processor.h>
>>  #include <asm/cputype.h>
>> @@ -458,3 +459,11 @@ int acpi_unmap_cpu(int cpu)
>>  }
>>  EXPORT_SYMBOL(acpi_unmap_cpu);
>>  #endif /* CONFIG_ACPI_HOTPLUG_CPU */
>> +
>> +int acpi_get_cpu_acpi_id(unsigned int cpu)
>> +{
>> +       if (cpu >= nr_cpu_ids || !cpu_possible(cpu))
>> +               return -EINVAL;
>> +       return get_acpi_id_for_cpu(cpu);
>> +}
>> +EXPORT_SYMBOL_GPL(acpi_get_cpu_acpi_id);
>> diff --git a/arch/loongarch/kernel/acpi.c b/arch/loongarch/kernel/acpi.c
>> index 1367ca759468..db28747a18e8 100644
>> --- a/arch/loongarch/kernel/acpi.c
>> +++ b/arch/loongarch/kernel/acpi.c
>> @@ -16,6 +16,7 @@
>>  #include <linux/memblock.h>
>>  #include <linux/of_fdt.h>
>>  #include <linux/serial_core.h>
>> +#include <asm/acpi.h>
>>  #include <asm/io.h>
>>  #include <asm/numa.h>
>>  #include <asm/loongson.h>
>> @@ -385,3 +386,11 @@ int acpi_unmap_cpu(int cpu)
>>  EXPORT_SYMBOL(acpi_unmap_cpu);
>>
>>  #endif /* CONFIG_ACPI_HOTPLUG_CPU */
>> +
>> +int acpi_get_cpu_acpi_id(unsigned int cpu)
>> +{
>> +       if (cpu >= nr_cpu_ids || !cpu_possible(cpu))
>> +               return -EINVAL;
>> +       return get_acpi_id_for_cpu(cpu);
>> +}
>> +EXPORT_SYMBOL_GPL(acpi_get_cpu_acpi_id);
>> diff --git a/arch/riscv/kernel/acpi.c b/arch/riscv/kernel/acpi.c
>> index 71698ee11621..287c25e79347 100644
>> --- a/arch/riscv/kernel/acpi.c
>> +++ b/arch/riscv/kernel/acpi.c
>> @@ -22,6 +22,8 @@
>>  #include <linux/pci.h>
>>  #include <linux/serial_core.h>
>>
>> +#include <asm/acpi.h>
>> +
>>  int acpi_noirq = 1;            /* skip ACPI IRQ initialization */
>>  int acpi_disabled = 1;
>>  EXPORT_SYMBOL(acpi_disabled);
>> @@ -337,3 +339,11 @@ int raw_pci_write(unsigned int domain, unsigned int bus,
>>  }
>>
>>  #endif /* CONFIG_PCI */
>> +
>> +int acpi_get_cpu_acpi_id(unsigned int cpu)
>> +{
>> +       if (cpu >= nr_cpu_ids || !cpu_possible(cpu))
>> +               return -EINVAL;
>> +       return get_acpi_id_for_cpu(cpu);
>> +}
>> +EXPORT_SYMBOL_GPL(acpi_get_cpu_acpi_id);
>> diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
>> index 1c3261cae40c..9b06c76d5c0c 100644
>> --- a/arch/x86/kernel/cpu/common.c
>> +++ b/arch/x86/kernel/cpu/common.c
>> @@ -28,6 +28,7 @@
>>  #include <linux/stackprotector.h>
>>  #include <linux/utsname.h>
>>  #include <linux/efi.h>
>> +#include <linux/acpi.h>
>>
>>  #include <asm/alternative.h>
>>  #include <asm/cmdline.h>
>> @@ -57,6 +58,7 @@
>>  #include <asm/asm.h>
>>  #include <asm/bugs.h>
>>  #include <asm/cpu.h>
>> +#include <asm/smp.h>
>>  #include <asm/mce.h>
>>  #include <asm/msr.h>
>>  #include <asm/cacheinfo.h>
>> @@ -2643,3 +2645,18 @@ void __init arch_cpu_finalize_init(void)
>>          */
>>         mem_encrypt_init();
>>  }
>> +
>> +int acpi_get_cpu_acpi_id(unsigned int cpu)
>> +{
>> +       u32 acpi_id;
>> +
>> +       if (cpu >= nr_cpu_ids || !cpu_possible(cpu))
>> +               return -EINVAL;
>> +
>> +       acpi_id = cpu_acpi_id(cpu);
>> +       if (acpi_id == CPU_ACPIID_INVALID)
>> +               return -ENODEV;
>> +
>> +       return (int)acpi_id;
>> +}
>> +EXPORT_SYMBOL_GPL(acpi_get_cpu_acpi_id);
>> diff --git a/drivers/pci/tph.c b/drivers/pci/tph.c
>> index ca4f97be7538..3cd38972fcb1 100644
>> --- a/drivers/pci/tph.c
>> +++ b/drivers/pci/tph.c
>> @@ -236,21 +236,28 @@ 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
>> +       unsigned int cpu_uid;
>>         struct pci_dev *rp;
>>         acpi_handle rp_acpi_handle;
>>         union st_info info;
>> +       int ret;
>> +
>> +       ret = acpi_get_cpu_acpi_id(cpu);
> Can we use get_acpi_id_for_cpu() directly? Then just x86 needs a wrapper.

Yes, it indeed simple.

But I prefer to have the acpi_ prefix for such API names because it's a cross-subsystem API reference.

Thanks

> 
> Huacai
> 
>> +       if (ret < 0)
>> +               return ret;
>> +       cpu_uid = (unsigned int)ret;
>>
>>         rp = pcie_find_root_port(pdev);
>>         if (!rp || !rp->bus || !rp->bus->bridge)
>> @@ -265,9 +272,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/acpi.h b/include/linux/acpi.h
>> index 4d2f0bed7a06..426fb4dca333 100644
>> --- a/include/linux/acpi.h
>> +++ b/include/linux/acpi.h
>> @@ -324,6 +324,16 @@ int acpi_unmap_cpu(int cpu);
>>
>>  acpi_handle acpi_get_processor_handle(int cpu);
>>
>> +/*
>> + * acpi_get_cpu_acpi_id() - Get ACPI Processor UID of a specified CPU from MADT table
>> + * @cpu: Logical CPU number (0-based)
>> + *
>> + * Return: ACPI Processor ID of the CPU on success (non-negative);
>> + *         -EINVAL if the CPU number is invalid or not possible;
>> + *         -ENODEV if the ACPI ID of the CPU is invalid.
>> + */
>> +int acpi_get_cpu_acpi_id(unsigned int cpu);
>> +
>>  #ifdef CONFIG_ACPI_HOTPLUG_IOAPIC
>>  int acpi_get_ioapic_id(acpi_handle handle, u32 gsi_base, u64 *phys_addr);
>>  #endif
>> 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] 26+ messages in thread

* Re: [PATCH v2] PCI/TPH: Fix get cpu steer-tag fail on ARM64 platform
  2026-03-05  9:07     ` fengchengwen
@ 2026-03-05 14:54       ` Jonathan Cameron
  2026-03-06  2:20         ` fengchengwen
  0 siblings, 1 reply; 26+ messages in thread
From: Jonathan Cameron @ 2026-03-05 14:54 UTC (permalink / raw)
  To: fengchengwen
  Cc: Huacai Chen, linux-pci, bhelgaas, Jonathan Corbet, Shuah Khan,
	Catalin Marinas, Will Deacon, WANG Xuerui, Paul Walmsley,
	Palmer Dabbelt, Albert Ou, Alexandre Ghiti, Thomas Gleixner,
	Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
	Rafael J. Wysocki, Len Brown, Andy Gospodarek, Eric Van Tassell,
	Ajit Khaparde, Somnath Kotur, linux-acpi, wei.huang2, wangzhou1,
	wanghuiqiang, liuyonglong, stable, jeremy.linton, sunilvl,
	sunilvl, chenhuacai, wangliupu, linux-doc, linux-kernel,
	linux-arm-kernel, loongarch, linux-riscv


> >> +       ret = acpi_get_cpu_acpi_id(cpu);  
> > Can we use get_acpi_id_for_cpu() directly? Then just x86 needs a wrapper.  
> 
> Yes, it indeed simple.
> 
> But I prefer to have the acpi_ prefix for such API names because it's a cross-subsystem API reference.

Can we just do a global rename of get_acpi_id_for_cpu() as a precursor
patch?  Then this just becomes adding x86 implementation and using
it on all architectures.

J



^ permalink raw reply	[flat|nested] 26+ messages in thread

* [PATCH v3] PCI/TPH: Fix get cpu steer-tag fail on ARM64 platform
  2026-03-03  0:36 [PATCH] PCI/TPH: Fix get cpu steer-tag fail on ARM64 platform Chengwen Feng
                   ` (5 preceding siblings ...)
  2026-03-05  8:36 ` [PATCH v2] " Chengwen Feng
@ 2026-03-06  2:19 ` Chengwen Feng
  2026-03-06 10:01   ` Jonathan Cameron
  2026-03-09  4:16 ` [PATCH v4 0/2] " Chengwen Feng
  7 siblings, 1 reply; 26+ messages in thread
From: Chengwen Feng @ 2026-03-06  2:19 UTC (permalink / raw)
  To: linux-pci, bhelgaas, Jonathan Corbet, Shuah Khan, Catalin Marinas,
	Will Deacon, Huacai Chen, WANG Xuerui, Paul Walmsley,
	Palmer Dabbelt, Albert Ou, Alexandre Ghiti, Thomas Gleixner,
	Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
	Rafael J. Wysocki, Len Brown, Sunil V L, Mark Rutland,
	Eric Van Tassell, Wei Huang, Ajit Khaparde, Andy Gospodarek
  Cc: linux-acpi, jonathan.cameron, wangzhou1, wanghuiqiang,
	liuyonglong, stable, jeremy.linton, sunilvl, chenhuacai,
	wangliupu, Chengwen Feng, Somnath Kotur, linux-doc, linux-kernel,
	linux-arm-kernel, loongarch, linux-riscv, linux-perf-users

Currently the pcie_tph_get_cpu_st() has an issue on ARM64 platform:
1. The pcie_tph_get_cpu_st() function directly uses cpu_uid as the input
   parameter to call the PCI ACPI DSM method. According to the DSM
   definition, the input value should be the ACPI Processor UID (see [1]
   for details).
2. In the Broadcom driver implementation [2] (which invokes
   pcie_tph_get_cpu_st()), cpu_uid is obtained via
   cpumask_first(irq->cpu_mask) - this is 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.
   As a result, the current implementation fails to retrieve the correct
   CPU steer-tag in such cases.
4. The function works on AMD x86 platforms only because the logical CPU
   ID is identical to the ACPI Processor UID on those systems.

This commit fixes it by:
1. For ACPI-enabled platforms, unify the CPU ACPI ID retrieval
   interface:
   - On arm64/riscv/loongarch: Rename existing get_acpi_id_for_cpu() to
     acpi_get_cpu_acpi_id().
   - On x86: Add new acpi_get_cpu_acpi_id() implementation that wraps
     cpu_acpi_id().
2. Update pcie_tph_get_cpu_st() to use acpi_get_cpu_acpi_id(cpu) to get
   valid ACPI Processor UID for DSM calls.
3. Renaming pcie_tph_get_cpu_st()'s input parameter cpu_uid to cpu for
   clarity, as the parameter now represents a logical CPU ID (not a
   UID).

[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."
[2] commit c214410c47d6e ("bnxt_en: Add TPH support in BNXT driver")

Fixes: d2e8a34876ce ("PCI/TPH: Add Steering Tag support")
Cc: stable@vger.kernel.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>

---
Changes in v3:
- Rename existing get_acpi_id_for_cpu() to acpi_get_cpu_acpi_id() other
  than add one new API.

Changes in v2:
- Add ECN _DSM reference doc name and its URL.
- Separate implement acpi_get_cpu_acpi_id() in each arch which supports
  ACPI.
- Refine commit-log.

---
 Documentation/PCI/tph.rst          |  4 ++--
 arch/arm64/include/asm/acpi.h      |  4 ++--
 arch/loongarch/include/asm/acpi.h  |  2 +-
 arch/riscv/include/asm/acpi.h      |  2 +-
 arch/riscv/kernel/acpi_numa.c      |  2 +-
 arch/x86/include/asm/acpi.h        |  2 ++
 arch/x86/kernel/cpu/common.c       |  8 ++++++++
 drivers/acpi/pptt.c                | 16 ++++++++--------
 drivers/acpi/riscv/rhct.c          |  2 +-
 drivers/pci/tph.c                  | 11 ++++++-----
 drivers/perf/arm_cspmu/arm_cspmu.c |  2 +-
 include/linux/pci-tph.h            |  4 ++--
 12 files changed, 35 insertions(+), 24 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/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h
index c07a58b96329..202107aeb05b 100644
--- a/arch/arm64/include/asm/acpi.h
+++ b/arch/arm64/include/asm/acpi.h
@@ -114,7 +114,7 @@ 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)
+static inline u32 acpi_get_cpu_acpi_id(unsigned int cpu)
 {
 	return	acpi_cpu_get_madt_gicc(cpu)->uid;
 }
@@ -125,7 +125,7 @@ static inline int get_cpu_for_acpi_id(u32 uid)
 
 	for (cpu = 0; cpu < nr_cpu_ids; cpu++)
 		if (acpi_cpu_get_madt_gicc(cpu) &&
-		    uid == get_acpi_id_for_cpu(cpu))
+		    uid == acpi_get_cpu_acpi_id(cpu))
 			return cpu;
 
 	return -EINVAL;
diff --git a/arch/loongarch/include/asm/acpi.h b/arch/loongarch/include/asm/acpi.h
index 7376840fa9f7..89c6c8f52cc3 100644
--- a/arch/loongarch/include/asm/acpi.h
+++ b/arch/loongarch/include/asm/acpi.h
@@ -40,7 +40,7 @@ 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)
+static inline u32 acpi_get_cpu_acpi_id(unsigned int cpu)
 {
 	return acpi_core_pic[cpu_logical_map(cpu)].processor_id;
 }
diff --git a/arch/riscv/include/asm/acpi.h b/arch/riscv/include/asm/acpi.h
index 6e13695120bc..1d23681b61b5 100644
--- a/arch/riscv/include/asm/acpi.h
+++ b/arch/riscv/include/asm/acpi.h
@@ -61,7 +61,7 @@ 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)
+static inline u32 acpi_get_cpu_acpi_id(int cpu)
 {
 	return acpi_cpu_get_madt_rintc(cpu)->uid;
 }
diff --git a/arch/riscv/kernel/acpi_numa.c b/arch/riscv/kernel/acpi_numa.c
index 130769e3a99c..c2eb4824d0f7 100644
--- a/arch/riscv/kernel/acpi_numa.c
+++ b/arch/riscv/kernel/acpi_numa.c
@@ -40,7 +40,7 @@ static inline int get_cpu_for_acpi_id(u32 uid)
 	int cpu;
 
 	for (cpu = 0; cpu < nr_cpu_ids; cpu++)
-		if (uid == get_acpi_id_for_cpu(cpu))
+		if (uid == acpi_get_cpu_acpi_id(cpu))
 			return cpu;
 
 	return -EINVAL;
diff --git a/arch/x86/include/asm/acpi.h b/arch/x86/include/asm/acpi.h
index a03aa6f999d1..b968369715c1 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;
 }
 
+u32 acpi_get_cpu_acpi_id(unsigned int cpu);
+
 #define ACPI_HAVE_ARCH_SET_ROOT_POINTER
 static __always_inline void acpi_arch_set_root_pointer(u64 addr)
 {
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index 1c3261cae40c..1c7aa7a4faa0 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -29,6 +29,7 @@
 #include <linux/utsname.h>
 #include <linux/efi.h>
 
+#include <asm/acpi.h>
 #include <asm/alternative.h>
 #include <asm/cmdline.h>
 #include <asm/cpuid/api.h>
@@ -57,6 +58,7 @@
 #include <asm/asm.h>
 #include <asm/bugs.h>
 #include <asm/cpu.h>
+#include <asm/smp.h>
 #include <asm/mce.h>
 #include <asm/msr.h>
 #include <asm/cacheinfo.h>
@@ -2643,3 +2645,9 @@ void __init arch_cpu_finalize_init(void)
 	 */
 	mem_encrypt_init();
 }
+
+u32 acpi_get_cpu_acpi_id(unsigned int cpu)
+{
+	return cpu_acpi_id(cpu);
+}
+EXPORT_SYMBOL_GPL(acpi_get_cpu_acpi_id);
diff --git a/drivers/acpi/pptt.c b/drivers/acpi/pptt.c
index de5f8c018333..c1a8fba4c2b2 100644
--- a/drivers/acpi/pptt.c
+++ b/drivers/acpi/pptt.c
@@ -459,7 +459,7 @@ 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 = acpi_get_cpu_acpi_id(cpu);
 	struct cacheinfo *this_leaf;
 	unsigned int index = 0;
 	struct acpi_pptt_processor *cpu_node = NULL;
@@ -546,7 +546,7 @@ 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 = acpi_get_cpu_acpi_id(cpu);
 
 	cpu_node = acpi_find_processor_node(table, acpi_cpu_id);
 	if (cpu_node) {
@@ -622,7 +622,7 @@ static int find_acpi_cpu_topology_tag(unsigned int cpu, int level, int flag)
 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 = acpi_get_cpu_acpi_id(cpu);
 	struct acpi_pptt_processor *cpu_node = NULL;
 	int ret = -ENOENT;
 
@@ -671,7 +671,7 @@ 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);
+	acpi_cpu_id = acpi_get_cpu_acpi_id(cpu);
 	cpu_node = acpi_find_processor_node(table, acpi_cpu_id);
 	if (!cpu_node)
 		return -ENOENT;
@@ -797,7 +797,7 @@ int find_acpi_cpu_topology_cluster(unsigned int cpu)
 	if (!table)
 		return -ENOENT;
 
-	acpi_cpu_id = get_acpi_id_for_cpu(cpu);
+	acpi_cpu_id = acpi_get_cpu_acpi_id(cpu);
 	cpu_node = acpi_find_processor_node(table, acpi_cpu_id);
 	if (!cpu_node || !cpu_node->parent)
 		return -ENOENT;
@@ -872,7 +872,7 @@ 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);
+		acpi_id = acpi_get_cpu_acpi_id(cpu);
 		cpu_node = acpi_find_processor_node(table_hdr, acpi_id);
 
 		while (cpu_node) {
@@ -966,7 +966,7 @@ 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 = acpi_get_cpu_acpi_id(cpu);
 		struct acpi_pptt_cache *cache;
 		struct acpi_pptt_processor *cpu_node;
 
@@ -1030,7 +1030,7 @@ 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 = acpi_get_cpu_acpi_id(cpu);
 		struct acpi_pptt_cache *cache;
 		struct acpi_pptt_processor *cpu_node;
 
diff --git a/drivers/acpi/riscv/rhct.c b/drivers/acpi/riscv/rhct.c
index caa2c16e1697..c15ce8c13136 100644
--- a/drivers/acpi/riscv/rhct.c
+++ b/drivers/acpi/riscv/rhct.c
@@ -44,7 +44,7 @@ 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 = acpi_get_cpu_acpi_id(cpu);
 
 	BUG_ON(acpi_disabled);
 
diff --git a/drivers/pci/tph.c b/drivers/pci/tph.c
index ca4f97be7538..c1bd60637b5a 100644
--- a/drivers/pci/tph.c
+++ b/drivers/pci/tph.c
@@ -236,18 +236,19 @@ 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
+	u32 cpu_uid = acpi_get_cpu_acpi_id(cpu);
 	struct pci_dev *rp;
 	acpi_handle rp_acpi_handle;
 	union st_info info;
@@ -265,9 +266,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/drivers/perf/arm_cspmu/arm_cspmu.c b/drivers/perf/arm_cspmu/arm_cspmu.c
index 34430b68f602..506b661c60fd 100644
--- a/drivers/perf/arm_cspmu/arm_cspmu.c
+++ b/drivers/perf/arm_cspmu/arm_cspmu.c
@@ -1115,7 +1115,7 @@ static int arm_cspmu_acpi_get_cpus(struct arm_cspmu *cspmu)
 	if (affinity_flag == ACPI_APMT_FLAGS_AFFINITY_PROC) {
 		for_each_possible_cpu(cpu) {
 			if (apmt_node->proc_affinity ==
-			    get_acpi_id_for_cpu(cpu)) {
+			    acpi_get_cpu_acpi_id(cpu)) {
 				cpumask_set_cpu(cpu, &cspmu->associated_cpus);
 				break;
 			}
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] 26+ messages in thread

* Re: [PATCH v2] PCI/TPH: Fix get cpu steer-tag fail on ARM64 platform
  2026-03-05 14:54       ` Jonathan Cameron
@ 2026-03-06  2:20         ` fengchengwen
  0 siblings, 0 replies; 26+ messages in thread
From: fengchengwen @ 2026-03-06  2:20 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Huacai Chen, linux-pci, bhelgaas, Jonathan Corbet, Shuah Khan,
	Catalin Marinas, Will Deacon, WANG Xuerui, Paul Walmsley,
	Palmer Dabbelt, Albert Ou, Alexandre Ghiti, Thomas Gleixner,
	Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
	Rafael J. Wysocki, Len Brown, Andy Gospodarek, Eric Van Tassell,
	Ajit Khaparde, Somnath Kotur, linux-acpi, wei.huang2, wangzhou1,
	wanghuiqiang, liuyonglong, stable, jeremy.linton, sunilvl,
	sunilvl, chenhuacai, wangliupu, linux-doc, linux-kernel,
	linux-arm-kernel, loongarch, linux-riscv

On 3/5/2026 10:54 PM, Jonathan Cameron wrote:
> 
>>>> +       ret = acpi_get_cpu_acpi_id(cpu);  
>>> Can we use get_acpi_id_for_cpu() directly? Then just x86 needs a wrapper.  
>>
>> Yes, it indeed simple.
>>
>> But I prefer to have the acpi_ prefix for such API names because it's a cross-subsystem API reference.
> 
> Can we just do a global rename of get_acpi_id_for_cpu() as a precursor
> patch?  Then this just becomes adding x86 implementation and using
> it on all architectures.

Sounds good, done in v3

Thanks

> 
> J
> 
> 


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v3] PCI/TPH: Fix get cpu steer-tag fail on ARM64 platform
  2026-03-06  2:19 ` [PATCH v3] " Chengwen Feng
@ 2026-03-06 10:01   ` Jonathan Cameron
  2026-03-09  4:18     ` fengchengwen
  0 siblings, 1 reply; 26+ messages in thread
From: Jonathan Cameron @ 2026-03-06 10:01 UTC (permalink / raw)
  To: Chengwen Feng
  Cc: linux-pci, bhelgaas, Jonathan Corbet, Shuah Khan, Catalin Marinas,
	Will Deacon, Huacai Chen, WANG Xuerui, Paul Walmsley,
	Palmer Dabbelt, Albert Ou, Alexandre Ghiti, Thomas Gleixner,
	Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
	Rafael J. Wysocki, Len Brown, Sunil V L, Mark Rutland,
	Eric Van Tassell, Wei Huang, Ajit Khaparde, Andy Gospodarek,
	linux-acpi, wangzhou1, wanghuiqiang, liuyonglong, stable,
	jeremy.linton, sunilvl, chenhuacai, wangliupu, Somnath Kotur,
	linux-doc, linux-kernel, linux-arm-kernel, loongarch, linux-riscv,
	linux-perf-users

On Fri, 6 Mar 2026 10:19:17 +0800
Chengwen Feng <fengchengwen@huawei.com> wrote:

> Currently the pcie_tph_get_cpu_st() has an issue on ARM64 platform:
> 1. The pcie_tph_get_cpu_st() function directly uses cpu_uid as the input
>    parameter to call the PCI ACPI DSM method. According to the DSM
>    definition, the input value should be the ACPI Processor UID (see [1]
>    for details).
> 2. In the Broadcom driver implementation [2] (which invokes
>    pcie_tph_get_cpu_st()), cpu_uid is obtained via
>    cpumask_first(irq->cpu_mask) - this is 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.
>    As a result, the current implementation fails to retrieve the correct
>    CPU steer-tag in such cases.
> 4. The function works on AMD x86 platforms only because the logical CPU
>    ID is identical to the ACPI Processor UID on those systems.
> 
> This commit fixes it by:
> 1. For ACPI-enabled platforms, unify the CPU ACPI ID retrieval
>    interface:
>    - On arm64/riscv/loongarch: Rename existing get_acpi_id_for_cpu() to
>      acpi_get_cpu_acpi_id().
>    - On x86: Add new acpi_get_cpu_acpi_id() implementation that wraps
>      cpu_acpi_id().
> 2. Update pcie_tph_get_cpu_st() to use acpi_get_cpu_acpi_id(cpu) to get
>    valid ACPI Processor UID for DSM calls.
> 3. Renaming pcie_tph_get_cpu_st()'s input parameter cpu_uid to cpu for
>    clarity, as the parameter now represents a logical CPU ID (not a
>    UID).
> 
> [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."
> [2] commit c214410c47d6e ("bnxt_en: Add TPH support in BNXT driver")
> 
> Fixes: d2e8a34876ce ("PCI/TPH: Add Steering Tag support")
> Cc: stable@vger.kernel.org
> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
> 
> ---
> Changes in v3:
> - Rename existing get_acpi_id_for_cpu() to acpi_get_cpu_acpi_id() other
>   than add one new API.
Ah. I wasn't clear around that rename suggestion.  Split this into two patches.
1) Rename
2) The new stuff plus x86 implementation.

> 
> Changes in v2:
> - Add ECN _DSM reference doc name and its URL.
> - Separate implement acpi_get_cpu_acpi_id() in each arch which supports
>   ACPI.
> - Refine commit-log.
> 
> ---
>  Documentation/PCI/tph.rst          |  4 ++--
>  arch/arm64/include/asm/acpi.h      |  4 ++--
>  arch/loongarch/include/asm/acpi.h  |  2 +-
>  arch/riscv/include/asm/acpi.h      |  2 +-
>  arch/riscv/kernel/acpi_numa.c      |  2 +-
>  arch/x86/include/asm/acpi.h        |  2 ++
>  arch/x86/kernel/cpu/common.c       |  8 ++++++++
>  drivers/acpi/pptt.c                | 16 ++++++++--------
>  drivers/acpi/riscv/rhct.c          |  2 +-
>  drivers/pci/tph.c                  | 11 ++++++-----
>  drivers/perf/arm_cspmu/arm_cspmu.c |  2 +-
>  include/linux/pci-tph.h            |  4 ++--
>  12 files changed, 35 insertions(+), 24 deletions(-)




^ permalink raw reply	[flat|nested] 26+ messages in thread

* [PATCH v4 0/2] Fix get cpu steer-tag fail on ARM64 platform
  2026-03-03  0:36 [PATCH] PCI/TPH: Fix get cpu steer-tag fail on ARM64 platform Chengwen Feng
                   ` (6 preceding siblings ...)
  2026-03-06  2:19 ` [PATCH v3] " Chengwen Feng
@ 2026-03-09  4:16 ` Chengwen Feng
  2026-03-09  4:16   ` [PATCH v4 1/2] ACPI: Rename get_acpi_id_for_cpu() to acpi_get_cpu_acpi_id() on non-x86 Chengwen Feng
                     ` (2 more replies)
  7 siblings, 3 replies; 26+ messages in thread
From: Chengwen Feng @ 2026-03-09  4:16 UTC (permalink / raw)
  To: linux-pci, bhelgaas, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	Alexandre Ghiti
  Cc: linux-acpi, rafael, lenb, wei.huang2, Eric.VanTassell,
	jonathan.cameron, wangzhou1, wanghuiqiang, liuyonglong, stable,
	jeremy.linton, sunilvl, sunilvl, chenhuacai, wangliupu,
	Chengwen Feng, linux-riscv

This patchset addresses the issue where retrieving the CPU steer-tag
fails on ARM64 platforms. The first commit is a pure renaming of the
ACPI CPU ID retrieval interface (no functional changes), which serves
as preparation for the second commit that implements the core fix for
the steer-tag retrieval logic.

---
Changes in v4:
- Split the rename into a separate commit.

Changes in v3:
- Rename existing get_acpi_id_for_cpu() to acpi_get_cpu_acpi_id() other
  than add one new API.

Changes in v2:
- Add ECN _DSM reference doc name and its URL.
- Separate implement acpi_get_cpu_acpi_id() in each arch which supports
  ACPI.
- Refine commit-log.

Chengwen Feng (2):
  ACPI: Rename get_acpi_id_for_cpu() to acpi_get_cpu_acpi_id() on
    non-x86
  PCI/TPH: Fix get cpu steer-tag fail on ARM64 platform

 Documentation/PCI/tph.rst          |  4 ++--
 arch/arm64/include/asm/acpi.h      |  4 ++--
 arch/loongarch/include/asm/acpi.h  |  2 +-
 arch/riscv/include/asm/acpi.h      |  2 +-
 arch/riscv/kernel/acpi_numa.c      |  2 +-
 arch/x86/include/asm/acpi.h        |  2 ++
 arch/x86/kernel/cpu/common.c       |  8 ++++++++
 drivers/acpi/pptt.c                | 16 ++++++++--------
 drivers/acpi/riscv/rhct.c          |  2 +-
 drivers/pci/tph.c                  | 11 ++++++-----
 drivers/perf/arm_cspmu/arm_cspmu.c |  2 +-
 include/linux/pci-tph.h            |  4 ++--
 12 files changed, 35 insertions(+), 24 deletions(-)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [PATCH v4 1/2] ACPI: Rename get_acpi_id_for_cpu() to acpi_get_cpu_acpi_id() on non-x86
  2026-03-09  4:16 ` [PATCH v4 0/2] " Chengwen Feng
@ 2026-03-09  4:16   ` Chengwen Feng
  2026-03-09 10:30     ` Jonathan Cameron
  2026-03-09 13:29     ` Huacai Chen
  2026-03-09  4:16   ` [PATCH v4 2/2] PCI/TPH: Fix get cpu steer-tag fail on ARM64 platform Chengwen Feng
  2026-03-09 10:28   ` [PATCH v4 0/2] " Jonathan Cameron
  2 siblings, 2 replies; 26+ messages in thread
From: Chengwen Feng @ 2026-03-09  4:16 UTC (permalink / raw)
  To: linux-pci, bhelgaas, Catalin Marinas, Will Deacon, Huacai Chen,
	WANG Xuerui, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	Alexandre Ghiti, Rafael J. Wysocki, Len Brown, Sunil V L,
	Mark Rutland
  Cc: linux-acpi, wei.huang2, Eric.VanTassell, jonathan.cameron,
	wangzhou1, wanghuiqiang, liuyonglong, stable, jeremy.linton,
	sunilvl, chenhuacai, wangliupu, Chengwen Feng, linux-arm-kernel,
	linux-kernel, loongarch, linux-riscv, linux-perf-users

To unify the CPU ACPI ID retrieval interface across architectures,
rename the existing get_acpi_id_for_cpu() function to
acpi_get_cpu_acpi_id() on arm64/riscv/loongarch platforms.

This is a pure rename with no functional change, preparing for a
consistent ACPI Processor UID retrieval interface across all ACPI-enabled
platforms.

Cc: stable@vger.kernel.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
 arch/arm64/include/asm/acpi.h      |  4 ++--
 arch/loongarch/include/asm/acpi.h  |  2 +-
 arch/riscv/include/asm/acpi.h      |  2 +-
 arch/riscv/kernel/acpi_numa.c      |  2 +-
 drivers/acpi/pptt.c                | 16 ++++++++--------
 drivers/acpi/riscv/rhct.c          |  2 +-
 drivers/perf/arm_cspmu/arm_cspmu.c |  2 +-
 7 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h
index c07a58b96329..202107aeb05b 100644
--- a/arch/arm64/include/asm/acpi.h
+++ b/arch/arm64/include/asm/acpi.h
@@ -114,7 +114,7 @@ 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)
+static inline u32 acpi_get_cpu_acpi_id(unsigned int cpu)
 {
 	return	acpi_cpu_get_madt_gicc(cpu)->uid;
 }
@@ -125,7 +125,7 @@ static inline int get_cpu_for_acpi_id(u32 uid)
 
 	for (cpu = 0; cpu < nr_cpu_ids; cpu++)
 		if (acpi_cpu_get_madt_gicc(cpu) &&
-		    uid == get_acpi_id_for_cpu(cpu))
+		    uid == acpi_get_cpu_acpi_id(cpu))
 			return cpu;
 
 	return -EINVAL;
diff --git a/arch/loongarch/include/asm/acpi.h b/arch/loongarch/include/asm/acpi.h
index 7376840fa9f7..89c6c8f52cc3 100644
--- a/arch/loongarch/include/asm/acpi.h
+++ b/arch/loongarch/include/asm/acpi.h
@@ -40,7 +40,7 @@ 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)
+static inline u32 acpi_get_cpu_acpi_id(unsigned int cpu)
 {
 	return acpi_core_pic[cpu_logical_map(cpu)].processor_id;
 }
diff --git a/arch/riscv/include/asm/acpi.h b/arch/riscv/include/asm/acpi.h
index 6e13695120bc..1d23681b61b5 100644
--- a/arch/riscv/include/asm/acpi.h
+++ b/arch/riscv/include/asm/acpi.h
@@ -61,7 +61,7 @@ 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)
+static inline u32 acpi_get_cpu_acpi_id(int cpu)
 {
 	return acpi_cpu_get_madt_rintc(cpu)->uid;
 }
diff --git a/arch/riscv/kernel/acpi_numa.c b/arch/riscv/kernel/acpi_numa.c
index 130769e3a99c..c2eb4824d0f7 100644
--- a/arch/riscv/kernel/acpi_numa.c
+++ b/arch/riscv/kernel/acpi_numa.c
@@ -40,7 +40,7 @@ static inline int get_cpu_for_acpi_id(u32 uid)
 	int cpu;
 
 	for (cpu = 0; cpu < nr_cpu_ids; cpu++)
-		if (uid == get_acpi_id_for_cpu(cpu))
+		if (uid == acpi_get_cpu_acpi_id(cpu))
 			return cpu;
 
 	return -EINVAL;
diff --git a/drivers/acpi/pptt.c b/drivers/acpi/pptt.c
index de5f8c018333..c1a8fba4c2b2 100644
--- a/drivers/acpi/pptt.c
+++ b/drivers/acpi/pptt.c
@@ -459,7 +459,7 @@ 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 = acpi_get_cpu_acpi_id(cpu);
 	struct cacheinfo *this_leaf;
 	unsigned int index = 0;
 	struct acpi_pptt_processor *cpu_node = NULL;
@@ -546,7 +546,7 @@ 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 = acpi_get_cpu_acpi_id(cpu);
 
 	cpu_node = acpi_find_processor_node(table, acpi_cpu_id);
 	if (cpu_node) {
@@ -622,7 +622,7 @@ static int find_acpi_cpu_topology_tag(unsigned int cpu, int level, int flag)
 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 = acpi_get_cpu_acpi_id(cpu);
 	struct acpi_pptt_processor *cpu_node = NULL;
 	int ret = -ENOENT;
 
@@ -671,7 +671,7 @@ 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);
+	acpi_cpu_id = acpi_get_cpu_acpi_id(cpu);
 	cpu_node = acpi_find_processor_node(table, acpi_cpu_id);
 	if (!cpu_node)
 		return -ENOENT;
@@ -797,7 +797,7 @@ int find_acpi_cpu_topology_cluster(unsigned int cpu)
 	if (!table)
 		return -ENOENT;
 
-	acpi_cpu_id = get_acpi_id_for_cpu(cpu);
+	acpi_cpu_id = acpi_get_cpu_acpi_id(cpu);
 	cpu_node = acpi_find_processor_node(table, acpi_cpu_id);
 	if (!cpu_node || !cpu_node->parent)
 		return -ENOENT;
@@ -872,7 +872,7 @@ 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);
+		acpi_id = acpi_get_cpu_acpi_id(cpu);
 		cpu_node = acpi_find_processor_node(table_hdr, acpi_id);
 
 		while (cpu_node) {
@@ -966,7 +966,7 @@ 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 = acpi_get_cpu_acpi_id(cpu);
 		struct acpi_pptt_cache *cache;
 		struct acpi_pptt_processor *cpu_node;
 
@@ -1030,7 +1030,7 @@ 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 = acpi_get_cpu_acpi_id(cpu);
 		struct acpi_pptt_cache *cache;
 		struct acpi_pptt_processor *cpu_node;
 
diff --git a/drivers/acpi/riscv/rhct.c b/drivers/acpi/riscv/rhct.c
index caa2c16e1697..c15ce8c13136 100644
--- a/drivers/acpi/riscv/rhct.c
+++ b/drivers/acpi/riscv/rhct.c
@@ -44,7 +44,7 @@ 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 = acpi_get_cpu_acpi_id(cpu);
 
 	BUG_ON(acpi_disabled);
 
diff --git a/drivers/perf/arm_cspmu/arm_cspmu.c b/drivers/perf/arm_cspmu/arm_cspmu.c
index 34430b68f602..506b661c60fd 100644
--- a/drivers/perf/arm_cspmu/arm_cspmu.c
+++ b/drivers/perf/arm_cspmu/arm_cspmu.c
@@ -1115,7 +1115,7 @@ static int arm_cspmu_acpi_get_cpus(struct arm_cspmu *cspmu)
 	if (affinity_flag == ACPI_APMT_FLAGS_AFFINITY_PROC) {
 		for_each_possible_cpu(cpu) {
 			if (apmt_node->proc_affinity ==
-			    get_acpi_id_for_cpu(cpu)) {
+			    acpi_get_cpu_acpi_id(cpu)) {
 				cpumask_set_cpu(cpu, &cspmu->associated_cpus);
 				break;
 			}
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH v4 2/2] PCI/TPH: Fix get cpu steer-tag fail on ARM64 platform
  2026-03-09  4:16 ` [PATCH v4 0/2] " Chengwen Feng
  2026-03-09  4:16   ` [PATCH v4 1/2] ACPI: Rename get_acpi_id_for_cpu() to acpi_get_cpu_acpi_id() on non-x86 Chengwen Feng
@ 2026-03-09  4:16   ` Chengwen Feng
  2026-03-09 10:59     ` Jonathan Cameron
  2026-03-09 10:28   ` [PATCH v4 0/2] " Jonathan Cameron
  2 siblings, 1 reply; 26+ messages in thread
From: Chengwen Feng @ 2026-03-09  4:16 UTC (permalink / raw)
  To: linux-pci, bhelgaas, Jonathan Corbet, Shuah Khan, Thomas Gleixner,
	Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
	Andy Gospodarek, Somnath Kotur, Wei Huang, Eric Van Tassell
  Cc: linux-acpi, rafael, lenb, jonathan.cameron, wangzhou1,
	wanghuiqiang, liuyonglong, stable, jeremy.linton, sunilvl,
	sunilvl, chenhuacai, wangliupu, Chengwen Feng, Ajit Khaparde,
	linux-doc, linux-kernel

Currently the pcie_tph_get_cpu_st() has an issue on ARM64 platform:
1. The pcie_tph_get_cpu_st() function directly uses cpu_uid as the input
   parameter to call the PCI ACPI DSM method. According to the DSM
   definition, the input value should be the ACPI Processor UID (see [1]
   for details).
2. In the Broadcom driver implementation [2] (which invokes
   pcie_tph_get_cpu_st()), cpu_uid is obtained via
   cpumask_first(irq->cpu_mask) - this is 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.
   As a result, the current implementation fails to retrieve the correct
   CPU steer-tag in such cases.
4. The function works on AMD x86 platforms only because the logical CPU
   ID is identical to the ACPI Processor UID on those systems.

This commit fixes it by:
1. Add new acpi_get_cpu_acpi_id() implementation on x86 that wraps
   cpu_acpi_id(), completing the unified ACPI CPU ID retrieval interface
   across ACPI-enabled platforms.
2. Update pcie_tph_get_cpu_st() to use acpi_get_cpu_acpi_id(cpu) to get
   valid ACPI Processor UID for DSM calls.
3. Renaming pcie_tph_get_cpu_st()'s input parameter cpu_uid to cpu for
   clarity, as the parameter now represents a logical CPU ID (not a
   UID).

[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."
[2] commit c214410c47d6e ("bnxt_en: Add TPH support in BNXT driver")

Fixes: d2e8a34876ce ("PCI/TPH: Add Steering Tag support")
Cc: stable@vger.kernel.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
 Documentation/PCI/tph.rst    |  4 ++--
 arch/x86/include/asm/acpi.h  |  2 ++
 arch/x86/kernel/cpu/common.c |  8 ++++++++
 drivers/pci/tph.c            | 11 ++++++-----
 include/linux/pci-tph.h      |  4 ++--
 5 files changed, 20 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/arch/x86/include/asm/acpi.h b/arch/x86/include/asm/acpi.h
index a03aa6f999d1..b968369715c1 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;
 }
 
+u32 acpi_get_cpu_acpi_id(unsigned int cpu);
+
 #define ACPI_HAVE_ARCH_SET_ROOT_POINTER
 static __always_inline void acpi_arch_set_root_pointer(u64 addr)
 {
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index 1c3261cae40c..1c7aa7a4faa0 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -29,6 +29,7 @@
 #include <linux/utsname.h>
 #include <linux/efi.h>
 
+#include <asm/acpi.h>
 #include <asm/alternative.h>
 #include <asm/cmdline.h>
 #include <asm/cpuid/api.h>
@@ -57,6 +58,7 @@
 #include <asm/asm.h>
 #include <asm/bugs.h>
 #include <asm/cpu.h>
+#include <asm/smp.h>
 #include <asm/mce.h>
 #include <asm/msr.h>
 #include <asm/cacheinfo.h>
@@ -2643,3 +2645,9 @@ void __init arch_cpu_finalize_init(void)
 	 */
 	mem_encrypt_init();
 }
+
+u32 acpi_get_cpu_acpi_id(unsigned int cpu)
+{
+	return cpu_acpi_id(cpu);
+}
+EXPORT_SYMBOL_GPL(acpi_get_cpu_acpi_id);
diff --git a/drivers/pci/tph.c b/drivers/pci/tph.c
index ca4f97be7538..c1bd60637b5a 100644
--- a/drivers/pci/tph.c
+++ b/drivers/pci/tph.c
@@ -236,18 +236,19 @@ 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
+	u32 cpu_uid = acpi_get_cpu_acpi_id(cpu);
 	struct pci_dev *rp;
 	acpi_handle rp_acpi_handle;
 	union st_info info;
@@ -265,9 +266,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] 26+ messages in thread

* Re: [PATCH v3] PCI/TPH: Fix get cpu steer-tag fail on ARM64 platform
  2026-03-06 10:01   ` Jonathan Cameron
@ 2026-03-09  4:18     ` fengchengwen
  0 siblings, 0 replies; 26+ messages in thread
From: fengchengwen @ 2026-03-09  4:18 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: linux-pci, bhelgaas, Jonathan Corbet, Shuah Khan, Catalin Marinas,
	Will Deacon, Huacai Chen, WANG Xuerui, Paul Walmsley,
	Palmer Dabbelt, Albert Ou, Alexandre Ghiti, Thomas Gleixner,
	Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
	Rafael J. Wysocki, Len Brown, Sunil V L, Mark Rutland,
	Eric Van Tassell, Wei Huang, Ajit Khaparde, Andy Gospodarek,
	linux-acpi, wangzhou1, wanghuiqiang, liuyonglong, stable,
	jeremy.linton, sunilvl, chenhuacai, wangliupu, Somnath Kotur,
	linux-doc, linux-kernel, linux-arm-kernel, loongarch, linux-riscv,
	linux-perf-users

On 3/6/2026 6:01 PM, Jonathan Cameron wrote:
> On Fri, 6 Mar 2026 10:19:17 +0800
> Chengwen Feng <fengchengwen@huawei.com> wrote:
> 
>> Currently the pcie_tph_get_cpu_st() has an issue on ARM64 platform:
>> 1. The pcie_tph_get_cpu_st() function directly uses cpu_uid as the input
>>    parameter to call the PCI ACPI DSM method. According to the DSM
>>    definition, the input value should be the ACPI Processor UID (see [1]
>>    for details).
>> 2. In the Broadcom driver implementation [2] (which invokes
>>    pcie_tph_get_cpu_st()), cpu_uid is obtained via
>>    cpumask_first(irq->cpu_mask) - this is 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.
>>    As a result, the current implementation fails to retrieve the correct
>>    CPU steer-tag in such cases.
>> 4. The function works on AMD x86 platforms only because the logical CPU
>>    ID is identical to the ACPI Processor UID on those systems.
>>
>> This commit fixes it by:
>> 1. For ACPI-enabled platforms, unify the CPU ACPI ID retrieval
>>    interface:
>>    - On arm64/riscv/loongarch: Rename existing get_acpi_id_for_cpu() to
>>      acpi_get_cpu_acpi_id().
>>    - On x86: Add new acpi_get_cpu_acpi_id() implementation that wraps
>>      cpu_acpi_id().
>> 2. Update pcie_tph_get_cpu_st() to use acpi_get_cpu_acpi_id(cpu) to get
>>    valid ACPI Processor UID for DSM calls.
>> 3. Renaming pcie_tph_get_cpu_st()'s input parameter cpu_uid to cpu for
>>    clarity, as the parameter now represents a logical CPU ID (not a
>>    UID).
>>
>> [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."
>> [2] commit c214410c47d6e ("bnxt_en: Add TPH support in BNXT driver")
>>
>> Fixes: d2e8a34876ce ("PCI/TPH: Add Steering Tag support")
>> Cc: stable@vger.kernel.org
>> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
>>
>> ---
>> Changes in v3:
>> - Rename existing get_acpi_id_for_cpu() to acpi_get_cpu_acpi_id() other
>>   than add one new API.
> Ah. I wasn't clear around that rename suggestion.  Split this into two patches.
> 1) Rename
> 2) The new stuff plus x86 implementation.

Hi Jonathan,

All fixes are applied in v4. Please review.

Thanks.

> 
>>
>> Changes in v2:
>> - Add ECN _DSM reference doc name and its URL.
>> - Separate implement acpi_get_cpu_acpi_id() in each arch which supports
>>   ACPI.
>> - Refine commit-log.
>>
>> ---
>>  Documentation/PCI/tph.rst          |  4 ++--
>>  arch/arm64/include/asm/acpi.h      |  4 ++--
>>  arch/loongarch/include/asm/acpi.h  |  2 +-
>>  arch/riscv/include/asm/acpi.h      |  2 +-
>>  arch/riscv/kernel/acpi_numa.c      |  2 +-
>>  arch/x86/include/asm/acpi.h        |  2 ++
>>  arch/x86/kernel/cpu/common.c       |  8 ++++++++
>>  drivers/acpi/pptt.c                | 16 ++++++++--------
>>  drivers/acpi/riscv/rhct.c          |  2 +-
>>  drivers/pci/tph.c                  | 11 ++++++-----
>>  drivers/perf/arm_cspmu/arm_cspmu.c |  2 +-
>>  include/linux/pci-tph.h            |  4 ++--
>>  12 files changed, 35 insertions(+), 24 deletions(-)
> 
> 
> 


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v4 0/2] Fix get cpu steer-tag fail on ARM64 platform
  2026-03-09  4:16 ` [PATCH v4 0/2] " Chengwen Feng
  2026-03-09  4:16   ` [PATCH v4 1/2] ACPI: Rename get_acpi_id_for_cpu() to acpi_get_cpu_acpi_id() on non-x86 Chengwen Feng
  2026-03-09  4:16   ` [PATCH v4 2/2] PCI/TPH: Fix get cpu steer-tag fail on ARM64 platform Chengwen Feng
@ 2026-03-09 10:28   ` Jonathan Cameron
  2026-03-10  3:26     ` fengchengwen
  2 siblings, 1 reply; 26+ messages in thread
From: Jonathan Cameron @ 2026-03-09 10:28 UTC (permalink / raw)
  To: Chengwen Feng
  Cc: linux-pci, bhelgaas, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	Alexandre Ghiti, linux-acpi, rafael, lenb, wei.huang2,
	Eric.VanTassell, wangzhou1, wanghuiqiang, liuyonglong, stable,
	jeremy.linton, sunilvl, sunilvl, chenhuacai, wangliupu,
	linux-riscv

On Mon, 9 Mar 2026 12:16:56 +0800
Chengwen Feng <fengchengwen@huawei.com> wrote:

> This patchset addresses the issue where retrieving the CPU steer-tag
> fails on ARM64 platforms. The first commit is a pure renaming of the
> ACPI CPU ID retrieval interface (no functional changes), which serves
> as preparation for the second commit that implements the core fix for
> the steer-tag retrieval logic.

Hi,

For future reference, please keep same lists +CC on every patch
(for a small series, send everything to everyone who gets any patch).
For me at least, that led to my filter putting patch 1 in a totally different
place from the rest and some confusion.

Also, don't send in reply to a previous version. Just start a new email
thread.  That both avoids deep nesting in email clients and generally
ensures your series ends up in the right place if people are sorting
by time of sending.

No need to resend this time unless others ask for it. 

Thanks,

Jonathan

> 
> ---
> Changes in v4:
> - Split the rename into a separate commit.
> 
> Changes in v3:
> - Rename existing get_acpi_id_for_cpu() to acpi_get_cpu_acpi_id() other
>   than add one new API.
> 
> Changes in v2:
> - Add ECN _DSM reference doc name and its URL.
> - Separate implement acpi_get_cpu_acpi_id() in each arch which supports
>   ACPI.
> - Refine commit-log.
> 
> Chengwen Feng (2):
>   ACPI: Rename get_acpi_id_for_cpu() to acpi_get_cpu_acpi_id() on
>     non-x86
>   PCI/TPH: Fix get cpu steer-tag fail on ARM64 platform
> 
>  Documentation/PCI/tph.rst          |  4 ++--
>  arch/arm64/include/asm/acpi.h      |  4 ++--
>  arch/loongarch/include/asm/acpi.h  |  2 +-
>  arch/riscv/include/asm/acpi.h      |  2 +-
>  arch/riscv/kernel/acpi_numa.c      |  2 +-
>  arch/x86/include/asm/acpi.h        |  2 ++
>  arch/x86/kernel/cpu/common.c       |  8 ++++++++
>  drivers/acpi/pptt.c                | 16 ++++++++--------
>  drivers/acpi/riscv/rhct.c          |  2 +-
>  drivers/pci/tph.c                  | 11 ++++++-----
>  drivers/perf/arm_cspmu/arm_cspmu.c |  2 +-
>  include/linux/pci-tph.h            |  4 ++--
>  12 files changed, 35 insertions(+), 24 deletions(-)
> 


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v4 1/2] ACPI: Rename get_acpi_id_for_cpu() to acpi_get_cpu_acpi_id() on non-x86
  2026-03-09  4:16   ` [PATCH v4 1/2] ACPI: Rename get_acpi_id_for_cpu() to acpi_get_cpu_acpi_id() on non-x86 Chengwen Feng
@ 2026-03-09 10:30     ` Jonathan Cameron
  2026-03-09 13:29     ` Huacai Chen
  1 sibling, 0 replies; 26+ messages in thread
From: Jonathan Cameron @ 2026-03-09 10:30 UTC (permalink / raw)
  To: Chengwen Feng
  Cc: linux-pci, bhelgaas, Catalin Marinas, Will Deacon, Huacai Chen,
	WANG Xuerui, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	Alexandre Ghiti, Rafael J. Wysocki, Len Brown, Sunil V L,
	Mark Rutland, linux-acpi, wei.huang2, Eric.VanTassell, wangzhou1,
	wanghuiqiang, liuyonglong, stable, jeremy.linton, sunilvl,
	chenhuacai, wangliupu, linux-arm-kernel, linux-kernel, loongarch,
	linux-riscv, linux-perf-users

On Mon, 9 Mar 2026 12:16:57 +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_acpi_id() on arm64/riscv/loongarch platforms.
> 
> This is a pure rename with no functional change, preparing for a
> consistent ACPI Processor UID retrieval interface across all ACPI-enabled
> platforms.
> 
> Cc: stable@vger.kernel.org
> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>

Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v4 2/2] PCI/TPH: Fix get cpu steer-tag fail on ARM64 platform
  2026-03-09  4:16   ` [PATCH v4 2/2] PCI/TPH: Fix get cpu steer-tag fail on ARM64 platform Chengwen Feng
@ 2026-03-09 10:59     ` Jonathan Cameron
  0 siblings, 0 replies; 26+ messages in thread
From: Jonathan Cameron @ 2026-03-09 10:59 UTC (permalink / raw)
  To: Chengwen Feng
  Cc: linux-pci, bhelgaas, Jonathan Corbet, Shuah Khan, Thomas Gleixner,
	Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
	Andy Gospodarek, Somnath Kotur, Wei Huang, Eric Van Tassell,
	linux-acpi, rafael, lenb, wangzhou1, wanghuiqiang, liuyonglong,
	stable, jeremy.linton, sunilvl, sunilvl, chenhuacai, wangliupu,
	Ajit Khaparde, linux-doc, linux-kernel

On Mon, 9 Mar 2026 12:16:58 +0800
Chengwen Feng <fengchengwen@huawei.com> wrote:

> Currently the pcie_tph_get_cpu_st() has an issue on ARM64 platform:
> 1. The pcie_tph_get_cpu_st() function directly uses cpu_uid as the input
>    parameter to call the PCI ACPI DSM method. According to the DSM
>    definition, the input value should be the ACPI Processor UID (see [1]
>    for details).
> 2. In the Broadcom driver implementation [2] (which invokes
>    pcie_tph_get_cpu_st()), cpu_uid is obtained via
>    cpumask_first(irq->cpu_mask) - this is 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.
>    As a result, the current implementation fails to retrieve the correct
>    CPU steer-tag in such cases.
> 4. The function works on AMD x86 platforms only because the logical CPU
>    ID is identical to the ACPI Processor UID on those systems.
> 
> This commit fixes it by:
> 1. Add new acpi_get_cpu_acpi_id() implementation on x86 that wraps
>    cpu_acpi_id(), completing the unified ACPI CPU ID retrieval interface
>    across ACPI-enabled platforms.
> 2. Update pcie_tph_get_cpu_st() to use acpi_get_cpu_acpi_id(cpu) to get
>    valid ACPI Processor UID for DSM calls.
> 3. Renaming pcie_tph_get_cpu_st()'s input parameter cpu_uid to cpu for
>    clarity, as the parameter now represents a logical CPU ID (not a
>    UID).
> 
> [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."
> [2] commit c214410c47d6e ("bnxt_en: Add TPH support in BNXT driver")
> 
> 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>

If you do respin, might be worth some minor edits to the patch description
just to make it more concise.  If not, I'm fine with current text, just takes
a bit more reading than strictly necessary :)

"
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. Implement acpi_get_cpu_acpi_id() for x86, wrapping cpu_acpi_id().
   All ACPI platforms now have an implementation.
2. Use acpi_get_cpu_acpi_id() in pcie_tph_get_cpu_st() to translate from
   logical CPU ID to ACPI Processor UID needed for the DSM call.
3. Rename pcie_tpu_get_cpu_st() parameter from cpu_uid to cpu to
   reflect that it is a logical CPU_ID.
"


The references are fine as is.

Thanks,

Jonathan


> This commit fixes it by:
> 1. Add new acpi_get_cpu_acpi_id() implementation on x86 that wraps
>    cpu_acpi_id(), completing the unified ACPI CPU ID retrieval interface
>    across ACPI-enabled platforms.
> 2. Update pcie_tph_get_cpu_st() to use acpi_get_cpu_acpi_id(cpu) to get
>    valid ACPI Processor UID for DSM calls.
> 3. Renaming pcie_tph_get_cpu_st()'s input parameter cpu_uid to cpu for
>    clarity, as the parameter now represents a logical CPU ID (not a
>    UID).
> 
> [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."
> [2] commit c214410c47d6e ("bnxt_en: Add TPH support in BNXT driver")


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v4 1/2] ACPI: Rename get_acpi_id_for_cpu() to acpi_get_cpu_acpi_id() on non-x86
  2026-03-09  4:16   ` [PATCH v4 1/2] ACPI: Rename get_acpi_id_for_cpu() to acpi_get_cpu_acpi_id() on non-x86 Chengwen Feng
  2026-03-09 10:30     ` Jonathan Cameron
@ 2026-03-09 13:29     ` Huacai Chen
  2026-03-10  3:29       ` fengchengwen
  1 sibling, 1 reply; 26+ messages in thread
From: Huacai Chen @ 2026-03-09 13:29 UTC (permalink / raw)
  To: Chengwen Feng
  Cc: linux-pci, bhelgaas, Catalin Marinas, Will Deacon, WANG Xuerui,
	Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
	Rafael J. Wysocki, Len Brown, Sunil V L, Mark Rutland, linux-acpi,
	wei.huang2, Eric.VanTassell, jonathan.cameron, wangzhou1,
	wanghuiqiang, liuyonglong, stable, jeremy.linton, sunilvl,
	chenhuacai, wangliupu, linux-arm-kernel, linux-kernel, loongarch,
	linux-riscv, linux-perf-users

Hi, Chengwen,

On Mon, Mar 9, 2026 at 12:17 PM 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_acpi_id() on arm64/riscv/loongarch platforms.
Can we also rename cpu_acpi_id() to acpi_get_cpu_acpi_id() for x86?

Huacai

>
> This is a pure rename with no functional change, preparing for a
> consistent ACPI Processor UID retrieval interface across all ACPI-enabled
> platforms.
>
> Cc: stable@vger.kernel.org
> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
> ---
>  arch/arm64/include/asm/acpi.h      |  4 ++--
>  arch/loongarch/include/asm/acpi.h  |  2 +-
>  arch/riscv/include/asm/acpi.h      |  2 +-
>  arch/riscv/kernel/acpi_numa.c      |  2 +-
>  drivers/acpi/pptt.c                | 16 ++++++++--------
>  drivers/acpi/riscv/rhct.c          |  2 +-
>  drivers/perf/arm_cspmu/arm_cspmu.c |  2 +-
>  7 files changed, 15 insertions(+), 15 deletions(-)
>
> diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h
> index c07a58b96329..202107aeb05b 100644
> --- a/arch/arm64/include/asm/acpi.h
> +++ b/arch/arm64/include/asm/acpi.h
> @@ -114,7 +114,7 @@ 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)
> +static inline u32 acpi_get_cpu_acpi_id(unsigned int cpu)
>  {
>         return  acpi_cpu_get_madt_gicc(cpu)->uid;
>  }
> @@ -125,7 +125,7 @@ static inline int get_cpu_for_acpi_id(u32 uid)
>
>         for (cpu = 0; cpu < nr_cpu_ids; cpu++)
>                 if (acpi_cpu_get_madt_gicc(cpu) &&
> -                   uid == get_acpi_id_for_cpu(cpu))
> +                   uid == acpi_get_cpu_acpi_id(cpu))
>                         return cpu;
>
>         return -EINVAL;
> diff --git a/arch/loongarch/include/asm/acpi.h b/arch/loongarch/include/asm/acpi.h
> index 7376840fa9f7..89c6c8f52cc3 100644
> --- a/arch/loongarch/include/asm/acpi.h
> +++ b/arch/loongarch/include/asm/acpi.h
> @@ -40,7 +40,7 @@ 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)
> +static inline u32 acpi_get_cpu_acpi_id(unsigned int cpu)
>  {
>         return acpi_core_pic[cpu_logical_map(cpu)].processor_id;
>  }
> diff --git a/arch/riscv/include/asm/acpi.h b/arch/riscv/include/asm/acpi.h
> index 6e13695120bc..1d23681b61b5 100644
> --- a/arch/riscv/include/asm/acpi.h
> +++ b/arch/riscv/include/asm/acpi.h
> @@ -61,7 +61,7 @@ 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)
> +static inline u32 acpi_get_cpu_acpi_id(int cpu)
>  {
>         return acpi_cpu_get_madt_rintc(cpu)->uid;
>  }
> diff --git a/arch/riscv/kernel/acpi_numa.c b/arch/riscv/kernel/acpi_numa.c
> index 130769e3a99c..c2eb4824d0f7 100644
> --- a/arch/riscv/kernel/acpi_numa.c
> +++ b/arch/riscv/kernel/acpi_numa.c
> @@ -40,7 +40,7 @@ static inline int get_cpu_for_acpi_id(u32 uid)
>         int cpu;
>
>         for (cpu = 0; cpu < nr_cpu_ids; cpu++)
> -               if (uid == get_acpi_id_for_cpu(cpu))
> +               if (uid == acpi_get_cpu_acpi_id(cpu))
>                         return cpu;
>
>         return -EINVAL;
> diff --git a/drivers/acpi/pptt.c b/drivers/acpi/pptt.c
> index de5f8c018333..c1a8fba4c2b2 100644
> --- a/drivers/acpi/pptt.c
> +++ b/drivers/acpi/pptt.c
> @@ -459,7 +459,7 @@ 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 = acpi_get_cpu_acpi_id(cpu);
>         struct cacheinfo *this_leaf;
>         unsigned int index = 0;
>         struct acpi_pptt_processor *cpu_node = NULL;
> @@ -546,7 +546,7 @@ 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 = acpi_get_cpu_acpi_id(cpu);
>
>         cpu_node = acpi_find_processor_node(table, acpi_cpu_id);
>         if (cpu_node) {
> @@ -622,7 +622,7 @@ static int find_acpi_cpu_topology_tag(unsigned int cpu, int level, int flag)
>  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 = acpi_get_cpu_acpi_id(cpu);
>         struct acpi_pptt_processor *cpu_node = NULL;
>         int ret = -ENOENT;
>
> @@ -671,7 +671,7 @@ 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);
> +       acpi_cpu_id = acpi_get_cpu_acpi_id(cpu);
>         cpu_node = acpi_find_processor_node(table, acpi_cpu_id);
>         if (!cpu_node)
>                 return -ENOENT;
> @@ -797,7 +797,7 @@ int find_acpi_cpu_topology_cluster(unsigned int cpu)
>         if (!table)
>                 return -ENOENT;
>
> -       acpi_cpu_id = get_acpi_id_for_cpu(cpu);
> +       acpi_cpu_id = acpi_get_cpu_acpi_id(cpu);
>         cpu_node = acpi_find_processor_node(table, acpi_cpu_id);
>         if (!cpu_node || !cpu_node->parent)
>                 return -ENOENT;
> @@ -872,7 +872,7 @@ 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);
> +               acpi_id = acpi_get_cpu_acpi_id(cpu);
>                 cpu_node = acpi_find_processor_node(table_hdr, acpi_id);
>
>                 while (cpu_node) {
> @@ -966,7 +966,7 @@ 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 = acpi_get_cpu_acpi_id(cpu);
>                 struct acpi_pptt_cache *cache;
>                 struct acpi_pptt_processor *cpu_node;
>
> @@ -1030,7 +1030,7 @@ 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 = acpi_get_cpu_acpi_id(cpu);
>                 struct acpi_pptt_cache *cache;
>                 struct acpi_pptt_processor *cpu_node;
>
> diff --git a/drivers/acpi/riscv/rhct.c b/drivers/acpi/riscv/rhct.c
> index caa2c16e1697..c15ce8c13136 100644
> --- a/drivers/acpi/riscv/rhct.c
> +++ b/drivers/acpi/riscv/rhct.c
> @@ -44,7 +44,7 @@ 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 = acpi_get_cpu_acpi_id(cpu);
>
>         BUG_ON(acpi_disabled);
>
> diff --git a/drivers/perf/arm_cspmu/arm_cspmu.c b/drivers/perf/arm_cspmu/arm_cspmu.c
> index 34430b68f602..506b661c60fd 100644
> --- a/drivers/perf/arm_cspmu/arm_cspmu.c
> +++ b/drivers/perf/arm_cspmu/arm_cspmu.c
> @@ -1115,7 +1115,7 @@ static int arm_cspmu_acpi_get_cpus(struct arm_cspmu *cspmu)
>         if (affinity_flag == ACPI_APMT_FLAGS_AFFINITY_PROC) {
>                 for_each_possible_cpu(cpu) {
>                         if (apmt_node->proc_affinity ==
> -                           get_acpi_id_for_cpu(cpu)) {
> +                           acpi_get_cpu_acpi_id(cpu)) {
>                                 cpumask_set_cpu(cpu, &cspmu->associated_cpus);
>                                 break;
>                         }
> --
> 2.17.1
>

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v4 0/2] Fix get cpu steer-tag fail on ARM64 platform
  2026-03-09 10:28   ` [PATCH v4 0/2] " Jonathan Cameron
@ 2026-03-10  3:26     ` fengchengwen
  0 siblings, 0 replies; 26+ messages in thread
From: fengchengwen @ 2026-03-10  3:26 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: linux-pci, bhelgaas, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	Alexandre Ghiti, linux-acpi, rafael, lenb, wei.huang2,
	Eric.VanTassell, wangzhou1, wanghuiqiang, liuyonglong, stable,
	jeremy.linton, sunilvl, sunilvl, chenhuacai, wangliupu,
	linux-riscv

On 3/9/2026 6:28 PM, Jonathan Cameron wrote:
> On Mon, 9 Mar 2026 12:16:56 +0800
> Chengwen Feng <fengchengwen@huawei.com> wrote:
> 
>> This patchset addresses the issue where retrieving the CPU steer-tag
>> fails on ARM64 platforms. The first commit is a pure renaming of the
>> ACPI CPU ID retrieval interface (no functional changes), which serves
>> as preparation for the second commit that implements the core fix for
>> the steer-tag retrieval logic.
> 
> Hi,
> 
> For future reference, please keep same lists +CC on every patch
> (for a small series, send everything to everyone who gets any patch).
> For me at least, that led to my filter putting patch 1 in a totally different
> place from the rest and some confusion.
> 
> Also, don't send in reply to a previous version. Just start a new email
> thread.  That both avoids deep nesting in email clients and generally
> ensures your series ends up in the right place if people are sorting
> by time of sending.

Thanks Jonathan for the reminder, v5 has been sent with all of your comments.

Thanks again

> 
> No need to resend this time unless others ask for it. 
> 
> Thanks,
> 
> Jonathan
> 
>>
>> ---
>> Changes in v4:
>> - Split the rename into a separate commit.
>>
>> Changes in v3:
>> - Rename existing get_acpi_id_for_cpu() to acpi_get_cpu_acpi_id() other
>>   than add one new API.
>>
>> Changes in v2:
>> - Add ECN _DSM reference doc name and its URL.
>> - Separate implement acpi_get_cpu_acpi_id() in each arch which supports
>>   ACPI.
>> - Refine commit-log.
>>
>> Chengwen Feng (2):
>>   ACPI: Rename get_acpi_id_for_cpu() to acpi_get_cpu_acpi_id() on
>>     non-x86
>>   PCI/TPH: Fix get cpu steer-tag fail on ARM64 platform
>>
>>  Documentation/PCI/tph.rst          |  4 ++--
>>  arch/arm64/include/asm/acpi.h      |  4 ++--
>>  arch/loongarch/include/asm/acpi.h  |  2 +-
>>  arch/riscv/include/asm/acpi.h      |  2 +-
>>  arch/riscv/kernel/acpi_numa.c      |  2 +-
>>  arch/x86/include/asm/acpi.h        |  2 ++
>>  arch/x86/kernel/cpu/common.c       |  8 ++++++++
>>  drivers/acpi/pptt.c                | 16 ++++++++--------
>>  drivers/acpi/riscv/rhct.c          |  2 +-
>>  drivers/pci/tph.c                  | 11 ++++++-----
>>  drivers/perf/arm_cspmu/arm_cspmu.c |  2 +-
>>  include/linux/pci-tph.h            |  4 ++--
>>  12 files changed, 35 insertions(+), 24 deletions(-)
>>
> 


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v4 1/2] ACPI: Rename get_acpi_id_for_cpu() to acpi_get_cpu_acpi_id() on non-x86
  2026-03-09 13:29     ` Huacai Chen
@ 2026-03-10  3:29       ` fengchengwen
  0 siblings, 0 replies; 26+ messages in thread
From: fengchengwen @ 2026-03-10  3:29 UTC (permalink / raw)
  To: Huacai Chen
  Cc: linux-pci, bhelgaas, Catalin Marinas, Will Deacon, WANG Xuerui,
	Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
	Rafael J. Wysocki, Len Brown, Sunil V L, Mark Rutland, linux-acpi,
	wei.huang2, Eric.VanTassell, jonathan.cameron, wangzhou1,
	wanghuiqiang, liuyonglong, stable, jeremy.linton, sunilvl,
	chenhuacai, wangliupu, linux-arm-kernel, linux-kernel, loongarch,
	linux-riscv, linux-perf-users

Hi Huacai,

On 3/9/2026 9:29 PM, Huacai Chen wrote:
> Hi, Chengwen,
> 
> On Mon, Mar 9, 2026 at 12:17 PM 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_acpi_id() on arm64/riscv/loongarch platforms.
> Can we also rename cpu_acpi_id() to acpi_get_cpu_acpi_id() for x86?

Remove cpu_acpi_id() would make it look more concise, this was done in v5, thanks.

> 
> Huacai
> 
>>
>> This is a pure rename with no functional change, preparing for a
>> consistent ACPI Processor UID retrieval interface across all ACPI-enabled
>> platforms.
>>
>> Cc: stable@vger.kernel.org
>> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
>> ---
>>  arch/arm64/include/asm/acpi.h      |  4 ++--
>>  arch/loongarch/include/asm/acpi.h  |  2 +-
>>  arch/riscv/include/asm/acpi.h      |  2 +-
>>  arch/riscv/kernel/acpi_numa.c      |  2 +-
>>  drivers/acpi/pptt.c                | 16 ++++++++--------
>>  drivers/acpi/riscv/rhct.c          |  2 +-
>>  drivers/perf/arm_cspmu/arm_cspmu.c |  2 +-
>>  7 files changed, 15 insertions(+), 15 deletions(-)
>>
>> diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h
>> index c07a58b96329..202107aeb05b 100644
>> --- a/arch/arm64/include/asm/acpi.h
>> +++ b/arch/arm64/include/asm/acpi.h
>> @@ -114,7 +114,7 @@ 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)
>> +static inline u32 acpi_get_cpu_acpi_id(unsigned int cpu)
>>  {
>>         return  acpi_cpu_get_madt_gicc(cpu)->uid;
>>  }
>> @@ -125,7 +125,7 @@ static inline int get_cpu_for_acpi_id(u32 uid)
>>
>>         for (cpu = 0; cpu < nr_cpu_ids; cpu++)
>>                 if (acpi_cpu_get_madt_gicc(cpu) &&
>> -                   uid == get_acpi_id_for_cpu(cpu))
>> +                   uid == acpi_get_cpu_acpi_id(cpu))
>>                         return cpu;
>>
>>         return -EINVAL;
>> diff --git a/arch/loongarch/include/asm/acpi.h b/arch/loongarch/include/asm/acpi.h
>> index 7376840fa9f7..89c6c8f52cc3 100644
>> --- a/arch/loongarch/include/asm/acpi.h
>> +++ b/arch/loongarch/include/asm/acpi.h
>> @@ -40,7 +40,7 @@ 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)
>> +static inline u32 acpi_get_cpu_acpi_id(unsigned int cpu)
>>  {
>>         return acpi_core_pic[cpu_logical_map(cpu)].processor_id;
>>  }
>> diff --git a/arch/riscv/include/asm/acpi.h b/arch/riscv/include/asm/acpi.h
>> index 6e13695120bc..1d23681b61b5 100644
>> --- a/arch/riscv/include/asm/acpi.h
>> +++ b/arch/riscv/include/asm/acpi.h
>> @@ -61,7 +61,7 @@ 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)
>> +static inline u32 acpi_get_cpu_acpi_id(int cpu)
>>  {
>>         return acpi_cpu_get_madt_rintc(cpu)->uid;
>>  }
>> diff --git a/arch/riscv/kernel/acpi_numa.c b/arch/riscv/kernel/acpi_numa.c
>> index 130769e3a99c..c2eb4824d0f7 100644
>> --- a/arch/riscv/kernel/acpi_numa.c
>> +++ b/arch/riscv/kernel/acpi_numa.c
>> @@ -40,7 +40,7 @@ static inline int get_cpu_for_acpi_id(u32 uid)
>>         int cpu;
>>
>>         for (cpu = 0; cpu < nr_cpu_ids; cpu++)
>> -               if (uid == get_acpi_id_for_cpu(cpu))
>> +               if (uid == acpi_get_cpu_acpi_id(cpu))
>>                         return cpu;
>>
>>         return -EINVAL;
>> diff --git a/drivers/acpi/pptt.c b/drivers/acpi/pptt.c
>> index de5f8c018333..c1a8fba4c2b2 100644
>> --- a/drivers/acpi/pptt.c
>> +++ b/drivers/acpi/pptt.c
>> @@ -459,7 +459,7 @@ 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 = acpi_get_cpu_acpi_id(cpu);
>>         struct cacheinfo *this_leaf;
>>         unsigned int index = 0;
>>         struct acpi_pptt_processor *cpu_node = NULL;
>> @@ -546,7 +546,7 @@ 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 = acpi_get_cpu_acpi_id(cpu);
>>
>>         cpu_node = acpi_find_processor_node(table, acpi_cpu_id);
>>         if (cpu_node) {
>> @@ -622,7 +622,7 @@ static int find_acpi_cpu_topology_tag(unsigned int cpu, int level, int flag)
>>  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 = acpi_get_cpu_acpi_id(cpu);
>>         struct acpi_pptt_processor *cpu_node = NULL;
>>         int ret = -ENOENT;
>>
>> @@ -671,7 +671,7 @@ 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);
>> +       acpi_cpu_id = acpi_get_cpu_acpi_id(cpu);
>>         cpu_node = acpi_find_processor_node(table, acpi_cpu_id);
>>         if (!cpu_node)
>>                 return -ENOENT;
>> @@ -797,7 +797,7 @@ int find_acpi_cpu_topology_cluster(unsigned int cpu)
>>         if (!table)
>>                 return -ENOENT;
>>
>> -       acpi_cpu_id = get_acpi_id_for_cpu(cpu);
>> +       acpi_cpu_id = acpi_get_cpu_acpi_id(cpu);
>>         cpu_node = acpi_find_processor_node(table, acpi_cpu_id);
>>         if (!cpu_node || !cpu_node->parent)
>>                 return -ENOENT;
>> @@ -872,7 +872,7 @@ 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);
>> +               acpi_id = acpi_get_cpu_acpi_id(cpu);
>>                 cpu_node = acpi_find_processor_node(table_hdr, acpi_id);
>>
>>                 while (cpu_node) {
>> @@ -966,7 +966,7 @@ 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 = acpi_get_cpu_acpi_id(cpu);
>>                 struct acpi_pptt_cache *cache;
>>                 struct acpi_pptt_processor *cpu_node;
>>
>> @@ -1030,7 +1030,7 @@ 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 = acpi_get_cpu_acpi_id(cpu);
>>                 struct acpi_pptt_cache *cache;
>>                 struct acpi_pptt_processor *cpu_node;
>>
>> diff --git a/drivers/acpi/riscv/rhct.c b/drivers/acpi/riscv/rhct.c
>> index caa2c16e1697..c15ce8c13136 100644
>> --- a/drivers/acpi/riscv/rhct.c
>> +++ b/drivers/acpi/riscv/rhct.c
>> @@ -44,7 +44,7 @@ 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 = acpi_get_cpu_acpi_id(cpu);
>>
>>         BUG_ON(acpi_disabled);
>>
>> diff --git a/drivers/perf/arm_cspmu/arm_cspmu.c b/drivers/perf/arm_cspmu/arm_cspmu.c
>> index 34430b68f602..506b661c60fd 100644
>> --- a/drivers/perf/arm_cspmu/arm_cspmu.c
>> +++ b/drivers/perf/arm_cspmu/arm_cspmu.c
>> @@ -1115,7 +1115,7 @@ static int arm_cspmu_acpi_get_cpus(struct arm_cspmu *cspmu)
>>         if (affinity_flag == ACPI_APMT_FLAGS_AFFINITY_PROC) {
>>                 for_each_possible_cpu(cpu) {
>>                         if (apmt_node->proc_affinity ==
>> -                           get_acpi_id_for_cpu(cpu)) {
>> +                           acpi_get_cpu_acpi_id(cpu)) {
>>                                 cpumask_set_cpu(cpu, &cspmu->associated_cpus);
>>                                 break;
>>                         }
>> --
>> 2.17.1
>>
> 


^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2026-03-10  3:29 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-03  0:36 [PATCH] PCI/TPH: Fix get cpu steer-tag fail on ARM64 platform Chengwen Feng
2026-03-03 19:02 ` Bjorn Helgaas
2026-03-04  9:28   ` fengchengwen
2026-03-04 15:38     ` Bjorn Helgaas
2026-03-05  8:40       ` fengchengwen
2026-03-04 13:50 ` kernel test robot
2026-03-04 23:18 ` kernel test robot
2026-03-05  0:02 ` kernel test robot
2026-03-05  1:29 ` kernel test robot
2026-03-05  8:36 ` [PATCH v2] " Chengwen Feng
2026-03-05  8:53   ` Huacai Chen
2026-03-05  9:07     ` fengchengwen
2026-03-05 14:54       ` Jonathan Cameron
2026-03-06  2:20         ` fengchengwen
2026-03-06  2:19 ` [PATCH v3] " Chengwen Feng
2026-03-06 10:01   ` Jonathan Cameron
2026-03-09  4:18     ` fengchengwen
2026-03-09  4:16 ` [PATCH v4 0/2] " Chengwen Feng
2026-03-09  4:16   ` [PATCH v4 1/2] ACPI: Rename get_acpi_id_for_cpu() to acpi_get_cpu_acpi_id() on non-x86 Chengwen Feng
2026-03-09 10:30     ` Jonathan Cameron
2026-03-09 13:29     ` Huacai Chen
2026-03-10  3:29       ` fengchengwen
2026-03-09  4:16   ` [PATCH v4 2/2] PCI/TPH: Fix get cpu steer-tag fail on ARM64 platform Chengwen Feng
2026-03-09 10:59     ` Jonathan Cameron
2026-03-09 10:28   ` [PATCH v4 0/2] " Jonathan Cameron
2026-03-10  3:26     ` fengchengwen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox