Repository navigation
soc: apple: clpc: gate low-power PHPC step-downs on PHPC-interval busy and floor - #3671
Merged
RyanTheTide merged 2 commits intoDec 1, 2026
Merged
Conversation
In the low-power platform profile, apple_clpc_profile_limit() reads SMC PHPC (package power, which includes the GPU and display as well as the CPUs) and steps one CPU cluster down on every new reading above low_power_mw. When a GPU or display workload holds PHPC above low_power_mw while the CPUs are idle or lightly loaded, stepping down CPU ceilings saves almost no power, so PHPC stays above target and every CPU cluster walks down to its minimum OPP (300 MHz). Neither SMC nor apple-pmc exposes a per-cluster CPU-only power meter on these platforms (CPU and GPU share PHPC), so gate downward steps on the cluster's scheduler non-idle utilisation (cl->busy >= APPLE_CLPC_BUSY_PCT, already sampled by apple_clpc_sample_cluster()): - Extract apple_clpc_sample_busy() and run it for standalone (!clpc->has_pmc) low-power package-power instances as well, so cl->busy is populated uniformly without SoC gating. - Extract apple_clpc_pick_profile_step() and skip clusters with cl->busy < APPLE_CLPC_BUSY_PCT when stepping down (step < 0), while still stepping every capped cluster back up when PHPC drops below 90% of low_power_mw (step > 0). - Add KUnit test apple_clpc_profile_step_busy_test covering idle clusters under over-budget PHPC, single busy cluster selection, multi-cluster busy ordering, idle recovery on step-up, and step == 0. Fixes: aurora-silicon#3450 Signed-off-by: Ryan Murray <[email protected]>
…y and floor On PMC-backed SoCs (such as T6050), cl->busy reflects the busiest CPU in the cluster over the 4 ms PMC sampling window. Sampling that on each ~1 s PHPC reading leaks step-downs during GPU/compositor workloads because short redraw bursts still push one CPU over APPLE_CLPC_BUSY_PCT in a 4 ms slice. In addition, the !clpc->has_pmc path read clpc->wall and clpc->idle even though probe only allocates those arrays when clpc->has_pmc is true. Track a separate per-cluster busy share over the PHPC update interval and prevent the low-power package power loop from stepping onto the minimum OPP: - Generalize apple_clpc_sample_busy() into apple_clpc_busy_since() taking explicit wall/idle baseline arrays. - Allocate per-CPU power_wall/power_idle baselines in probe whenever low_power_khz && low_power_mw (independent of has_pmc), reset them when leaving low-power mode and on resume, and update cl->power_busy on each fresh PHPC reading. - Gate apple_clpc_pick_profile_step() downward steps on cl->power_busy instead of cl->busy, and skip stepping a cluster onto policy->cpuinfo.min_freq (its lowest table row). - Update apple_clpc_profile_step_busy_test to cover cl->power_busy vs cl->busy independence and the lowest-row floor. Signed-off-by: betizzel <[email protected]>
There was a problem hiding this comment.
Verdict: MERGE at 3ec9d7e08604
Blockers: none (ready to merge into fix/clpc-low-power-busy-cluster for #3488; full hosted CI against main and the second-family regression row will run on #3488 before merging to main).
Checked:
drivers/soc/apple/clpc.c(apple_clpc_busy_since(),apple_clpc_probe(),apple_clpc_profile_limit(),apple_clpc_resume()): verifiedapple_clpc_sample_busy()generalizes cleanly toapple_clpc_busy_since(cl, base_wall, base_idle)preserving offline-CPU baseline resets and delta guards;power_idle/power_wallare allocated viadevm_kcalloc(..., nr_cpu_ids, ...)wheneverlow_power_khz && low_power_mwindependent ofhas_pmc(eliminating the!has_pmcNULL dereference ofclpc->wall/clpc->idle);cl->power_busyis updated only on fresh PHPC readings (mw >= 0 && mw != clpc->power_mw), which is the exact condition under whichstepcan be non-zero, and baselines reset on leaving low-power mode and on resume so the first un-baselined reading returns0without spurious step-downs.apple_clpc_pick_profile_step(): verified downward steps (step < 0) require bothcl->power_busy >= APPLE_CLPC_BUSY_PCTandkhz > policy[i]->cpuinfo.min_freq, while upward recovery (step > 0) remains ungated so capped clusters restore cleanly when PHPC drops below 90%.- KUnit (
apple_clpc_test_policy(),apple_clpc_profile_step_busy_test()): verifiedpolicy->cpuinfo.min_freqsetup, independence ofpower_busyfromcl->busy = 100, and lowest-table-row floor enforcement (1200000kHz does not step down to600000kHz). - Local verification (
3ec9d7e08604):checkpatch.pl --strict, CLPC host tests, LLVM/GCCW=1builds, and KUnitapple-clpc*19/19 under KASAN+UBSAN PASS; equivalentwindow=1, floor=1J714s hardware matrix verified in#3488. - Policy & attribution: human
Signed-off-bypresent, no module parameters, no board/SoC gates, no Apple material or AI attribution.
Evidence
- Head:
3ec9d7e086041dbd5c179979fd6c8cc7c296fc26(base: fix/clpc-low-power-busy-cluster,MERGEABLE,+84/-31, 1 file, 1 commit). - Note: standard
main-targeted CI workflows are skipped on feature-branch basefix/clpc-low-power-busy-cluster; full hosted CI and the second-family regression row remain tracked on#3488.
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
RyanTheTide
changed the base branch from
fix/clpc-low-power-busy-cluster
to
main
December 1, 2026 10:04
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Follow-up for #3488 (fixing #3450 on PMC-backed SoCs such as T6050):
apple_clpc_sample_busy()intoapple_clpc_busy_since()and trackcl->power_busyover each fresh PHPC interval instead of readingcl->busyfrom the 4 ms PMC sampler.power_wall/power_idlebaselines in probe wheneverlow_power_khz && low_power_mwso!has_pmcinstances no longer touchclpc->wall/clpc->idle; reset them on leaving low-power and on resume.apple_clpc_pick_profile_step()from stepping a cluster down ontopolicy->cpuinfo.min_freq(its lowest table row).apple_clpc_profile_step_busy_testto coverpower_busyvsbusyindependence and the lowest-row floor.No module parameters.
Tested
Tested: J714s hardware matrix on the equivalent
window=1, floor=1variant is in #3488; on this commit (3ec9d7e08604):scripts/checkpatch.pl --strict: 0 errors, 0 warnings, 0 checks.python3 tools/asahi/clpc-gpu-demand-tests.py: PASS (all positive and negative controls).python3 tools/asahi/clpc-high-power-cleanup-tests.py: PASS.make LLVM=1 ARCH=arm64 W=1 drivers/soc/apple/clpc.o(drivers/soc/apple/clpc.kunitconfig): clean, 0 warnings.make ARCH=arm64 W=1 drivers/soc/apple/clpc.o(gcc,asahi.config): clean, 0 warnings../tools/testing/kunit/kunit.py run --arch=arm64 --make_options LLVM=1 --kunitconfig=drivers/soc/apple/clpc.kunitconfig 'apple-clpc*': 19/19 passed (apple-clpc-gpu: 14/14,apple-clpc-policy: 5/5 includingapple_clpc_profile_step_busy_test, under KASAN + UBSAN in QEMU).Risk
Risk: two-way door · Scoped to
drivers/soc/apple/clpc.clow-power PHPC step-down gating and its KUnit test. Single-commit revert; no DT/ABI changes or SoC gates.Not yet