Commit Graph

1576 Commits

Author SHA1 Message Date
Linus Torvalds
96463e4e02 Turbostat Fixes
Fix a memory allocation issue that could corrupt output values or SEGV
 
 Fix a perf initilization issue that could exit on some HW + kernels.
 
 Minor fixes.
 -----BEGIN PGP SIGNATURE-----
 
 iQJIBAABCgAyFiEE67dNfPFP+XUaA73mB9BFOha3NhcFAmnY/PkUHGxlbi5icm93
 bkBpbnRlbC5jb20ACgkQB9BFOha3NhcTIA//QsbmJV7qddOe/kOhS7izRyVjuaLQ
 QIyIrSLSa5+49oT4uRhZxuzDm6N6zVykFf+yxK5E2TSf+JfvzfwjZJQEgUPqHtkt
 vietoJheI4voMgmDQk39oxQmYyxmXuD3TRgvY+EN+QEIuWFA3/J9YaOulQMICrRy
 TX3juoZ3mxUpO8LC6+t3Yd8Kl1JEl3cKj3LdX7cMIchLM2cSTlbVFGSP0y5f0mu/
 m54+JLSeSCFyqfin8rkgLYar8+AIIrHVak57rQ3qKBUOfoJlMaJEgXC4/sKdEzAW
 zKld2cFfzzXd2LnShN9Su7L9VCF09POKpD7P9bk9rDcp/MfsOmlKRctRvnY4T7Bq
 si+AflAYzYtHlq0LQbw2tHsKLFnqIJziDzz+YHl9UxcK0X17Gkp32NSQOX7Djvdu
 g/HDMHudnyoq0dAObieQgevYAWYmfKTNeQpJk+d+27X9HTzNXCDe70D774+DhM73
 ViDU5zPrFBc1Z9ScQmgbe4z2N3MvzWGkodJRseb1v44ClH+Z6sCG4RYxYpxj0Zyu
 0rR5GBb6ymuDUAQYEVuk2/F05bgmp3oXhoaddC+bO115XGEfe9sR7PBk3p9LYSM5
 KirznZsjE8qI8GUXdL4EztTtIUJ5sx9CWb5FqP6k7XovrPCoMhSsbbo0vUbLCK4C
 eh0+iPh3sAf0NZs=
 =xJLy
 -----END PGP SIGNATURE-----

Merge tag 'turbostat-fixes-for-7.0' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux

Pull turbostat fixes from Len Brown:

 - Fix a memory allocation issue that could corrupt output values or
   SEGV

 - Fix a perf initilization issue that could exit on some HW + kernels

 - Minor fixes

* tag 'turbostat-fixes-for-7.0' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux:
  tools/power turbostat: Allow execution to continue after perf_l2_init() failure
  tools/power turbostat: Fix delimiter bug in print functions
  tools/power turbostat: Fix --show/--hide for individual cpuidle counters
  tools/power turbostat: Fix incorrect format variable
  tools/power turbostat: Consistently use print_float_value()
  tools/power/turbostat: Fix microcode patch level output for AMD/Hygon
  tools/power turbostat: Eliminate unnecessary data structure allocation
  tools/power turbostat: Fix swidle header vs data display
  tools/power turbostat: Fix illegal memory access when SMT is present and disabled
2026-04-10 08:36:32 -07:00
David Arcari
ba893caead tools/power turbostat: Allow execution to continue after perf_l2_init() failure
Currently, if perf_l2_init() fails turbostat exits after issuing the
following error (which was encountered on AlderLake):

turbostat: perf_l2_init(cpu0, 0x0, 0xff24) REFS: Invalid argument

This occurs because perf_l2_init() calls err(). However, the code has been
written in such a manner that it is able to perform cleanup and continue.
Therefore, this issue can be addressed by changing the appropriate calls
to err() to warnx().

Additionally, correct the PMU type arguments passed to the warning strings
in the ecore and lcore blocks so the logs accurately reflect the failing
counter type.

Signed-off-by: David Arcari <darcari@redhat.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2026-04-10 09:04:32 -04:00
Artem Bityutskiy
cdbefe9d40 tools/power turbostat: Fix delimiter bug in print functions
Commands that add counters, such as 'turbostat --show C1,C1+'
display merged columns without a delimiter.

This is caused by the bad syntax: '(*printed++ ? delim : "")', shared by
print_name()/print_hex_value()/print_decimal_value()/print_float_value()

Use '((*printed)++ ? delim : "")' to correctly increment the value at *printed.

[lenb: fix code and commit message typo, re-word]
Fixes: 56dbb87850 ("tools/power turbostat: Refactor added column header printing")
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2026-03-18 15:57:58 -04:00
Artem Bityutskiy
b6398bc2ef tools/power turbostat: Fix --show/--hide for individual cpuidle counters
Problem: individual swidle counter names (C1, C1+, C1-, etc.) cannot be
selected via --show/--hide due to two bugs in probe_cpuidle_counts():
1. The function returns immediately when BIC_cpuidle is not enabled,
   without checking deferred_add_index.
2. The deferred name check runs against name_buf before the trailing
   newline is stripped, so is_deferred_add("C1\n") never matches "C1".

Fix:
1. Relax the early return to pass through when deferred names are
   queued.
2. Strip the trailing newline from name_buf before performing deferred
   name checks.
3. Check each suffixed variant (C1+, C1, C1-) individually so that
   e.g. "--show C1+" enables only the requested metric.

In addition, introduce a helper function to avoid repeating the
condition (readability cleanup).

Fixes: ec4acd3166 ("tools/power turbostat: disable "cpuidle" invocation counters, by default")
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2026-03-17 23:39:42 -04:00
Artem Bityutskiy
23cb4f5c81 tools/power turbostat: Fix incorrect format variable
In the perf thread, core, and package counter loops, an incorrect
'mp->format' variable is used instead of 'pp->format'.

[lenb: edit commit message]
Fixes: 696d15cbd8 ("tools/power turbostat: Refactor floating point printout code")
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2026-03-17 23:39:42 -04:00
Artem Bityutskiy
ed532d738a tools/power turbostat: Consistently use print_float_value()
Fix the PMT thread code to use print_float_value(),
to be consistent with the PMT core and package code.

[lenb: commit message]
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2026-03-17 23:39:42 -04:00
Serhii Pievniev
a444083286 tools/power/turbostat: Fix microcode patch level output for AMD/Hygon
turbostat always used the same logic to read the microcode patch level,
which is correct for Intel but not for AMD/Hygon.
While Intel stores the patch level in the upper 32 bits of MSR, AMD
stores it in the lower 32 bits, which causes turbostat to report the
microcode version as 0x0 on AMD/Hygon.

Fix by shifting right by 32 for non-AMD/Hygon, preserving the existing
behavior for Intel and unknown vendors.

Fixes: 3e4048466c ("tools/power turbostat: Add --no-msr option")
Signed-off-by: Serhii Pievniev <spevnev16@gmail.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2026-03-17 23:13:09 -04:00
Zhang Rui
99b38fa343 tools/power turbostat: Eliminate unnecessary data structure allocation
Linux core_id's are a per-package namespace, not a per-node namespace.

Rename topo.cores_per_node to topo.cores_per_pkg to reflect this.

Eliminate topo.nodes_per_pkg from the sizing for core data structures,
since it has no role except to unnecessarily bloat the allocation.

Validated on multiple Intel platforms (ICX/SPR/SRF/EMR/GNR/CWF) with
various CPU online/offline configurations and SMT enabled/disabled
scenarios.

No functional changes.

[lenb: commit message]
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2026-03-17 23:13:09 -04:00
Len Brown
b8ead30e2b tools/power turbostat: Fix swidle header vs data display
I changed my mind about displaying swidle statistics,
which are "added counters".  Recently I reverted the
column headers to 8-columns, but kept print_decimal_value()
padding out to 16-columns for all 64-bit counters.

Simplify by keeping print_decimial_value() at %lld -- which
will often fit into 8-columns, and live with the fact
that it can overflow and shift the other columns,
which continue to tab-delimited.

This is a better compromise than inserting a bunch
of space characters that most users don't like.

Fixes: 1a23ba6a1b ("tools/power turbostat: Print wide names only for RAW 64-bit columns")
Reported-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2026-03-17 23:10:23 -04:00
Zhang Rui
57d2371d52 tools/power turbostat: Fix illegal memory access when SMT is present and disabled
When SMT is present and disabled, turbostat may under-size
the thread_data array.  This can corrupt results or
cause turbostat to exit with a segmentation fault.

[lenb: commit message]
Fixes: a2b4d0f8bf ("tools/power turbostat: Favor cpu# over core#")
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2026-03-10 14:58:50 -04:00
Zhang Rui
3817b1d344 cpupower: Add intel_pstate turbo boost support for Intel platforms
On modern Intel platforms, the intel_pstate driver is commonly used and
it provides turbo boost control via
/sys/devices/system/cpu/intel_pstate/no_turbo.

However, cpupower doesn't handle this. it
1. shows turbo boost as "active" blindly for Intel platforms
2. controls turbo boost functionality via the generic
   /sys/devices/system/cpu/cpufreq/boost sysfs interface only.

Enhance the cpupower tool to ensure the "--boost" command works
seamlessly on Intel platforms with intel_pstate driver running.

Without this patch,
   $ echo 1 | sudo tee /sys/devices/system/cpu/intel_pstate/no_turbo
   1
   $ sudo cpupower frequency-info --boost
   analyzing CPU 21:
     boost state support:
       Supported: yes
       Active: yes
   $ sudo cpupower set --boost 0
   Error setting turbo-boost
   $ sudo cpupower set --boost 1
   Error setting turbo-boost

With this patch,
   $ cat /sys/devices/system/cpu/intel_pstate/no_turbo
   0
   $ sudo cpupower set --boost 0
   $ sudo cpupower frequency-info --boost
   analyzing CPU 21:
     boost state support:
       Supported: yes
       Active: no
   $ cat /sys/devices/system/cpu/intel_pstate/no_turbo
   1
   $ sudo cpupower set --boost 1
   $ sudo cpupower frequency-info --boost
   analyzing CPU 28:
     boost state support:
       Supported: yes
       Active: yes
   $ cat /sys/devices/system/cpu/intel_pstate/no_turbo
   0

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2026-03-03 11:18:53 -07:00
Jan Kiszka
50ad1a31be cpupower: Add support for setting EPP via systemd service
Extend the systemd service so that it can be used for tuning the Energy
Performance Preference (EPP) as well. Available options can be read from
/sys/devices/system/cpu/cpufreq/policy0/energy_performance_available_preferences.
The desired one can then be set in cpupower-service.conf.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2026-03-03 11:07:06 -07:00
Kaushlendra Kumar
dff8e3c025 cpupower: fix swapped power/energy unit labels
Fix error where microWatts and microJoules units were interchanged.

Signed-off-by: Kaushlendra Kumar <kaushlendra.kumar@intel.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2026-02-28 13:13:49 -07:00
Linus Torvalds
7ad54bbbc9 turbostat-2026.02.14-AMD-RAPL-fix
Fix a recent AMD regression due to errant code cleanup.
 -----BEGIN PGP SIGNATURE-----
 
 iQJIBAABCgAyFiEE67dNfPFP+XUaA73mB9BFOha3NhcFAmmVTxQUHGxlbi5icm93
 bkBpbnRlbC5jb20ACgkQB9BFOha3Nhd7fxAAtzAu/NDP1pRaJkHQtMBVf9E1RUKZ
 4HLoOxwdOqId3spfYRXIcQ0M9o31MBdNNjnSeJgwVIdPu1ie91SPjMcRZv+xqA4z
 Z6mowdhDYvmrtQbi9KcPKtYqmujA+NimobYVlY9ze7q2kI8GC3ogyb1m1BkN/wYA
 GYFez5d2PyS3A/X3sC9eMLwJv9w/8E3n52X8gDvxzGazP51jkgDo5reoW+tm3y/d
 Tr0YUzZOVYVhnorJm90lY5VTQZZ7/RFgPClvb7Izk3nueXHbM/5p26avDOmBEyPQ
 1s5CU/1niMOy3dTUDUY5h6hEoOig1+qcg0GIgmrrbvhBmhlvVEB5Me999u2/5nUN
 ZCCRPrpXRCTysg/3wGx+0O0L32cTf59mHiGyToFB46LTTA0JOj1j45h7mNwI2yfa
 wZwhwbcOwXzMAO9TIbXIvN0xd++9QhTz5XDivZcQSHRYLVzP6nRizO40+1F2PMyG
 iBah5zFtIzfqWEUSOkj/Nce7u+I/Dp75lI6yiHp2RYJ3GkTjr9/09SaHjmSXlJ56
 9QV16lmWB0i59cMVH2n+b9DADP3piVU8FLXFjr0B3SHT2Ayg6sXWNHrk8Loa5qZM
 8kd8HtBEZTVwfREWW3772ZjkEfT1WprEsF7pbHHUoqtPqa3X2G47xOC4ZZY81UqH
 gml3aw66jhIHlps=
 =THke
 -----END PGP SIGNATURE-----

Merge tag 'turbostat-2026.02.14-AMD-RAPL-fix' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux

Pull turbostat fix from Len Brown:
 "Fix a recent AMD regression due to errant code cleanup"

* tag 'turbostat-2026.02.14-AMD-RAPL-fix' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux:
  tools/power turbostat: Fix AMD RAPL regression
2026-02-18 09:52:38 -08:00
Len Brown
ef0e60083f tools/power turbostat: Fix AMD RAPL regression
turbostat.c:8688: rapl_perf_init: Assertion `next_domain < num_domains' failed.

Two recent cleanup patches that were not supposed to change anything
broke the core_id code needed for AMD RAPL initialization:

commit 070e92361e ("tools/power turbostat: Enhance HT enumeration")
commit ddf60e38ca ("tools/power turbostat: Simplify global core_id calculation")

Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Len Brown <len.brown@intel.com>
2026-02-17 23:27:52 -06:00
Linus Torvalds
2961f841b0 turbostat-2026.02.14
Since release 2025.12.02:
 
 	Add L2 statistics columns for recent Intel processors:
 		L2MRPS = L2 Cache M-References Per Second
 		L2%hit = L2 Cache Hit %
 
 	Sort work and output by cpu# rather than core#
 
 	Minor features and fixes.
 -----BEGIN PGP SIGNATURE-----
 
 iQJIBAABCgAyFiEE67dNfPFP+XUaA73mB9BFOha3NhcFAmmPhVYUHGxlbi5icm93
 bkBpbnRlbC5jb20ACgkQB9BFOha3NhfpyxAAuAjLE5AD+pHSSMW/wOXU5YxU5L5g
 xIo5rWrgMIwx3IGDZE3EO45N0GpMDrL1hwmjPT/NtF+RESlzxo7NrsdrAM9+u8Eu
 qMu+Krd45cGwi/q37QD337pIMLvG1nT46BLt4eQk2TpUJSJynNF4WiwJ32enHoSh
 lwG76mChITxOdGDYfAvLZknsJqJgpv9sBbJzm3M7HxIKEnobKfE4A3Urooq+sz5X
 zWcNSPBWNnVLSIs79INbgSaFBY51P3HtIaXvmivfAKS5BWcUZ6/5BAiCG+QjSqIe
 l6bW4HU0UdVwzX76g2mApeeU40mz53xO5uDN9oriXOAEFh3unf4ui0I62TBgjDCB
 Y86XfFAXzjYMfml9rM8pA7U6Rj+3XrMFjRdrO+7itKHotaWrXylr6qO3bNO6DxN1
 OTcveL8hdnTunGOsiOuG2CFfwLxMhpyyb9+MBA5JNofltCmzgrhW7TjzLKPXM4fE
 xCIe16RR/1DEw1PnPzYABU8gNmhTjm0zbUC8tlQhe8G9tSAXtBoz9Zv5bnqHr++6
 ETlipyt9u7awj9APX/Oye/0eskcYVgST3XimXxD5rQrtveRyg/4B8PTej9eXNIp3
 8eJjFkv+I+/740KetJFD/6gP8SBbO0bRV5yjDDXJ8ihbqm8854tFaOSef3W8zXNc
 8iuNqxby3SVZc7Q=
 =UG/p
 -----END PGP SIGNATURE-----

Merge tag 'turbostat-2026.02.14' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux

Pull turbostat updates from Len Brown:

 - Add L2 statistics columns for recent Intel processors:
	L2MRPS = L2 Cache M-References Per Second
	L2%hit = L2 Cache Hit %

 - Sort work and output by cpu# rather than core#

 - Minor features and fixes

* tag 'turbostat-2026.02.14' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux: (23 commits)
  tools/power turbostat: version 2026.02.14
  tools/power turbostat: Fix and document --header_iterations
  tools/power turbostat: Use strtoul() for iteration parsing
  tools/power turbostat: Favor cpu# over core#
  tools/power turbostat: Expunge logical_cpu_id
  tools/power turbostat: Enhance HT enumeration
  tools/power turbostat: Simplify global core_id calculation
  tools/power turbostat: Unify even/odd/average counter referencing
  tools/power turbostat: Allocate average counters dynamically
  tools/power turbostat: Delete core_data.core_id
  tools/power turbostat: Rename physical_core_id to core_id
  tools/power turbostat: Cleanup package_id
  tools/power turbostat: Cleanup internal use of "base_cpu"
  tools/power turbostat: Add L2 cache statistics
  tools/power turbostat: Remove redundant newlines from err(3) strings
  tools/power turbostat: Allow more use of is_hybrid flag
  tools/power turbostat: Rename "LLCkRPS" column to "LLCMRPS"
  tools/power turbostat.8: Document the "--force" option
  tools/power turbostat: Harden against unexpected values
  tools/power turbostat: Dump hypervisor name
  ...
2026-02-17 15:51:14 -08:00
Linus Torvalds
f50822fd86 platform-drivers-x86 for v7.0-1
Highlights:
 
 - amd/pmf:
   - Avoid overwriting BIOS input values when events occur rapidly
   - Fix PMF driver issues related to S4 (in part on crypto/ccp side)
   - Add NPU metrics API (for accel side consumers)
   - Allow disabling Smart PC function through a module parameter
 
 - asus-wmi & HID/asus:
   - Unification of backlight control (replaces quirks)
   - Support multiple interfaces for controlling keyboard/RGB brightness
   - Simplify init sequence
 
 - hp-wmi:
   - Add manual fan control for Victus S models
   - Add fan mode keep-alive
   - Fix platform profile values for Omen 16-wf1xxx
   - Add EC offset to get the thermal profile
 
 - intel/pmc: Show substate residencies also for non-primary PMCs
 
 - intel/ISST:
   - Store and restore data for all domains
   - Write interface improvements
 
 - lenovo-wmi:
   - Support multiple Capability Data
   - Add HWMON reporting and tuning support
 
 - mellanox/mlx-platform: Add HI173 & HI174 support
 
 - surface/aggregator_registry: Add Surface Pro 11 (QCOM)
 
 - thinkpad_acpi: Add support for HW damage detection capability
 
 - uniwill: Implement cTGP setting
 
 - wmi:
   - Introduce marshalling support
   - Convert a few drivers to use the new buffer-based WMI API
 
 - tools/power/x86/intel-speed-select: Allow read operations for non-root
 
 - Miscellaneous cleanups / refactoring / improvements
 
 The following is an automated shortlog grouped by driver:
 
 amd/pmf:
  -  Added a module parameter to disable the Smart PC function
  -  Introduce new interface to export NPU metrics
  -  Prevent TEE errors after hibernate
  -  Use ring buffer to store custom BIOS input values
 
 amd:
  -  Use scope-based cleanup for wbrf_record()
 
 asus-wmi:
  -  add keyboard brightness event handler
  -  Add support for multiple kbd led handlers
  -  remove unused keyboard backlight quirk
 
 crypto:
  -  ccp - Add an S4 restore flow
  -  ccp - Declare PSP dead if PSP_CMD_TEE_RING_INIT fails
  -  ccp - Factor out ring destroy handling to a helper
  -  ccp - Send PSP_CMD_TEE_RING_DESTROY when PSP_CMD_TEE_RING_INIT fails
 
 HID: asus:
  -  add support for the asus-wmi brightness handler
  -  early return for ROG devices
  -  fortify keyboard handshake
  -  initialize additional endpoints only for certain devices
  -  listen to the asus-wmi brightness device instead of creating one
  -  move vendor initialization to probe
  -  simplify RGB init sequence
  -  use same report_id in response
 
 hp-wmi:
  -  Add EC offsets to read Victus S thermal profile
  -  add manual fan control for Victus S models
  -  fix platform profile values for Omen 16-wf1xxx
  -  implement fan keep-alive
  -  order include headers
 
 ideadpad-laptop:
  -  Clean up style warnings and checks
 
 intel/pmc:
  -  Change LPM mode fields to u8
  -  Enable substate residencies for multiple PMCs
  -  Move LPM mode attributes to PMC
  -  Remove double empty line
 
 intel/pmt:
  -  Replace sprintf() with sysfs_emit()
 
 intel/uncore-freq:
  -  Replace sprintf() with scnprintf()
  -  Replace sprintf() with sysfs_emit()
 
 intel-wmi-sbl-fw-update:
  -  Use new buffer-based WMI API
 
 intel/wmi: thunderbolt:
  -  Use new buffer-based WMI API
 
 ISST:
  -  Add missing write block check
  -  Check for admin capability for write commands
  -  Optimize suspend/resume callbacks
  -  Store and restore all domains data
 
 lenovo-wmi-capdata:
  -  Add support for Capability Data 00
  -  Add support for Fan Test Data
 
 lenovo-wmi-{capdata,other}:
  -  Fix HWMON channel visibility
  -  Support multiple Capability Data
 
 lenovo-wmi-capdata:
  -  Wire up Fan Test Data
 
 lenovo-wmi-helpers:
  -  Convert returned buffer into u32
 
 lenovo-wmi-other:
  -  Add HWMON for fan reporting/tuning
 
 mlx-platform:
  -  Add support DGX flavor of next-generation 800GB/s ethernet switch.
  -  Add support for new Nvidia DGX system based on class VMOD0010
 
 Rename lenovo-wmi-capdata01 to lenovo-wmi-capdata:
  - Rename lenovo-wmi-capdata01 to lenovo-wmi-capdata
 
 surface: aggregator_registry:
  -  Add Surface Pro 11 (QCOM)
 
 surface:
  -  Replace deprecated strcpy() in surface_button_add()
 
 thinkpad_acpi:
  -  Add support to detect hardware damage detection capability.
  -  Add sysfs to display details of damaged device.
 
 tools/power/x86/intel-speed-select:
  -  Allow non root users
  -  Fix file descriptor leak in isolate_cpus()
  -  Use pkg-config for libnl-3.0 detection
  -  v1.25 release
 
 uniwill:
  -  Implement cTGP setting
 
 uniwill-laptop:
  -  Introduce device descriptor system
 
 wmi:
  -  Add helper functions for WMI string conversions
  -  Add kunit test for the marshalling code
  -  Add kunit test for the string conversion code
 
 wmi-bmof:
  -  Use new buffer-based WMI API
 
 wmi:
  -  Introduce marshalling support
 
 wmi: string-kunit:
  -  Add missing oversized string test case
 
 wmi:
  -  Update driver development guide
 
 xiaomi-wmi:
  -  Use new buffer-based WMI API
 
 yogabook:
  -  Clean up code style
 
 Merges:
  -  Merge branch 'fixes' of into for-next
  -  Merge branch 'intel-sst' of https://github.com/spandruvada/linux-kernel into for-next
  -  Merge branch 'platform-drivers-x86-asus-kbd' into for-next
 -----BEGIN PGP SIGNATURE-----
 
 iHUEABYIAB0WIQSCSUwRdwTNL2MhaBlZrE9hU+XOMQUCaY9soAAKCRBZrE9hU+XO
 MT5EAP9aK1wHlVGDfuC2k07X4gk8ZX5Ks9anXJlBcZFrpC9okwD5Aeqj3XLK338x
 g5k/x+r87GwXjcBLnFi2TnNA2c8SWQY=
 =eGAm
 -----END PGP SIGNATURE-----

Merge tag 'platform-drivers-x86-v7.0-1' of git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86

Pull x86 platform driver updates from Ilpo Järvinen:
 "Highlights:

   - amd/pmf:
      - Avoid overwriting BIOS input values when events occur rapidly
      - Fix PMF driver issues related to S4 (in part on crypto/ccp side)
      - Add NPU metrics API (for accel side consumers)
      - Allow disabling Smart PC function through a module parameter

   - asus-wmi & HID/asus:
      - Unification of backlight control (replaces quirks)
      - Support multiple interfaces for controlling keyboard/RGB brightness
      - Simplify init sequence

   - hp-wmi:
      - Add manual fan control for Victus S models
      - Add fan mode keep-alive
      - Fix platform profile values for Omen 16-wf1xxx
      - Add EC offset to get the thermal profile

   - intel/pmc: Show substate residencies also for non-primary PMCs

   - intel/ISST:
      - Store and restore data for all domains
      - Write interface improvements

   - lenovo-wmi:
      - Support multiple Capability Data
      - Add HWMON reporting and tuning support

   - mellanox/mlx-platform: Add HI173 & HI174 support

   - surface/aggregator_registry: Add Surface Pro 11 (QCOM)

   - thinkpad_acpi: Add support for HW damage detection capability

   - uniwill: Implement cTGP setting

   - wmi:
      - Introduce marshalling support
      - Convert a few drivers to use the new buffer-based WMI API

   - tools/power/x86/intel-speed-select: Allow read operations for non-root

   - Miscellaneous cleanups / refactoring / improvements"

* tag 'platform-drivers-x86-v7.0-1' of git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86: (68 commits)
  platform/x86: lenovo-wmi-{capdata,other}: Fix HWMON channel visibility
  platform/x86: hp-wmi: Add EC offsets to read Victus S thermal profile
  platform: mellanox: mlx-platform: Add support DGX flavor of next-generation 800GB/s ethernet switch.
  platform: mellanox: mlx-platform: Add support for new Nvidia DGX system based on class VMOD0010
  HID: asus: add support for the asus-wmi brightness handler
  platform/x86: asus-wmi: add keyboard brightness event handler
  platform/x86: asus-wmi: remove unused keyboard backlight quirk
  HID: asus: listen to the asus-wmi brightness device instead of creating one
  platform/x86: asus-wmi: Add support for multiple kbd led handlers
  HID: asus: early return for ROG devices
  HID: asus: move vendor initialization to probe
  HID: asus: fortify keyboard handshake
  HID: asus: use same report_id in response
  HID: asus: initialize additional endpoints only for certain devices
  HID: asus: simplify RGB init sequence
  platform/wmi: string-kunit: Add missing oversized string test case
  platform/x86/amd/pmf: Added a module parameter to disable the Smart PC function
  platform/x86/uniwill: Implement cTGP setting
  platform/x86: uniwill-laptop: Introduce device descriptor system
  platform/x86/amd: Use scope-based cleanup for wbrf_record()
  ...
2026-02-13 15:39:15 -08:00
Len Brown
51496091dd tools/power turbostat: version 2026.02.14
Since release 2025.12.02:

Add L2 statistics columns for recent Intel processors:
	L2MRPS = L2 Cache M-References Per Second
	L2%hit = L2 Cache Hit %

Sort work and output by cpu# rather than core#

This commit:
	Version number and white space (indent -l160)
	No functional change.

Signed-off-by: Len Brown <len.brown@intel.com>
2026-02-13 14:08:33 -06:00
Len Brown
96718ad296 tools/power turbostat: Fix and document --header_iterations
The "header_iterations" option is commonly used to de-clutter
the screen of redundant header label rows in an interactive session:
Eg. every 10 rows:

$ sudo turbostat --header_iterations 10 -S -q -i 1

But --header_iterations was missing from turbostat.8

Also turbostat help advertised the "-N" short option
that did not actually work:

$ turbostat --help
  -N, --header_iterations num
		print header every num iterations

Repair "-N"
Document "--header_iterations" on turbostat.8

Signed-off-by: Len Brown <len.brown@intel.com>
2026-02-13 14:03:17 -06:00
Kaushlendra Kumar
8e5c0cc326 tools/power turbostat: Use strtoul() for iteration parsing
Replace strtod() with strtoul() and check errno for -n/-N options, since
num_iterations and header_iterations are unsigned long counters. Reject
zero and conversion errors; negative inputs wrap to large positive values
per standard unsigned semantics.

Signed-off-by: Kaushlendra Kumar <kaushlendra.kumar@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2026-02-13 14:03:17 -06:00
Len Brown
a2b4d0f8bf tools/power turbostat: Favor cpu# over core#
Turbostat collects statistics and outputs results in "topology order",
which means it prioritizes the core# over the cpu#.
The strategy is to minimize wakesups to a core -- which is
important when measuring an idle system.

But core order is problematic, because Linux core#'s are physical
(within each package), and thus subject to APIC-id scrambling
that may be done by the hardware or the BIOS.

As a result users may be are faced with rows in a confusing order:

sudo turbostat -q --show topology,Busy%,CPU%c6,UncMHz sleep 1
Core	CPU	Busy%	CPU%c6	UncMHz
-	-	1.25	72.18	3400
0	4	7.74	0.00
1	5	1.77	88.59
2	6	0.48	96.73
3	7	0.21	98.34
4	8	0.14	96.85
5	9	0.26	97.55
6	10	0.44	97.24
7	11	0.12	96.18
8	0	5.41	0.31	3400
8	1	0.19
12	2	0.41	0.22
12	3	0.08
32	12	0.04	99.21
33	13	0.25	94.92

Abandon the legacy "core# topology order" in favor of simply
ordering by cpu#, with a special case to handle HT siblings
that may not have adjacent cpu#'s.

sudo ./turbostat -q --show topology,Busy%,CPU%c6,UncMHz sleep 1
1.003001 sec
Core	CPU	Busy%	CPU%c6	UncMHz
-	-	1.38	80.55	1600
8	0	10.94	0.00	1600
8	1	0.53
12	2	2.90	0.45
12	3	0.11
0	4	1.96	91.20
1	5	0.97	96.40
2	6	0.24	94.72
3	7	0.31	98.01
4	8	0.20	98.20
5	9	0.62	96.00
6	10	0.06	98.15
7	11	0.12	99.31
32	12	0.04	99.07
33	13	0.27	95.09

The result is that cpu#'s now take precedence over core#'s.

Signed-off-by: Len Brown <len.brown@intel.com>
2026-02-13 14:03:10 -06:00
Len Brown
6be5c151eb tools/power turbostat: Expunge logical_cpu_id
There is only once cpu_id name space -- cpu_id.
Expunge the term logical_cpu_id.

No functional change.

Signed-off-by: Len Brown <len.brown@intel.com>
2026-02-13 08:53:17 -06:00
Len Brown
070e92361e tools/power turbostat: Enhance HT enumeration
Record the cpu_id of each CPU HT sibling -- will need this later.

Rename "thread_id" to "ht_id" to disambiguate that the scope
of this id is within a Core -- it is not a global cpu_id.

No functional change.

Signed-off-by: Len Brown <len.brown@intel.com>
2026-02-13 08:53:17 -06:00
Len Brown
ddf60e38ca tools/power turbostat: Simplify global core_id calculation
Standardize the generation of globally unique core_id's
in a macro, and simplify the related code.

No functional change.

Signed-off-by: Len Brown <len.brown@intel.com>
2026-02-13 08:53:17 -06:00
Len Brown
a854684986 tools/power turbostat: Unify even/odd/average counter referencing
Update the syntax of accesses to the even and odd counters
to match the average counters.

No functional change.

Signed-off-by: Len Brown <len.brown@intel.com>
2026-02-13 08:53:17 -06:00
Len Brown
3cecd4a62d tools/power turbostat: Allocate average counters dynamically
The current static definition of average{} is inconsistent with
the dynamically allocated even{} and odd{} counters.

Allocate average{} counters dynamically.

No functional change.

Signed-off-by: Len Brown <len.brown@intel.com>
2026-02-13 08:53:17 -06:00
Len Brown
439632cf95 tools/power turbostat: Delete core_data.core_id
Delete redundant core_data.core_id.
Use cpus[].core_id as the single copy of the truth.

No functional change.

Signed-off-by: Len Brown <len.brown@intel.com>
2026-02-13 08:53:17 -06:00
Len Brown
5e160646f4 tools/power turbostat: Rename physical_core_id to core_id
The Linux Kernel topology sysfs is flawed.
core_id is not globally unique, but is per-package.

Turbostat works around this when it needs to, with

        rapl_core_id = cpus[cpu].core_id;
        rapl_core_id += cpus[cpu].package_id * nr_cores_per_package

Otherwise, turbostat handles core_id as subservient to each package.

As there is only one core_id namespace, rename
physical_core_id to simply be core_id.

No functional change.

Signed-off-by: Len Brown <len.brown@intel.com>
2026-02-13 08:53:17 -06:00
Len Brown
4aaf7d07a0 tools/power turbostat: Cleanup package_id
The kernel topology sysfs uses the name "physical_package_id"
because it is allowed to be sparse.

Inside Turbostat, that physical package_id namespace is the only
package_id namespace, so re-name it to simply be "package_id"
in cpus[].

Delete the redundant copy of package_id in pkg_data.
Rely instead on the single copy of the truth in cpus[].

No functional change.

Signed-off-by: Len Brown <len.brown@intel.com>
2026-02-13 08:53:17 -06:00
Len Brown
54ca69f33c tools/power turbostat: Cleanup internal use of "base_cpu"
Disambiguate the uses "base_cpu":

master_cpu: lowest permitted cpu#, read global MSRs here
package_data.first_cpu: lowest permitted cpu# in that package
core_data.first_cpu: lowest permitted cpu# in the core
current_cpu: where I'm running now

No functional change.

Signed-off-by: Len Brown <len.brown@intel.com>
2026-02-13 08:53:17 -06:00
Len Brown
dd23bfe4c3 tools/power turbostat: Add L2 cache statistics
version 2026.02.04

Add support for L2 cache statistics: L2MRPS and L2%hit
L2 statistics join the LLC in the "cache" counter group.

While the underlying LLC perf kernel support was architectural,
L2 perf counters are model-specific:

Support Intel Xeon -- Sapphire Rapids and newer.
Support Intel Atom -- Gracemont and newer.
Support Intel Hybrid -- Alder Lake and newer.

Example:

alder-lake-n$ sudo turbostat --quiet --show CPU,Busy%,cache my_workload
CPU	Busy%	LLCMRPS	LLC%hit	L2MRPS	L2%hit
-	49.82	1210	85.02	2909	31.63
0	99.14	322	88.89	767	32.38
1	0.91	1	32.47	1	18.86
2	0.20	0	40.78	0	23.34
3	99.17	295	81.79	706	31.89
4	0.68	1	58.71	1	15.61
5	99.16	299	85.65	726	31.32
6	0.08	0	45.35	0	31.71
7	99.21	293	83.63	707	30.92

where "my_workload" is a wrapper for a yogini workload
that has 4 fully-busy threads with 2MB working set each.

Note that analogous to the system summary for multiple LLC systems,
the system summary row for the L2 is the aggregate of all CPUS in the
system -- there is no per-cache roll-up.

Signed-off-by: Len Brown <len.brown@intel.com>
2026-02-13 08:52:53 -06:00
Len Brown
a9c7a1a292 tools/power turbostat: Remove redundant newlines from err(3) strings
err(3) supplies a newline at the end of the string.
No need to end err(3) strings with '\n'.

Signed-off-by: Len Brown <len.brown@intel.com>
2026-02-04 14:52:12 -06:00
Len Brown
b991074a51 tools/power turbostat: Allow more use of is_hybrid flag
The "is_hybrid" is set and used only in !quiet mode.

Make it valid in both quiet and !quiet mode to allow more uses.

Signed-off-by: Len Brown <len.brown@intel.com>
2026-02-04 14:52:12 -06:00
Len Brown
041e975937 tools/power turbostat: Rename "LLCkRPS" column to "LLCMRPS"
The purpose of the LLC References per Second LLC column
is to qualify the significance of the LLC%hit column.

If RPS is high, then the hit rate matters.
If RPS is low, then the hit rate is not significant.

Remove unnecessary and distracting precision in the RPS column
by dividing my a million rather than by a thousand.

Signed-off-by: Len Brown <len.brown@intel.com>
2026-02-04 14:52:12 -06:00
Len Brown
785953cf6e tools/power turbostat.8: Document the "--force" option
Starting in turbostat v2025.01.14, turbostat refused to run
on unsupported hardware, pointing to "RUN THE LATEST VERSION"
on turbostat(8).

At that time, turbostat supported and advertised the "--force"
parameter to run anyway (with unsupported results).

Also document "--force" on turbostat.8.

Signed-off-by: Len Brown <len.brown@intel.com>
2026-02-04 14:52:12 -06:00
Len Brown
d0f7093ad5 tools/power turbostat: Harden against unexpected values
Divide-by-zero resulted if LLC references == 0

Pull the percentage division into pct() to centralize sanity checks there.

Fixes: 8808292799 ("tools/power turbostat: Print "nan" for out of range percentages")

Signed-off-by: Len Brown <len.brown@intel.com>
2026-02-04 14:52:11 -06:00
Len Brown
61764831d5 tools/power turbostat: Dump hypervisor name
Sometimes useful to know which hypervisor is running beneath us...

Signed-off-by: Len Brown <len.brown@intel.com>
2026-02-04 14:52:11 -06:00
Len Brown
00b9e2a7fa tools/power turbostat: Dump CPUID.1.ECX[31] (Hypervisor)
Both Intel and AMD use CPUID.1.ECX[31] to distinguish
between hypervisor and real hardware.
Indicate "HV" or "No-HV" accordingly.

Signed-off-by: Len Brown <len.brown@intel.com>
2026-02-04 14:52:11 -06:00
Len Brown
bd1b6608d7 tools/power turbostat: Dump CPUID(1) consistently with CPUID(6)
We dumped selected CPUID(1) features using a format that showed '-'
for a missing feature.  Not so friendly to parse a bunch of dashes
when features are missing...

For CPUID(1) adopt the format we used for CPUID(6): 'No-FEATURE'
means that 'FEATURE' is not present.

Signed-off-by: Len Brown <len.brown@intel.com>
2026-02-04 14:52:11 -06:00
Len Brown
16cc8f249c tools/power turbostat: AMD: msr offset 0x611 read failed: Input/output error
Turbostat exits during RAPL probe with:

turbostat: cpu0: msr offset 0x611 read failed: Input/output error

A binary with this bug can be used successfully with
the option "--no-msr"

Fix this regression by trusting the static AMD RAPL MSR offset.

Fixes: 19476a592b ("tools/power turbostat: Validate RAPL MSRs for AWS Nitro Hypervisor")
Signed-off-by: Len Brown <len.brown@intel.com>
2026-02-04 14:52:11 -06:00
Srinivas Pandruvada
6142b726e6 tools/power/x86/intel-speed-select: v1.25 release
This version includes the following changes:
- Allow read only commands for non root users when permitted
- Fix file descriptor leak in isolate_cpus()
- Replace hardcoded libnl3 include path

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
2026-01-16 16:03:21 -08:00
Malaya Kumar Rout
56c17ee151 tools/power/x86/intel-speed-select: Fix file descriptor leak in isolate_cpus()
The file descriptor opened in isolate_cpus() when (!level) is true was
not being closed before returning, causing a file descriptor leak in
both the error path and the success path.

When write() fails at line 950, the function returns at line 953 without
closing the file descriptor. Similarly, on success, the function returns
at line 956 without closing the file descriptor.

Add close(fd) calls before both return statements to fix the resource
leak. This follows the same pattern used elsewhere in the same function
where file descriptors are properly closed before returning (see lines
1005 and 1027).

Fixes: 997074df65 ("tools/power/x86/intel-speed-select: Use cgroup v2 isolation")
Signed-off-by: Malaya Kumar Rout <mrout@redhat.com>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
2026-01-16 16:03:21 -08:00
Khem Raj
21adcd5ec9 tools/power/x86/intel-speed-select: Use pkg-config for libnl-3.0 detection
Replace hardcoded libnl3 include path with pkg-config detection to
improve portability across different distributions and build environments.

The previous implementation used a fixed path constructed from the
compiler's sysroot, which could fail on systems with non-standard
library installations. Now the build system:
- Attempts to detect libnl-3.0 include paths using pkg-config
- Falls back to /usr/include/libnl3 if pkg-config is unavailable
- Maintains backward compatibility with existing build configurations

This ensures the tool builds correctly on a wider range of systems
while preserving existing behavior when pkg-config is not present.

Closes:https://bugzilla.kernel.org/show_bug.cgi?id=220819
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
2026-01-16 16:03:20 -08:00
Srinivas Pandruvada
6588b8845e tools/power/x86/intel-speed-select: Allow non root users
When permitted by the file /dev/isst_interface, allow to issue commands
for non root users.

When user id is non root, check if  "/dev/isst_interface" can still be
opened. If this file can be opened, allow all read only commands.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
2026-01-16 16:03:20 -08:00
João Marcos Costa
7799ba2160 cpupower: make systemd unit installation optional
cpupower currently installs a cpupower.service unit file into unitdir
unconditionally, regardless of whether systemd is used by the host.

Improve the installation procedure by making this systemd step optional:
a 'SYSTEMD' build parameter that defaults to 'true' and can be set to
'false' to disable the installation of systemd's unit file.

Since 'SYSTEMD' defaults to true, the current behavior is kept as the
default.

Link: https://lore.kernel.org/r/20260113132753.1730020-2-joaomarcos.costa@bootlin.com
Signed-off-by: João Marcos Costa <joaomarcos.costa@bootlin.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2026-01-16 13:41:26 -07:00
Kaushlendra Kumar
ff72619e11 tools/power cpupower: Show C0 in idle-info dump
`cpupower idle-info -o` skipped C0 because the loop began at 1:

  before:
    states:
      C1 ... latency[002] residency[00002]
      C2 ... latency[010] residency[00020]
      C3 ... latency[133] residency[00600]

  after:
    states:
      C0 ... latency[000] residency[00000]
      C1 ... latency[002] residency[00002]
      C2 ... latency[010] residency[00020]
      C3 ... latency[133] residency[00600]

Start iterating at index 0 so the idle report mirrors sysfs and
includes C0 stats.

Link: https://lore.kernel.org/r/20251202065403.1492807-1-kaushlendra.kumar@intel.com
Signed-off-by: Kaushlendra Kumar <kaushlendra.kumar@intel.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2025-12-15 12:33:29 -07:00
Kaushlendra Kumar
f9bd3762cf tools/power cpupower: Reset errno before strtoull()
cpuidle_state_get_one_value() never cleared errno before calling
strtoull(), so a prior ERANGE caused every cpuidle counter read to
return zero. Reset errno to 0 before the conversion so each sysfs read
is evaluated independently.

Link: https://lore.kernel.org/r/20251201121745.3776703-1-kaushlendra.kumar@intel.com
Signed-off-by: Kaushlendra Kumar <kaushlendra.kumar@intel.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2025-12-15 12:33:28 -07:00
Kaushlendra Kumar
1b9aaf36b7 tools/cpupower: Use strcspn() to strip trailing newline
Replace manual newline removal with strcspn() which is safer and
cleaner. This avoids potential out-of-bounds access on empty strings
and handles the case where no newline exists.

Link: https://lore.kernel.org/r/20251127044536.715722-1-kaushlendra.kumar@intel.com
Signed-off-by: Kaushlendra Kumar <kaushlendra.kumar@intel.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2025-12-15 12:33:28 -07:00
Kaushlendra Kumar
24858a8416 tools/cpupower: Fix inverted APERF capability check
The capability check was inverted, causing the function to return
error when APERF support is available and proceed when it is not.

Negate the condition to return error only when APERF capability
is absent.

Link: https://lore.kernel.org/r/20251126091613.567480-1-kaushlendra.kumar@intel.com
Signed-off-by: Kaushlendra Kumar <kaushlendra.kumar@intel.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2025-12-15 12:33:28 -07:00
Kaushlendra Kumar
6b401a5b2d cpupower: idle_monitor: fix incorrect value logged after stop
The cpuidle sysfs monitor printed the previous sample’s counter
value in cpuidle_stop() instead of the freshly read one. The dprint
line used previous_count[cpu][state] while current_count[cpu][state]
had just been populated. This caused misleading debug output.

Switch the logging to current_count so the post-interval snapshot
matches the displayed value.

Link: https://lore.kernel.org/r/20251202044012.3844790-1-kaushlendra.kumar@intel.com
Signed-off-by: Kaushlendra Kumar <kaushlendra.kumar@intel.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2025-12-15 12:33:28 -07:00