Skip to content

[linux-nvidia-6.17]: Replace CPPC Autonomous Series with Version That Has Been Accepted Upstream#346

Draft
jamieNguyenNVIDIA wants to merge 22 commits intoNVIDIA:24.04_linux-nvidia-6.17-nextfrom
jamieNguyenNVIDIA:jamien/replace-cppc
Draft

[linux-nvidia-6.17]: Replace CPPC Autonomous Series with Version That Has Been Accepted Upstream#346
jamieNguyenNVIDIA wants to merge 22 commits intoNVIDIA:24.04_linux-nvidia-6.17-nextfrom
jamieNguyenNVIDIA:jamien/replace-cppc

Conversation

@jamieNguyenNVIDIA
Copy link
Copy Markdown
Collaborator

@jamieNguyenNVIDIA jamieNguyenNVIDIA commented Mar 17, 2026

Summary

Replaces 8 NVIDIA SAUCE CPPC patches in the 24.04 6.17 tree with the
upstream-accepted series, reducing the out-of-tree maintenance surface
for ACPI CPPC autonomous selection and performance control.

22 commits over 24.04_linux-nvidia-6.17-next, structured as:

  1. 8 reverts of the existing SAUCE patches (in dependency-safe order),
    removing the out-of-tree min/max_perf, perf_limited, auto_sel/EPP, and
    sysfs helper code that the upstream series replaces.

  2. 11 upstream cherry-picks/backports of the ACPI CPPC and cppc_cpufreq
    series merged via linux-pm: cppc_get_perf API, FFH/SystemMemory
    support in cppc_set_epp_perf, MIN/MAX_PERF in target callbacks,
    perf_limited sysfs interface, generic sysfs show/store helpers,
    cleanup of cppc_perf_caps / cppc_perf_ctrls structures, EPP
    constant rename, DESIRED_PERF probe warning, and cpc_read() return
    value checking. Two are minimally adapted backports (commits
    ed93528a8376, 07d53b6887ff) per their [jamien: ...] notes.

  3. One additional upstream cherry-pick as a prerequisite:
    cpufreq: Remove max_freq_req update for pre-existing policy
    (upstream 04aa9d0726cc, by Pierre Gondois). Removes a now-redundant
    else branch in cpufreq_policy_online().

  4. Two SAUCE backports of in-flight upstream patches, both still in
    review on linux-pm:

    • NVIDIA: SAUCE: cpufreq: Set policy->min and max as real QoS constraints — adapted from
      lore/20260423084731.1090384-2-pierre.gondois@arm.com.
      Makes driver-set policy->min/max durable QoS constraints. 6.17
      lacks the embedded-freq_qos_request refactor (9266b4da051a) and
      the boost_freq_req work (6e39ba4e5a82); reconciliation preserves
      6.17's heap-allocated pointer model — see commit trailer.
    • NVIDIA: SAUCE: cpufreq: CPPC: add autonomous mode boot parameter support — v2 from
      lore/20260424201814.230071-1-sumitg@nvidia.com.
      Adds the cppc_cpufreq.auto_sel_mode= boot parameter to engage CPPC
      autonomous mode at boot.

If either of the two in-review patches changes shape upstream, the
backport will need a redo.

Test results

Built and runtime-tested on two arm64 systems:

  • DGX Spark (20-core, AUTO_SEL register supported) with
    cppc_cpufreq.auto_sel_mode=1 set via modprobe.d. All 20 CPUs come up
    in autonomous mode with epp=0. Verified: hotplug-durability of
    scaling_max_freq while autonomous mode is active; auto_select toggle;
    EPP read/write/validation; perf_limited and auto_act_window interfaces;
    100-iteration stress on auto_select / EPP / scaling_max_freq writes;
    rmmod + modprobe cycle. Clean.

  • CG4 (288-core, AUTO_SEL not supported). SAUCE handles
    -EOPNOTSUPP cleanly. Hotplug-durability of scaling_max_freq verified.
    Clean.

Static: checkpatch.pl --strict clean on all SAUCE / new commits;
x86_64 allmodconfig cpufreq drivers and arm64 defconfig with CPPC
build clean.

Test plan checklist

  • Build on x86_64 (allmodconfig cpufreq drivers)
  • Build on arm64 (defconfig + CPPC + virtual-cpufreq)
  • checkpatch.pl --strict on all SAUCE / new commits
  • QoS-durability across hotplug — auto_sel-supported HW (Spark)
  • QoS-durability across hotplug — auto_sel-unsupported HW (UTSkinnyJoe)
  • Sysfs writes (auto_select, EPP, auto_act_window, perf_limited, scaling_*_freq)
  • Sysfs validation (EPP=256 rejected, perf_limited=4 rejected)
  • Stress: 100+ iterations of toggle/EPP/freq writes; 5-iter hotplug
  • rmmod + modprobe cycle

LP: https://bugs.launchpad.net/bugs/2131705

@jamieNguyenNVIDIA
Copy link
Copy Markdown
Collaborator Author

jamieNguyenNVIDIA commented Mar 17, 2026

test_cppc_cpufreq.sh

Attaching test script used to verify this PR.

Results from Spark:

cppc_cpufreq test suite
========================================
Tue Mar 17 11:10:44 AM PDT 2026
6.17.0-1012-nvidia-64k


Test 1: Basic driver load and sysfs layout
  PASS: scaling_driver is cppc_cpufreq (got 'cppc_cpufreq')
  PASS: governor is set (got 'performance', not '')
  PASS: auto_select sysfs exists
  PASS: auto_act_window sysfs exists
  PASS: energy_performance_preference_val sysfs exists
  PASS: perf_limited sysfs exists
  PASS: min_perf sysfs removed
  PASS: max_perf sysfs removed

Test 2: auto_sel_mode boot parameter
  auto_sel_mode=Y
  PASS: boot param is read-only (0444) (got '444')
./test_cppc_cpufreq.sh: line 80: /sys/module/cppc_cpufreq/parameters/auto_sel_mode: Permission denied
  PASS: boot param rejects writes
  PASS: auto_select enabled when boot param=Y (got '1')
  PASS: EPP set to performance (0) by boot param (got '0')
  PASS: auto_select=1 on all CPUs

Test 3: Runtime auto_select toggle via sysfs
  PASS: enable auto_select (got '1')
  PASS: disable auto_select (got '0')
  PASS: governor changes accepted after auto_select disable (perf=2808000, other=338000)

Test 4: MIN_PERF/MAX_PERF via scaling_min/max_freq
  cpuinfo range: 338000-2808000 kHz
  PASS: scaling_max_freq accepts midpoint (got '1573000')
  PASS: scaling_min_freq accepts min (got '338000')
  PASS: frequency clamped by scaling_max_freq (1573000 <= ~1573000)

Test 5: Energy Performance Preference
  PASS: write EPP=0 (performance)
  PASS: read back EPP=0 (got '0')
  PASS: write EPP=255 (energy-efficiency)
  PASS: read back EPP=255 (got '255')
  PASS: write EPP=128 (balanced)
  PASS: read back EPP=128 (got '128')
  PASS: reject EPP=256 (out of range)

Test 6: perf_limited register
  PASS: perf_limited readable (value=0)
  PASS: clear bit 0 (desired excursion)
  PASS: clear bit 1 (minimum excursion)
  PASS: clear both bits
  PASS: zero is valid no-op
  PASS: reject 0x4 (invalid bit)
  PASS: reject 0xff (invalid bits)

Test 7: CPU hotplug
  PASS: cpu1 offlined
  PASS: cpu1 re-onlined
  PASS: auto_select readable after hotplug (value=1)
  PASS: driver restored after hotplug (got 'cppc_cpufreq')

Test 8: auto_act_window sysfs
  PASS: auto_act_window readable (value=1)
  PASS: write auto_act_window=0

Test 9: Diagnostics in dmesg
  PASS: no DESIRED_PERF warning (firmware is compliant)
  PASS: no kernel errors related to CPPC (got '0')

Test 10: Stress / regression
  Rapid governor switching (performance <-> schedutil, 100 iterations)...
  PASS: 100 governor switches completed
  Rapid auto_select toggling (100 iterations)...
  PASS: 100 auto_select toggles completed
  Rapid scaling_max_freq changes (50 iterations)...
  PASS: 50 scaling_max_freq changes completed
  PASS: no kernel warnings after stress (got '0')

========================================
Results: 45 tests: 45 passed, 0 failed, 0 skipped
ALL TESTS PASSED

Results from GH:

cppc_cpufreq test suite
========================================
Tue Mar 17 18:22:52 UTC 2026
6.17.0-1012-nvidia-64k


Test 1: Basic driver load and sysfs layout
  PASS: scaling_driver is cppc_cpufreq (got 'cppc_cpufreq')
  PASS: governor is set (got 'performance', not '')
  PASS: auto_select sysfs exists
  PASS: auto_act_window sysfs exists
  PASS: energy_performance_preference_val sysfs exists
  PASS: perf_limited sysfs exists
  PASS: min_perf sysfs removed
  PASS: max_perf sysfs removed

Test 2: auto_sel_mode boot parameter
  auto_sel_mode=N
  PASS: boot param is read-only (0444) (got '444')
./test_cppc_cpufreq.sh: line 80: /sys/module/cppc_cpufreq/parameters/auto_sel_mode: Permission denied
  PASS: boot param rejects writes
  SKIP: auto_sel_mode not enabled (boot without param to test this)

Test 3: Runtime auto_select toggle via sysfs
  SKIP: auto_select not supported

Test 4: MIN_PERF/MAX_PERF via scaling_min/max_freq
  cpuinfo range: 81000-3384000 kHz
  PASS: scaling_max_freq accepts midpoint (got '1732500')
  PASS: scaling_min_freq accepts min (got '81000')
  PASS: frequency clamped by scaling_max_freq (1732500 <= ~1732500)

Test 5: Energy Performance Preference
  SKIP: EPP not supported on this platform

Test 6: perf_limited register
  PASS: perf_limited readable (value=0)
  PASS: clear bit 0 (desired excursion)
  PASS: clear bit 1 (minimum excursion)
  PASS: clear both bits
  PASS: zero is valid no-op
  PASS: reject 0x4 (invalid bit)
  PASS: reject 0xff (invalid bits)

Test 7: CPU hotplug
  PASS: cpu1 offlined
  PASS: cpu1 re-onlined
  PASS: auto_select readable after hotplug (value=<unsupported>)
  PASS: driver restored after hotplug (got 'cppc_cpufreq')

Test 8: auto_act_window sysfs
  SKIP: auto_act_window not supported on this platform

Test 9: Diagnostics in dmesg
  PASS: no DESIRED_PERF warning (firmware is compliant)
  PASS: no kernel errors related to CPPC (got '0')

Test 10: Stress / regression
  Rapid governor switching (performance <-> schedutil, 100 iterations)...
  PASS: 100 governor switches completed
  SKIP: auto_select not supported for toggle stress
  Rapid scaling_max_freq changes (50 iterations)...
  PASS: 50 scaling_max_freq changes completed
  PASS: no kernel warnings after stress (got '0')

========================================
Results: 34 tests: 29 passed, 0 failed, 5 skipped
ALL TESTS PASSED

@arighi
Copy link
Copy Markdown
Collaborator

arighi commented Mar 17, 2026

The commits look good, but technically they're still NVIDIA: SAUCE since they come from linux-next (for now).

So, if we follow the "Canonical stable kernel team" style, we should revert the old ones and re-apply the new ones, still as NVIDIA: SAUCE. If we follow the "Canonical devel kernel team" workflow, we should just drop the old patches (no revert, just a rebase + remove) and apply only the new ones. But the latter isn't really compatible with a PR...

Personally I think I like the rebase+drop approach more, because. moving forward with kernel versions, old patches may have conflicts, so we may end up spending time fixing the conflicts to essentially revert the patch later and re-apply a new one.

@clsotog
Copy link
Copy Markdown
Collaborator

clsotog commented Mar 18, 2026

The last commit needs the Sauce. Its not upstream yet?

@jamieNguyenNVIDIA
Copy link
Copy Markdown
Collaborator Author

The last commit needs the Sauce. Its not upstream yet?

Correct. Sumit only sent it yesterday, and it has not received feedback. I sent this PR early, and plan to adjust these commits as things develop upstream.

@nvmochs
Copy link
Copy Markdown
Collaborator

nvmochs commented Mar 23, 2026

I think we'd also want to include this other patch that Sumit also just posted (https://lore.kernel.org/all/20260318095005.2437960-1-sumitg@nvidia.com/), which was a follow-up to
ACPI: CPPC: Add cppc_get_perf() API to read performance controls

@jamieNguyenNVIDIA
Copy link
Copy Markdown
Collaborator Author

The commits look good, but technically they're still NVIDIA: SAUCE since they come from linux-next (for now).

So, if we follow the "Canonical stable kernel team" style, we should revert the old ones and re-apply the new ones, still as NVIDIA: SAUCE. If we follow the "Canonical devel kernel team" workflow, we should just drop the old patches (no revert, just a rebase + remove) and apply only the new ones. But the latter isn't really compatible with a PR...

Personally I think I like the rebase+drop approach more, because. moving forward with kernel versions, old patches may have conflicts, so we may end up spending time fixing the conflicts to essentially revert the patch later and re-apply a new one.

Thanks. It looks like the linux-next patches have made it into mainline so I've updated these references accordingly.

I'll ask Canonical about doing the rebase+drop approach for this series.

@jamieNguyenNVIDIA
Copy link
Copy Markdown
Collaborator Author

I think we'd also want to include this other patch that Sumit also just posted (https://lore.kernel.org/all/20260318095005.2437960-1-sumitg@nvidia.com/), which was a follow-up to ACPI: CPPC: Add cppc_get_perf() API to read performance controls

Thanks. I've backported this patch in the latest version.

@clsotog clsotog requested review from clsotog March 24, 2026 21:03
Copy link
Copy Markdown
Collaborator

@clsotog clsotog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The last changes looks ok.
Acked-by: Carol L Soto <csoto@nvidia.com>

@jamieNguyenNVIDIA jamieNguyenNVIDIA marked this pull request as draft March 24, 2026 21:16
@jamieNguyenNVIDIA
Copy link
Copy Markdown
Collaborator Author

Converted to draft as the final commits are still being reviewed by the community:

  1. 4092db4
  2. 4e03dbd

@nvidia-bfigg nvidia-bfigg force-pushed the 24.04_linux-nvidia-6.17-next branch from 9364d8b to 8dab82a Compare April 2, 2026 12:01
@nvidia-bfigg nvidia-bfigg force-pushed the 24.04_linux-nvidia-6.17-next branch from 8dab82a to 891b8e9 Compare April 8, 2026 12:01
@jamieNguyenNVIDIA jamieNguyenNVIDIA force-pushed the jamien/replace-cppc branch 2 times, most recently from 865bb6e to a000c64 Compare April 10, 2026 18:55
@jamieNguyenNVIDIA
Copy link
Copy Markdown
Collaborator Author

@jamieNguyenNVIDIA jamieNguyenNVIDIA force-pushed the jamien/replace-cppc branch 2 times, most recently from be84090 to 8376d26 Compare April 16, 2026 20:56
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 16, 2026

✅ Patchscan: No Missing Fixes

All cherry-picked commits have been checked — no missing upstream fixes found.

@jamieNguyenNVIDIA
Copy link
Copy Markdown
Collaborator Author

Differences between this and the 7.0 PR:

  • This includes reverts of the older v4 series that we took. Those were rebased away in 7.0
  • This includes the following prereqs to help with the cherry picks:
204f8372508f7 ACPI: CPPC: Rename EPP constants for clarity
adf60781adbf2 ACPI: CPPC: Clean up cppc_perf_caps and cppc_perf_ctrls structs
07b350a1a5da2 cpufreq: CPPC: Add generic helpers for sysfs show/store
  • ACPI: CPPC: Check cpc_read() return values consistently required porting. In 7.0, we mitigated this by taking the following prerquisites:
28aac1f6b4a1d ACPI: CPPC: Fix uninitialized ref variable in cppc_get_perf_caps()
ac179066fd0fe ACPI: CPPC: Move reference performance to capabilities

However, on 6.17, those prerequisites would have required more prerequisites:

f9cadb3d56912 -- "Factor out and export per-cpu cppc_perf_ctrs_in_pcc_cpu()"
16d39e2bf9607 -- "Remove unused parameter in cppc_perf_from_fbctrs()"

To avoid the cascading prerequisites, I went with the backport instead.

@nvmochs
Copy link
Copy Markdown
Collaborator

nvmochs commented Apr 16, 2026

@jamieNguyenNVIDIA I know this is still in draft mode, but went ahead and reviewed.

The reverts and first 3 picks look fine and I verified the SAUCE patch matches LKML.


3c977b0 ACPI: CPPC: Check cpc_read() return values consistently
beb6bd9 cpufreq: CPPC: Add sysfs documentation for perf_limited
4fd0d97 ACPI: CPPC: add APIs and sysfs interface for perf_limited
a66aa82 cpufreq: cppc: Update MIN_PERF/MAX_PERF in target callbacks
8efe398 cpufreq: CPPC: Update cached perf_ctrls on sysfs write
d9301de ACPI: CPPC: Extend cppc_set_epp_perf() for FFH/SystemMemory
a1fb110 ACPI: CPPC: Warn on missing mandatory DESIRED_PERF register
79383a9 ACPI: CPPC: Add cppc_get_perf() API to read performance controls

All of these dropped some of the commit message (Link and final SOB) during pick/backport.

@jamieNguyenNVIDIA
Copy link
Copy Markdown
Collaborator Author

@jamieNguyenNVIDIA I know this is still in draft mode, but went ahead and reviewed.

The reverts and first 3 picks look fine and I verified the SAUCE patch matches LKML.

3c977b0 ACPI: CPPC: Check cpc_read() return values consistently beb6bd9 cpufreq: CPPC: Add sysfs documentation for perf_limited 4fd0d97 ACPI: CPPC: add APIs and sysfs interface for perf_limited a66aa82 cpufreq: cppc: Update MIN_PERF/MAX_PERF in target callbacks 8efe398 cpufreq: CPPC: Update cached perf_ctrls on sysfs write d9301de ACPI: CPPC: Extend cppc_set_epp_perf() for FFH/SystemMemory a1fb110 ACPI: CPPC: Warn on missing mandatory DESIRED_PERF register 79383a9 ACPI: CPPC: Add cppc_get_perf() API to read performance controls

All of these dropped some of the commit message (Link and final SOB) during pick/backport.

Thanks. I believe these are all fixed in the latest push.

@nvmochs
Copy link
Copy Markdown
Collaborator

nvmochs commented Apr 17, 2026

@jamieNguyenNVIDIA I know this is still in draft mode, but went ahead and reviewed.
The reverts and first 3 picks look fine and I verified the SAUCE patch matches LKML.
3c977b0 ACPI: CPPC: Check cpc_read() return values consistently beb6bd9 cpufreq: CPPC: Add sysfs documentation for perf_limited 4fd0d97 ACPI: CPPC: add APIs and sysfs interface for perf_limited a66aa82 cpufreq: cppc: Update MIN_PERF/MAX_PERF in target callbacks 8efe398 cpufreq: CPPC: Update cached perf_ctrls on sysfs write d9301de ACPI: CPPC: Extend cppc_set_epp_perf() for FFH/SystemMemory a1fb110 ACPI: CPPC: Warn on missing mandatory DESIRED_PERF register 79383a9 ACPI: CPPC: Add cppc_get_perf() API to read performance controls
All of these dropped some of the commit message (Link and final SOB) during pick/backport.

Thanks. I believe these are all fixed in the latest push.

Confirmed.

No further issues from me.

Acked-by: Matthew R. Ochs <mochs@nvidia.com>

Copy link
Copy Markdown
Collaborator

@clsotog clsotog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Acked-by: Carol L Soto <csoto@nvidia.com>

@nvidia-bfigg nvidia-bfigg force-pushed the 24.04_linux-nvidia-6.17-next branch from 8b07926 to 80bac29 Compare April 21, 2026 12:02
jamieNguyenNVIDIA and others added 19 commits April 23, 2026 21:38
…ter support"

This reverts commit b0527bd.

It is to be replaced the following upstream series:

    https://lore.kernel.org/lkml/48b52f98-119e-4693-806b-78d47f7a43bb@nvidia.com/

Signed-off-by: Jamie Nguyen <jamien@nvidia.com>
…ling auto_select"

This reverts commit f106662.

It is to be replaced the following upstream series:

    https://lore.kernel.org/lkml/48b52f98-119e-4693-806b-78d47f7a43bb@nvidia.com/

Signed-off-by: Jamie Nguyen <jamien@nvidia.com>
…perf_limited"

This reverts commit c5a62d1.

It is to be replaced the following upstream series:

    https://lore.kernel.org/lkml/48b52f98-119e-4693-806b-78d47f7a43bb@nvidia.com/

Signed-off-by: Jamie Nguyen <jamien@nvidia.com>
…erf_limited register"

This reverts commit 5a35a52.

It is to be replaced the following upstream series:

    https://lore.kernel.org/lkml/48b52f98-119e-4693-806b-78d47f7a43bb@nvidia.com/

Signed-off-by: Jamie Nguyen <jamien@nvidia.com>
…in/max_perf"

This reverts commit e0f2e26.

It is to be replaced the following upstream series:

    https://lore.kernel.org/lkml/48b52f98-119e-4693-806b-78d47f7a43bb@nvidia.com/

Signed-off-by: Jamie Nguyen <jamien@nvidia.com>
…d epp"

This reverts commit a3b460e.

It is to be replaced the following upstream series:

    https://lore.kernel.org/lkml/48b52f98-119e-4693-806b-78d47f7a43bb@nvidia.com/

Signed-off-by: Jamie Nguyen <jamien@nvidia.com>
…rformance controls"

This reverts commit 10ff86b.

It is to be replaced the following upstream series:

    https://lore.kernel.org/lkml/48b52f98-119e-4693-806b-78d47f7a43bb@nvidia.com/

Signed-off-by: Jamie Nguyen <jamien@nvidia.com>
…how/store"

This reverts commit 6a55754.

It is to be replaced the following upstream series:

    https://lore.kernel.org/lkml/48b52f98-119e-4693-806b-78d47f7a43bb@nvidia.com/

Signed-off-by: Jamie Nguyen <jamien@nvidia.com>
Add generic helper functions for u64 sysfs attributes that follow the
common pattern of calling CPPC get/set APIs:
 - cppc_cpufreq_sysfs_show_u64(): reads value and handles -EOPNOTSUPP
 - cppc_cpufreq_sysfs_store_u64(): parses input and calls set function

Add CPPC_CPUFREQ_ATTR_RW_U64() macro to generate show/store functions
using these helpers, reducing boilerplate for simple attributes.

Convert auto_act_window and energy_performance_preference_val to use
the new macro.

No functional changes.

Signed-off-by: Sumit Gupta <sumitg@nvidia.com>
Reviewed-by: Lifeng Zheng <zhenglifeng1@huawei.com>
[ rjw: Retained empty code line after a conditional ]
Link: https://patch.msgid.link/20260120145623.2959636-2-sumitg@nvidia.com
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
(cherry picked from commit 4a1cf5e)
Signed-off-by: Jamie Nguyen <jamien@nvidia.com>
 - Remove redundant energy_perf field from 'struct cppc_perf_caps' as
   the same is available in 'struct cppc_perf_ctrls' which is used.

 - Move the 'auto_sel' field from 'struct cppc_perf_caps' to
   'struct cppc_perf_ctrls' as it represents a control register.

Signed-off-by: Sumit Gupta <sumitg@nvidia.com>
Reviewed-by: Pierre Gondois <pierre.gondois@arm.com>
Reviewed-by: Lifeng Zheng <zhenglifeng1@huawei.com>
Link: https://patch.msgid.link/20260120145623.2959636-3-sumitg@nvidia.com
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
(cherry picked from commit 7cb6f10)
Signed-off-by: Jamie Nguyen <jamien@nvidia.com>
Update EPP (Energy Performance Preference) constants for more clarity:

 - Add CPPC_EPP_PERFORMANCE_PREF (0x00) for performance preference.

 - Rename CPPC_ENERGY_PERF_MAX to CPPC_EPP_ENERGY_EFFICIENCY_PREF (0xFF)
   for energy efficiency.

Signed-off-by: Sumit Gupta <sumitg@nvidia.com>
Reviewed-by: Lifeng Zheng <zhenglifeng1@huawei.com>
[ rjw: Changelog edits ]
Link: https://patch.msgid.link/20260120145623.2959636-4-sumitg@nvidia.com
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
(cherry picked from commit 83e2908)
Signed-off-by: Jamie Nguyen <jamien@nvidia.com>
Add cppc_get_perf() function to read values of performance control
registers including desired_perf, min_perf, max_perf, energy_perf,
and auto_sel.

This provides a read interface to complement the existing
cppc_set_perf() write interface for performance control registers.

Note that auto_sel is read by cppc_get_perf() but not written by
cppc_set_perf() to avoid unintended mode changes during performance
updates. It can be updated with existing dedicated cppc_set_auto_sel()
API.

Use cppc_get_perf() in cppc_cpufreq_get_cpu_data() to initialize
perf_ctrls with current hardware register values during cpufreq
policy initialization.

Signed-off-by: Sumit Gupta <sumitg@nvidia.com>
Reviewed-by: Pierre Gondois <pierre.gondois@arm.com>
Reviewed-by: Lifeng Zheng <zhenglifeng1@huawei.com>
Link: https://patch.msgid.link/20260206142658.72583-2-sumitg@nvidia.com
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
(cherry picked from commit 658fa7b)
Signed-off-by: Jamie Nguyen <jamien@nvidia.com>
Add a warning during CPPC processor probe if the Desired Performance
register is not supported when it should be.

As per 8.4.6.1.2.3 section of ACPI 6.6 specification,
"The Desired Performance Register is optional only when OSPM indicates
support for CPPC2 in the platform-wide _OSC capabilities and the
Autonomous Selection Enable field is encoded as an Integer with a
value of 1."

In other words:
- In CPPC v1, DESIRED_PERF is mandatory
- In CPPC v2, it becomes optional only when AUTO_SEL_ENABLE is supported

This helps detect firmware configuration issues early during boot.

Link: https://lore.kernel.org/lkml/9fa21599-004a-4af8-acc2-190fd0404e35@nvidia.com/
Suggested-by: Pierre Gondois <pierre.gondois@arm.com>
Signed-off-by: Sumit Gupta <sumitg@nvidia.com>
Reviewed-by: Pierre Gondois <pierre.gondois@arm.com>
Reviewed-by: Lifeng Zheng <zhenglifeng1@huawei.com>
Link: https://patch.msgid.link/20260206142658.72583-3-sumitg@nvidia.com
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
(cherry picked from commit b3e45fb)
Signed-off-by: Jamie Nguyen <jamien@nvidia.com>
Extend cppc_set_epp_perf() to write both auto_sel and energy_perf
registers when they are in FFH or SystemMemory address space.

This keeps the behavior consistent with PCC case where both registers
are already updated together, but was missing for FFH/SystemMemory.

Signed-off-by: Sumit Gupta <sumitg@nvidia.com>
Reviewed-by: Pierre Gondois <pierre.gondois@arm.com>
Reviewed-by: Lifeng Zheng <zhenglifeng1@huawei.com>
Link: https://patch.msgid.link/20260206142658.72583-4-sumitg@nvidia.com
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
(cherry picked from commit 38428a6)
Signed-off-by: Jamie Nguyen <jamien@nvidia.com>
Update the cached perf_ctrls values when writing via sysfs to keep
them in sync with hardware registers:
- store_auto_select(): update perf_ctrls.auto_sel
- store_energy_performance_preference_val(): update perf_ctrls.energy_perf

This ensures consistent cached values after sysfs writes, which
complements the cppc_get_perf() initialization during policy setup.

Signed-off-by: Sumit Gupta <sumitg@nvidia.com>
Reviewed-by: Pierre Gondois <pierre.gondois@arm.com>
Reviewed-by: Lifeng Zheng <zhenglifeng1@huawei.com>
Link: https://patch.msgid.link/20260206142658.72583-5-sumitg@nvidia.com
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
(cherry picked from commit 24ad4c6)
Signed-off-by: Jamie Nguyen <jamien@nvidia.com>
Update MIN_PERF and MAX_PERF registers from policy->min and policy->max
in the .target() and .fast_switch() callbacks. This allows controlling
performance bounds via standard scaling_min_freq and scaling_max_freq
sysfs interfaces.

Similar to intel_cpufreq which updates HWP min/max limits in .target(),
cppc_cpufreq now programs MIN_PERF/MAX_PERF along with DESIRED_PERF.
Since MIN_PERF/MAX_PERF can be updated even when auto_sel is disabled,
they are updated unconditionally.

Also program MIN_PERF/MAX_PERF in store_auto_select() when enabling
autonomous selection so the platform uses correct bounds immediately.

Suggested-by: Rafael J. Wysocki <rafael@kernel.org>
Signed-off-by: Sumit Gupta <sumitg@nvidia.com>
Link: https://patch.msgid.link/20260206142658.72583-6-sumitg@nvidia.com
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
(cherry picked from commit ea3db45)
Signed-off-by: Jamie Nguyen <jamien@nvidia.com>
Add sysfs interface to read/write the Performance Limited register.

The Performance Limited register indicates to the OS that an
unpredictable event (like thermal throttling) has limited processor
performance. It contains two sticky bits set by the platform:
  - Bit 0 (Desired_Excursion): Set when delivered performance is
    constrained below desired performance. Not used when Autonomous
    Selection is enabled.
  - Bit 1 (Minimum_Excursion): Set when delivered performance is
    constrained below minimum performance.

These bits remain set until OSPM explicitly clears them. The write
operation accepts a bitmask of bits to clear:
  - Write 0x1 to clear bit 0
  - Write 0x2 to clear bit 1
  - Write 0x3 to clear both bits

This enables users to detect if platform throttling impacted a workload.
Users clear the register before execution, run the workload, then check
afterward - if set, hardware throttling occurred during that time window.

The interface is exposed as:
  /sys/devices/system/cpu/cpuX/cpufreq/perf_limited

Signed-off-by: Sumit Gupta <sumitg@nvidia.com>
Reviewed-by: Pierre Gondois <pierre.gondois@arm.com>
Reviewed-by: Lifeng Zheng <zhenglifeng1@huawei.com>
Link: https://patch.msgid.link/20260206142658.72583-7-sumitg@nvidia.com
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
(backported from commit 13c45a2)
[jamien: resolved context conflict in cppc_acpi.c]
Signed-off-by: Jamie Nguyen <jamien@nvidia.com>
Add ABI documentation for the Performance Limited Register sysfs
interface in the cppc_cpufreq driver.

Signed-off-by: Sumit Gupta <sumitg@nvidia.com>
Reviewed-by: Randy Dunlap <rdunlap@infradead.org>
Reviewed-by: Pierre Gondois <pierre.gondois@arm.com>
Reviewed-by: Lifeng Zheng <zhenglifeng1@huawei.com>
Link: https://patch.msgid.link/20260206142658.72583-8-sumitg@nvidia.com
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
(cherry picked from commit 856250b)
Signed-off-by: Jamie Nguyen <jamien@nvidia.com>
Callers of cpc_read() ignore its return value, which can lead
to using uninitialized or stale values when the read fails.

Fix this by consistently checking cpc_read() return values in
cppc_get_perf_caps(), cppc_get_perf_ctrs(), and cppc_get_perf().

Link: https://lore.kernel.org/lkml/48bdf87e-39f1-402f-a7dc-1a0e1e7a819d@nvidia.com/
Suggested-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Sumit Gupta <sumitg@nvidia.com>
Link: https://patch.msgid.link/20260318095005.2437960-1-sumitg@nvidia.com
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
(backported from commit 0cc2497)
[jamien: adapted for tree without reference_perf handling in
cppc_get_perf_caps(), and with additional ref_perf read in
cppc_get_perf_ctrs()]
Signed-off-by: Jamie Nguyen <jamien@nvidia.com>
pierregondois and others added 3 commits April 27, 2026 10:24
policy->max_freq_req QoS constraint represents the maximal allowed
frequency than can be requested. It is set by:
 - writing to policyX/scaling_max sysfs file
 - toggling the cpufreq/boost sysfs file

Upon calling freq_qos_update_request(), a successful update
of the max_freq_req value triggers cpufreq_notifier_max(),
followed by cpufreq_set_policy() which update the requested
frequency for the policy.
If the new max_freq_req value is not different from the
original value, no frequency update is triggered.

In a specific sequence of toggling:
 - cpufreq/boost sysfs file
 - CPU hot-plugging
a CPU could end up with boost enabled but running at the
maximal non-boost frequency, cpufreq_notifier_max() not being
triggered. The following fixed that:
commit 1608f02 ("cpufreq: Fix re-boost issue after hotplugging
a CPU")

The following:
commit dd016f3 ("cpufreq: Introduce a more generic way to
set default per-policy boost flag")
also fixed the issue by correctly setting the max_freq_req
constraint of a policy that is re-activated. This makes the
first fix unnecessary.

As the original issue is fixed by another method,
this patch reverts:
commit 1608f02 ("cpufreq: Fix re-boost issue after hotplugging
a CPU")

Reviewed-by: Lifeng Zheng <zhenglifeng1@huawei.com>
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Link: https://patch.msgid.link/20260326204404.1401849-2-pierre.gondois@arm.com
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
(cherry picked from commit 04aa9d0)
Signed-off-by: Jamie Nguyen <jamien@nvidia.com>
cpufreq_set_policy() will ultimately override the policy min/max
values written in the .init() callback through:
cpufreq_policy_online()
\-cpufreq_init_policy()
  \-cpufreq_set_policy()
    \-/* Set policy->min/max */
Thus the policy min/max values provided are only temporary.

There is an exception if CPUFREQ_NEED_INITIAL_FREQ_CHECK is set and:
cpufreq_policy_online()
\-cpufreq_init_policy()
  \-__cpufreq_driver_target()
    \-cpufreq_driver->target()
is called. To avoid any regression, set policy->min/max in cpufreq.c
if the values were not initialized.

In this patch:
- Setting policy->min or max value in driver .init() cb is
  interpreted as setting a QoS constraint.
- Remove policy->min/max initialization in drivers if the values
  are similar to policy->cpuinfo.min_freq/max_freq.
  The only drivers where these values are different are:
  - gx-suspmod.c
  - cppc-cpufreq.c
  - longrun.c
- For the cppc-cpufreq driver, the lowest non-linear freq. is
  used as a min QoS constraint as suggested at:
  https://lore.kernel.org/lkml/20260213100633.15413-1-zhangpengjie2@huawei.com/

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
Add a kernel boot parameter 'cppc_cpufreq.auto_sel_mode' to enable
CPPC autonomous performance selection on all CPUs at system startup.
When autonomous mode is enabled, the hardware automatically adjusts
CPU performance based on workload demands using Energy Performance
Preference (EPP) hints.

When auto_sel_mode=1:
- Configure all CPUs for autonomous operation on first init
- Set EPP to performance preference (0x0)
- Use HW min/max_perf when available; otherwise initialize from caps
- Clamp desired_perf to bounds before enabling autonomous mode
- Hardware controls frequency instead of the OS governor

The boot parameter is applied only during first policy initialization.
Skip applying it on CPU hotplug to preserve runtime sysfs configuration.

This patch depends on patch [2] ("cpufreq: Set policy->min and max
as real QoS constraints") so that the policy->min/max set in
cppc_cpufreq_cpu_init() are not overridden by cpufreq_set_policy()
during init.

Reviewed-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Sumit Gupta <sumitg@nvidia.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 30, 2026

PR Validation Report

Patchscan ✅ No Missing Fixes

All cherry-picked commits checked — no missing upstream fixes found.

PR Lint ❌ Errors found

Details
Checking 22 commits...

Cherry-pick digest:
┌──────────────┬───────────────────────────────────────────────┬────────────┬─────────┬───────────────────────────┐
│ Local        │ Referenced upstream / Patch subject           │ Patch-ID   │ Subject │ SoB chain                 │
├──────────────┼───────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ fdad114cfcc3 │ [SAUCE] cpufreq: cppc: add autonomous mode bo │ N/A        │ N/A     │ sumitg                    │
├──────────────┼───────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ c0eebd8437d7 │ [SAUCE] cpufreq: set policy->min and max as r │ N/A        │ N/A     │ gondois                   │
├──────────────┼───────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 1ef6d2020786 │ 04aa9d0726cc                                  │ match      │ match   │ preserved + jamien added  │
├──────────────┼───────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 07d53b6887ff │ [SAUCE] acpi: cppc: check cpc_read() return v │ N/A        │ N/A     │ sumitg, wysocki, jamien   │
├──────────────┼───────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 85564c60f8e5 │ 856250ba2e81                                  │ match      │ match   │ preserved + jamien added  │
├──────────────┼───────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ ed93528a8376 │ [SAUCE] acpi: cppc: add apis and sysfs interf │ N/A        │ N/A     │ sumitg, wysocki, jamien   │
├──────────────┼───────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 9bde3ae0c008 │ ea3db45ae476                                  │ match      │ match   │ preserved + jamien added  │
├──────────────┼───────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ fec983463b5f │ 24ad4c6c136b                                  │ match      │ match   │ preserved + jamien added  │
├──────────────┼───────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 9232bd46bcd7 │ 38428a680026                                  │ match      │ match   │ preserved + jamien added  │
├──────────────┼───────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ fcfda5aae15d │ b3e45fb2db9d                                  │ match      │ match   │ preserved + jamien added  │
├──────────────┼───────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 45184b07eccf │ 658fa7b1c47a                                  │ match      │ match   │ preserved + jamien added  │
├──────────────┼───────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ ac39d38fb99f │ 83e2908c1d42                                  │ match      │ match   │ preserved + jamien added  │
├──────────────┼───────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 5cc9f264391f │ 7cb6f10ce3ed                                  │ match      │ match   │ preserved + jamien added  │
├──────────────┼───────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 71de1ba12059 │ 4a1cf5ed51b1                                  │ match      │ match   │ preserved + jamien added  │
├──────────────┼───────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ de3aeb438061 │ [Revert] cpufreq: cppc: add generic helpers f │ N/A        │ N/A     │ jamien                    │
├──────────────┼───────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 737ef0dcd6a5 │ [Revert] acpi: cppc: add cppc_get_perf() api  │ N/A        │ N/A     │ jamien                    │
├──────────────┼───────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 5981214d972e │ [Revert] acpi: cppc: extend apis to support a │ N/A        │ N/A     │ jamien                    │
├──────────────┼───────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 0aec220f3a98 │ [Revert] acpi: cppc: add apis and sysfs inter │ N/A        │ N/A     │ jamien                    │
├──────────────┼───────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ f6faf71ea5e6 │ [Revert] acpi: cppc: add apis and sysfs inter │ N/A        │ N/A     │ jamien                    │
├──────────────┼───────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ c92f945a3a99 │ [Revert] cpufreq: cppc: add sysfs for min/max │ N/A        │ N/A     │ jamien                    │
├──────────────┼───────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ 98f0f3ccff15 │ [Revert] cpufreq: cppc: update policy min/max │ N/A        │ N/A     │ jamien                    │
├──────────────┼───────────────────────────────────────────────┼────────────┼─────────┼───────────────────────────┤
│ a45b8e78b901 │ [Revert] cpufreq: cppc: add autonomous mode b │ N/A        │ N/A     │ jamien                    │
└──────────────┴───────────────────────────────────────────────┴────────────┴─────────┴───────────────────────────┘

Lint results:
E: fdad114cfcc3 ("cpufreq: CPPC: add autonomous mode boot parameter "): not SAUCE/Revert but has no upstream reference trailer (cherry picked from commit ... or backported from ...)
E: c0eebd8437d7 ("cpufreq: Set policy->min and max as real QoS const"): not SAUCE/Revert but has no upstream reference trailer (cherry picked from commit ... or backported from ...)
E: 07d53b6887ff ("ACPI: CPPC: Check cpc_read() return values consist"): not SAUCE/Revert but has no upstream reference trailer (cherry picked from commit ... or backported from ...)
E: ed93528a8376 ("ACPI: CPPC: add APIs and sysfs interface for perf_"): not SAUCE/Revert but has no upstream reference trailer (cherry picked from commit ... or backported from ...)

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