Skip to content

soc: apple: clpc: gate low-power PHPC step-downs on PHPC-interval busy and floor - #3671

Merged
RyanTheTide merged 2 commits into
aurora-silicon:mainfrom
betizzel:fix/clpc-low-power-window-floor
Dec 1, 2026
Merged

RyanTheTide merged 2 commits into
aurora-silicon:mainfrom
betizzel:fix/clpc-low-power-window-floor

Conversation

@betizzel

Copy link
Copy Markdown
Contributor

What

Follow-up for #3488 (fixing #3450 on PMC-backed SoCs such as T6050):

  • Generalize apple_clpc_sample_busy() into apple_clpc_busy_since() and track cl->power_busy over each fresh PHPC interval instead of reading cl->busy from the 4 ms PMC sampler.
  • Allocate per-CPU power_wall/power_idle baselines in probe whenever low_power_khz && low_power_mw so !has_pmc instances no longer touch clpc->wall/clpc->idle; reset them on leaving low-power and on resume.
  • Prevent apple_clpc_pick_profile_step() from stepping a cluster down onto policy->cpuinfo.min_freq (its lowest table row).
  • Update apple_clpc_profile_step_busy_test to cover power_busy vs busy independence and the lowest-row floor.

No module parameters.

Tested

Tested: J714s hardware matrix on the equivalent window=1, floor=1 variant 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 including apple_clpc_profile_step_busy_test, under KASAN + UBSAN in QEMU).

Risk

Risk: two-way door · Scoped to drivers/soc/apple/clpc.c low-power PHPC step-down gating and its KUnit test. Single-commit revert; no DT/ABI changes or SoC gates.

Not yet

RyanTheTide and others added 2 commits November 28, 2026 16:17
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]>

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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()): verified apple_clpc_sample_busy() generalizes cleanly to apple_clpc_busy_since(cl, base_wall, base_idle) preserving offline-CPU baseline resets and delta guards; power_idle/power_wall are allocated via devm_kcalloc(..., nr_cpu_ids, ...) whenever low_power_khz && low_power_mw independent of has_pmc (eliminating the !has_pmc NULL dereference of clpc->wall/clpc->idle); cl->power_busy is updated only on fresh PHPC readings (mw >= 0 && mw != clpc->power_mw), which is the exact condition under which step can be non-zero, and baselines reset on leaving low-power mode and on resume so the first un-baselined reading returns 0 without spurious step-downs.
  • apple_clpc_pick_profile_step(): verified downward steps (step < 0) require both cl->power_busy >= APPLE_CLPC_BUSY_PCT and khz > 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()): verified policy->cpuinfo.min_freq setup, independence of power_busy from cl->busy = 100, and lowest-table-row floor enforcement (1200000 kHz does not step down to 600000 kHz).
  • Local verification (3ec9d7e08604): checkpatch.pl --strict, CLPC host tests, LLVM/GCC W=1 builds, and KUnit apple-clpc* 19/19 under KASAN+UBSAN PASS; equivalent window=1, floor=1 J714s hardware matrix verified in #3488.
  • Policy & attribution: human Signed-off-by present, 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 base fix/clpc-low-power-busy-cluster; full hosted CI and the second-family regression row remain tracked on #3488.

@github-actions github-actions Bot added area:platform Area from CODEOWNERS (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 30, 2026
@github-actions

Copy link
Copy Markdown

Merge readiness at 3ec9d7e0: not ready yet

Check Detail
CI at head ok 4 checks passed
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head ok in the PR body at 3ec9d7e0
Conflicts ok none
PR text ok Risk: two-way · Scoped to drivers/soc/apple/clpc.c low-power PHPC step-down gating and its KUnit test. Single-commit revert; no DT/ABI changes or SoC gates.

Areas: area:platform

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Merging at 3ec9d7e08604 (B2 merge train, 12-01 merge bar). Approval at this head: aurora-silicon-review[bot]. Row: in the PR body at 3ec9d7e. CI: linux train L6 = main + #3671 #3637: Apple driver compile pass, Apple DTBs W=1 pass, planned KUnit clpc pass. Revert: git revert -m 1 <merge commit>.

@RyanTheTide
RyanTheTide merged commit 41ab8f5 into aurora-silicon:main Dec 1, 2026
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:platform Area from CODEOWNERS (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants