Skip to content

Conversation

@zhang-rui
Copy link
Contributor

@zhang-rui zhang-rui commented Dec 8, 2025

Backport PLR (Power Limit Reasons) TPMI driver

Test:
Tested on GNR/CWF, the Perf Limit Reasons driver bugfs is shown and providing valid information.

1: seq_file: add helper macro to define attribute for rw file
2: kernel.h: Move ARRAY_SIZE() to a separate header
3: batman-adv: Switch to linux/array_size.h
4: platform/x86/intel/tpmi: Add support for performance limit reasons
5: platform/x86/intel/tpmi: Add API to get debugfs root
6: platform/x86/intel: TPMI domain id and CPU mapping
7: platform/x86/intel/tpmi: Add new auxiliary driver for performance limits
8: platform/x86/intel/tpmi/plr: Add support for the plr mailbox
9: platform/x86/intel/tpmi/plr: Fix output in plr_print_bits()
10: platform/x86/intel: power-domains: Add Clearwater Forest support
11: platform/x86/intel: power-domains: Use topology_logical_package_id() for package ID
12: config: enable CONFIG_INTEL_PLR_TPMI

Xingui Yang and others added 12 commits December 4, 2025 10:20
commit 9cba82b upstream.

Patch series "Add helper macro DEFINE_SHOW_STORE_ATTRIBUTE() at
seq_file.c", v6.

We already own DEFINE_SHOW_ATTRIBUTE() helper macro for defining attribute
for read-only file, but we found many of drivers also want a helper macro
for read-write file too.

So we add this helper macro to reduce duplicated code.

This patch (of 3):

We already own DEFINE_SHOW_ATTRIBUTE() helper macro for defining attribute
for read-only file, but many of drivers want a helper macro for read-write
file too.

So we add DEFINE_SHOW_STORE_ATTRIBUTE() helper to reduce duplicated code.

Intel-SIG: commit 9cba82b seq_file: add helper macro to define attribute for rw file
Backport PLR (Power Limit Reasons) TPMI driver

Link: https://lkml.kernel.org/r/[email protected]
Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Luo Jiaxing <[email protected]>
Co-developed-by: Xingui Yang <[email protected]>
Signed-off-by: Xingui Yang <[email protected]>
Reviewed-by: Andy Shevchenko <[email protected]>
Cc: Al Viro <[email protected]>
Cc: Animesh Manna <[email protected]>
Cc: Anshuman Gupta <[email protected]>
Cc: Damien Le Moal <[email protected]>
Cc: Felipe Balbi <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Himanshu Madhani <[email protected]>
Cc: James Bottomley <[email protected]>
Cc: John Garry <[email protected]>
Cc: Martin K. Petersen <[email protected]>
Cc: Uma Shankar <[email protected]>
Cc: Xiang Chen <[email protected]>
Cc: Zeng Tao <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
[ Zhang Rui: amend commit log ]
Signed-off-by: Zhang Rui <[email protected]>
commit 3cd39bc upstream.

Touching files so used for the kernel,
forces 'make' to recompile most of the kernel.

Having those definitions in more granular files
helps avoid recompiling so much of the kernel.

Intel-SIG: commit 3cd39bc kernel.h: Move ARRAY_SIZE() to a separate header
Backport PLR (Power Limit Reasons) TPMI driver

Signed-off-by: Alejandro Colomar <[email protected]>
Reviewed-by: Giovanni Cabiddu <[email protected]>
Reviewed-by: Andy Shevchenko <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
[andy: reduced to cover only string.h for now]
Signed-off-by: Andy Shevchenko <[email protected]>
[ Zhang Rui: amend commit log ]
Signed-off-by: Zhang Rui <[email protected]>
commit c3ed16a upstream.

The commit 3cd39bc ("kernel.h: Move ARRAY_SIZE() to a separate
header") introduced a new header for the ARRAY_SIZE macro which was
previously exposed via linux/kernel.h.

Intel-SIG: commit c3ed16a batman-adv: Switch to linux/array_size.h
Backport PLR (Power Limit Reasons) TPMI driver

Signed-off-by: Sven Eckelmann <[email protected]>
Signed-off-by: Simon Wunderlich <[email protected]>
[ Zhang Rui: amend commit log ]
Signed-off-by: Zhang Rui <[email protected]>
commit b44d79d upstream.

Add TPMI ID 0x0C (Perf Limit Reasons) to the list of supported TPMI IDs.

Intel-SIG: commit b44d79d platform/x86/intel/tpmi: Add support for performance limit reasons
Backport PLR (Power Limit Reasons) TPMI driver

Reviewed-by: Andy Shevchenko <[email protected]>
Reviewed-by: Ilpo Järvinen <[email protected]>
Signed-off-by: Tero Kristo <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Ilpo Järvinen <[email protected]>
[ Zhang Rui: amend commit log ]
Signed-off-by: Zhang Rui <[email protected]>
commit d36842b upstream.

Add new API to get the debugfs root directory for TPMI. This allows any
TPMI devices to add their own debugfs items under the same directory
structure.

Intel-SIG: commit d36842b platform/x86/intel/tpmi: Add API to get debugfs root
Backport PLR (Power Limit Reasons) TPMI driver

Reviewed-by: Andy Shevchenko <[email protected]>
Reviewed-by: Ilpo Järvinen <[email protected]>
Signed-off-by: Tero Kristo <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Ilpo Järvinen <[email protected]>
[ Zhang Rui: amend commit log ]
Signed-off-by: Zhang Rui <[email protected]>
commit 17ca278 upstream.

Each TPMI power domain includes a group of CPUs. Several power
management settings in this case applicable to a group of CPUs.
There can be several power domains in a CPU package. So, provide
interfaces for:
- Get power domain id for a Linux CPU
- Get mask of Linux CPUs in a power domain

Hardware Punit uses different CPU numbering, which is not based on
APIC (Advanced Programmable Interrupt Controller) CPU numbering.
The Linux CPU numbering is based on APIC CPU numbering. Some PM features
like Intel Speed Select, the CPU core mask provided by the hardware is
based on the Punit CPU numbering. To use the core mask, this mask
needs to be converted to a Linux CPUs mask. So, provide interfaces for:
- Convert to a Linux CPU number from a Punit CPU number
- Convert to a Punit CPU number from a Linux CPU number

On each CPU online, MSR 0x54 is used to read the mapping and stores in
a per cpu array. Create a hash for faster searching of a Linux CPU number
from a Punit CPU number.

Intel-SIG: commit 17ca278 platform/x86/intel: TPMI domain id and CPU mapping
Backport PLR (Power Limit Reasons) TPMI driver

Signed-off-by: Srinivas Pandruvada <[email protected]>
[tero.kristo: minor updates]
Reviewed-by: Andy Shevchenko <[email protected]>
Reviewed-by: Ilpo Järvinen <[email protected]>
Signed-off-by: Tero Kristo <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Ilpo Järvinen <[email protected]>
[ Zhang Rui: amend commit log ]
Signed-off-by: Zhang Rui <[email protected]>
commit 811f67c upstream.

Add new auxiliary driver that exposes the SoC performance limit reasons
via debugfs interface.

Intel-SIG: commit 811f67c platform/x86/intel/tpmi: Add new auxiliary driver for performance limits
Backport PLR (Power Limit Reasons) TPMI driver

Reviewed-by: Andy Shevchenko <[email protected]>
Reviewed-by: Ilpo Järvinen <[email protected]>
Signed-off-by: Tero Kristo <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Ilpo Järvinen <[email protected]>
[ Zhang Rui: amend commit log ]
Signed-off-by: Zhang Rui <[email protected]>
commit 9e9397a upstream.

Add support for reading fine grained power limit reasons via the PLR
mailbox.

Intel-SIG: commit 9e9397a platform/x86/intel/tpmi/plr: Add support for the plr mailbox
Backport PLR (Power Limit Reasons) TPMI driver

Reviewed-by: Andy Shevchenko <[email protected]>
Reviewed-by: Ilpo Järvinen <[email protected]>
Signed-off-by: Tero Kristo <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Ilpo Järvinen <[email protected]>
[ Zhang Rui: amend commit log ]
Signed-off-by: Zhang Rui <[email protected]>
commit 182c694 upstream.

Smatch complains that 'str' can be used without being initialized:

    drivers/platform/x86/intel/intel_plr_tpmi.c:178 plr_print_bits()
    error: uninitialized symbol 'str'.

In this loop, we iterate over all the set bits and print the name of the
bit.  The intention is that if there is a bit which is between 0-31 we
look for the name in the first array plr_coarse_reasons[] which has 10
elements.  If the bit is in the 32-63 range we look for it in the
plr_fine_reasons[] array which has 30 elements.  If the bit is in the
invalid ranges, 10-31 or 62-63, then we should print "UNKNOWN(%d)".

The problem is that 'str' needs to be initialized at the start of each
iteration, otherwise if we can't find the string then instead of printing
"UNKNOWN(%d)", we will re-print whatever the previous bit was.

Intel-SIG: commit 182c694 platform/x86/intel/tpmi/plr: Fix output in plr_print_bits()
Backport PLR (Power Limit Reasons) TPMI driver

Fixes: 9e9397a ("platform/x86/intel/tpmi/plr: Add support for the plr mailbox")
Signed-off-by: Dan Carpenter <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Reviewed-by: Ilpo Järvinen <[email protected]>
Signed-off-by: Ilpo Järvinen <[email protected]>
[ Zhang Rui: amend commit log ]
Signed-off-by: Zhang Rui <[email protected]>
commit bee9a0838fd223823e5a6d85c055ab1691dc738e upstream.

Add Clearwater Forest support (INTEL_ATOM_DARKMONT_X) to tpmi_cpu_ids
to support domaid id mappings.

Intel-SIG: commit bee9a0838fd2 platform/x86/intel: power-domains: Add Clearwater Forest support
Backport PLR (Power Limit Reasons) TPMI driver

Signed-off-by: Srinivas Pandruvada <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Reviewed-by: Ilpo Järvinen <[email protected]>
Signed-off-by: Ilpo Järvinen <[email protected]>
[ Zhang Rui: amend commit log ]
Signed-off-by: Zhang Rui <[email protected]>
…for package ID

commit aa28991fd5dc4c01a40caab2bd9af8c5e06f9899 upstream.

Currently, tpmi_get_logical_id() calls topology_physical_package_id()
to set the pkg_id of the info structure. Since some VM hosts assign non
contiguous package IDs, topology_physical_package_id() can return a
larger value than topology_max_packages(). This will result in an
invalid reference into tpmi_power_domain_mask[] as that is allocatead
based on topology_max_packages() as the maximum package ID.

Intel-SIG: commit aa28991fd5dc platform/x86/intel: power-domains: Use topology_logical_package_id() for package ID
Backport PLR (Power Limit Reasons) TPMI driver

Fixes: 17ca278 ("platform/x86/intel: TPMI domain id and CPU mapping")
Signed-off-by: David Arcari <[email protected]>
Acked-by: Srinivas Pandruvada <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Reviewed-by: Ilpo Järvinen <[email protected]>
Signed-off-by: Ilpo Järvinen <[email protected]>
[ Zhang Rui: amend commit log ]
Signed-off-by: Zhang Rui <[email protected]>
Enable PLR (Perf Limit Reasons) driver.

Signed-off-by: Zhang Rui <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants