Linux Power Management development
 help / color / mirror / Atom feed
* [PATCH v6 0/5] cpufreq: CPPC: Preserve OSPM-set registers across hotplug and unload
@ 2026-10-20 12:18 Sumit Gupta
  2026-10-20 12:18 ` [PATCH v6 1/5] ACPI: CPPC: Order performance-control updates Sumit Gupta
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Sumit Gupta @ 2026-10-20 12:18 UTC (permalink / raw)
  To: rafael, viresh.kumar, pierre.gondois, christian.loehle,
	ionela.voinescu, zhenglifeng1, zhanjie9, lenb, ray.huang,
	mario.limonciello, perry.yuan, kprateek.nayak,
	maciej.wieczor-retman, pawel.chmielewski, linux-pm, linux-acpi,
	acpica-devel, linux-kernel
  Cc: linux-tegra, treding, jonathanh, vsethi, ksitaraman, sanjayc,
	mochs, bbasu, sumitg

This series preserves the OSPM-set CPPC registers (Energy Performance
Preference, Autonomous Activity Window, Autonomous Selection - set via
sysfs) across CPU hotplug and suspend/resume. On driver unload, it puts
back the values they had before the driver loaded.

To do this, it keeps the CPPC cpufreq policy alive across CPU hotplug.
It also orders the performance-control writes in cppc_set_perf(), so
that restoring them after a platform reset never sends an invalid
request.

Without online()/offline() callbacks, the core tears a policy down when
its last CPU goes offline and rebuilds it on the way back, re-reading the
CPPC capabilities each time. The values written to these registers can
be lost:

 - Across CPU hotplug or suspend/resume: the platform may reset them
   while the CPU is offline or suspended.
 - On driver unload: the driver-written value is left in the register
   instead of returning to its pre-driver state.

Handle these with:

 - Patch 1: orders the Desired, MIN and MAX writes in cppc_set_perf(), so
   that the platform never sees an invalid request. Christian proposed
   it in [6], and this version adds fixes found in testing.
 - Patch 2: adds online()/offline() callbacks so the core keeps policy
   alive across CPU hotplug instead of tearing it down and rebuilding it.
 - Patch 3: makes the autonomous selection register helpers take a u64.
 - Patch 4: adds a table-driven mechanism that captures each register's
   firmware value at init(), restores it from offline(), and reapplies
   the OSPM-set value from online().
 - Patch 5: extends the same save/restore to system suspend/resume.

v5[5] -> v6:
 - Patch 1 (new):
   - add Christian's patch [6] ordering the performance-control writes.
   - init() requests the full range when the live MAX is zero, to avoid
     a probe failure.
   - clamp Desired to MIN and MAX, as rounding can put it below MIN.
 - Patch 2:
   - offline() lowers MIN to lowest_perf with Desired, so that the parked
     request stays valid. (Pierre)
   - drop cppc_cpufreq_prepare_perf_restore(), as cppc_set_perf() now
     orders the writes. (Jie Zhan, Christian, Pierre)
   - online() caches the restored limits only once the platform takes
     them, as set_target() and fast_switch() do.
 - Patch 3:
   - add Prateek's Reviewed-by and Tested-by.
 - Patch 4:
   - replace struct cppc_saved_vals with a u64 array indexed by register
     and type, which drops cppc_cpufreq_saved_reg_value(). (Pierre)
 - Patch 5:
   - fie_init() covers related_cpus, so CPUs onlined after resume() also
     restart their frequency invariance updates. (Sashiko, Pierre)
   - drop the fast-path cache reset in resume(), as online() does it.
 - Prateek's v5 Tested-by is not carried to patches 2, 4 and 5, as they
   changed. A retest would be welcome.

Christian Loehle (1):
  ACPI: CPPC: Order performance-control updates

Sumit Gupta (4):
  cpufreq: CPPC: Keep the policy across CPU hotplug
  ACPI: CPPC: Make autonomous selection helpers take a u64
  cpufreq: CPPC: Preserve OSPM-set registers across hotplug and unload
  cpufreq: CPPC: Preserve OSPM-set registers across suspend/resume

 drivers/acpi/cppc_acpi.c       | 314 ++++++++++++++++------
 drivers/cpufreq/amd-pstate.c   |   2 +-
 drivers/cpufreq/cppc_cpufreq.c | 465 +++++++++++++++++++++++++++++++--
 include/acpi/cppc_acpi.h       |   9 +-
 4 files changed, 684 insertions(+), 106 deletions(-)

[1] v1: https://lore.kernel.org/lkml/20260623095403.3407436-1-sumitg@nvidia.com/
[2] v2: https://lore.kernel.org/lkml/20260716153820.2007095-1-sumitg@nvidia.com/
[3] v3: https://lore.kernel.org/lkml/20260724215937.3368276-1-sumitg@nvidia.com/
[4] v4: https://lore.kernel.org/lkml/20260806200857.601152-1-sumitg@nvidia.com/
[5] v5: https://lore.kernel.org/lkml/20260916103820.1760297-1-sumitg@nvidia.com/
[6] https://lore.kernel.org/lkml/1be30b2b-e1e5-41ed-a0dc-0dd5ad3c47cd@arm.com/

-- 
2.34.1


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

end of thread, other threads:[~2026-10-20 16:11 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-20 12:18 [PATCH v6 0/5] cpufreq: CPPC: Preserve OSPM-set registers across hotplug and unload Sumit Gupta
2026-10-20 12:18 ` [PATCH v6 1/5] ACPI: CPPC: Order performance-control updates Sumit Gupta
2026-10-20 12:18 ` [PATCH v6 2/5] cpufreq: CPPC: Keep the policy across CPU hotplug Sumit Gupta
2026-10-20 12:18 ` [PATCH v6 3/5] ACPI: CPPC: Make autonomous selection helpers take a u64 Sumit Gupta
2026-10-20 16:10   ` Christian Loehle
2026-10-20 12:18 ` [PATCH v6 4/5] cpufreq: CPPC: Preserve OSPM-set registers across hotplug and unload Sumit Gupta
2026-10-20 16:11   ` Christian Loehle
2026-10-20 12:18 ` [PATCH v6 5/5] cpufreq: CPPC: Preserve OSPM-set registers across suspend/resume Sumit Gupta

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