public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Bjorn Helgaas <helgaas@kernel.org>
To: fengchengwen <fengchengwen@huawei.com>
Cc: linux-pci@vger.kernel.org, bhelgaas@google.com,
	linux-acpi@vger.kernel.org, rafael@kernel.org, lenb@kernel.org,
	wei.huang2@amd.com, Eric.VanTassell@amd.com,
	jonathan.cameron@huawei.com, wangzhou1@hisilicon.com,
	wanghuiqiang@huawei.com, liuyonglong@huawei.com,
	stable@vger.kernel.org, Jeremy Linton <jeremy.linton@arm.com>,
	Sunil V L <sunilvl@ventanamicro.com>,
	Sunil V L <sunilvl@oss.qualcomm.com>,
	Huacai Chen <chenhuacai@loongson.cn>,
	Liupu Wang <wangliupu@loongson.cn>
Subject: Re: [PATCH] PCI/TPH: Fix get cpu steer-tag fail on ARM64 platform
Date: Wed, 4 Mar 2026 09:38:47 -0600	[thread overview]
Message-ID: <20260304153847.GA23109@bhelgaas> (raw)
In-Reply-To: <ddf4b6db-b0c7-43ca-baad-a9df6acdca2e@huawei.com>

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.

  reply	other threads:[~2026-03-04 15:38 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260304153847.GA23109@bhelgaas \
    --to=helgaas@kernel.org \
    --cc=Eric.VanTassell@amd.com \
    --cc=bhelgaas@google.com \
    --cc=chenhuacai@loongson.cn \
    --cc=fengchengwen@huawei.com \
    --cc=jeremy.linton@arm.com \
    --cc=jonathan.cameron@huawei.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=liuyonglong@huawei.com \
    --cc=rafael@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=sunilvl@oss.qualcomm.com \
    --cc=sunilvl@ventanamicro.com \
    --cc=wanghuiqiang@huawei.com \
    --cc=wangliupu@loongson.cn \
    --cc=wangzhou1@hisilicon.com \
    --cc=wei.huang2@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox