Skip to content

Commit abdd2a8

Browse files
fengchengwenrafaeljw
authored andcommitted
PCI/TPH: Pass ACPI Processor UID to Cache Locality _DSM
pcie_tph_get_cpu_st() uses the Query Cache Locality Features _DSM [1] to retrieve the TPH Steering Tag for memory associated with the CPU identified by its "cpu_uid" parameter, a Linux logical CPU ID. The _DSM requires an ACPI Processor UID, which pcie_tph_get_cpu_st() previously assumed was the same as the Linux logical CPU ID. This is true on x86 but not on arm64, so pcie_tph_get_cpu_st() returned the wrong Steering Tag, resulting in incorrect TPH functionality on arm64. Convert the Linux logical CPU ID to the ACPI Processor UID with acpi_get_cpu_uid() before passing it to the _DSM. Additionally, rename the pcie_tph_get_cpu_st() parameter from "cpu_uid" to "cpu" to reflect that it represents a logical CPU ID (not an ACPI Processor 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." Fixes: d2e8a34 ("PCI/TPH: Add Steering Tag support") Signed-off-by: Chengwen Feng <fengchengwen@huawei.com> Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com> Reviewed-by: Bjorn Helgaas <bhelgaas@google.com> Link: https://patch.msgid.link/20260401081640.26875-9-fengchengwen@huawei.com Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent a7034e9 commit abdd2a8

3 files changed

Lines changed: 15 additions & 9 deletions

File tree

Documentation/PCI/tph.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,10 @@ To retrieve a Steering Tag for a target memory associated with a specific
7979
CPU, use the following function::
8080

8181
int pcie_tph_get_cpu_st(struct pci_dev *pdev, enum tph_mem_type type,
82-
unsigned int cpu_uid, u16 *tag);
82+
unsigned int cpu, u16 *tag);
8383

8484
The `type` argument is used to specify the memory type, either volatile
85-
or persistent, of the target memory. The `cpu_uid` argument specifies the
85+
or persistent, of the target memory. The `cpu` argument specifies the
8686
CPU where the memory is associated to.
8787

8888
After the ST value is retrieved, the device driver can use the following

drivers/pci/tph.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -236,21 +236,27 @@ static int write_tag_to_st_table(struct pci_dev *pdev, int index, u16 tag)
236236
* with a specific CPU
237237
* @pdev: PCI device
238238
* @mem_type: target memory type (volatile or persistent RAM)
239-
* @cpu_uid: associated CPU id
239+
* @cpu: associated CPU id
240240
* @tag: Steering Tag to be returned
241241
*
242242
* Return the Steering Tag for a target memory that is associated with a
243-
* specific CPU as indicated by cpu_uid.
243+
* specific CPU as indicated by cpu.
244244
*
245245
* Return: 0 if success, otherwise negative value (-errno)
246246
*/
247247
int pcie_tph_get_cpu_st(struct pci_dev *pdev, enum tph_mem_type mem_type,
248-
unsigned int cpu_uid, u16 *tag)
248+
unsigned int cpu, u16 *tag)
249249
{
250250
#ifdef CONFIG_ACPI
251251
struct pci_dev *rp;
252252
acpi_handle rp_acpi_handle;
253253
union st_info info;
254+
u32 cpu_uid;
255+
int ret;
256+
257+
ret = acpi_get_cpu_uid(cpu, &cpu_uid);
258+
if (ret != 0)
259+
return ret;
254260

255261
rp = pcie_find_root_port(pdev);
256262
if (!rp || !rp->bus || !rp->bus->bridge)
@@ -265,9 +271,9 @@ int pcie_tph_get_cpu_st(struct pci_dev *pdev, enum tph_mem_type mem_type,
265271

266272
*tag = tph_extract_tag(mem_type, pdev->tph_req_type, &info);
267273

268-
pci_dbg(pdev, "get steering tag: mem_type=%s, cpu_uid=%d, tag=%#04x\n",
274+
pci_dbg(pdev, "get steering tag: mem_type=%s, cpu=%d, tag=%#04x\n",
269275
(mem_type == TPH_MEM_TYPE_VM) ? "volatile" : "persistent",
270-
cpu_uid, *tag);
276+
cpu, *tag);
271277

272278
return 0;
273279
#else

include/linux/pci-tph.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ int pcie_tph_set_st_entry(struct pci_dev *pdev,
2525
unsigned int index, u16 tag);
2626
int pcie_tph_get_cpu_st(struct pci_dev *dev,
2727
enum tph_mem_type mem_type,
28-
unsigned int cpu_uid, u16 *tag);
28+
unsigned int cpu, u16 *tag);
2929
void pcie_disable_tph(struct pci_dev *pdev);
3030
int pcie_enable_tph(struct pci_dev *pdev, int mode);
3131
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,
3636
{ return -EINVAL; }
3737
static inline int pcie_tph_get_cpu_st(struct pci_dev *dev,
3838
enum tph_mem_type mem_type,
39-
unsigned int cpu_uid, u16 *tag)
39+
unsigned int cpu, u16 *tag)
4040
{ return -EINVAL; }
4141
static inline void pcie_disable_tph(struct pci_dev *pdev) { }
4242
static inline int pcie_enable_tph(struct pci_dev *pdev, int mode)

0 commit comments

Comments
 (0)