Skip to content

soc: apple: clpc: add DT-driven all-core window, slow-cluster cap, and J604 sustained power limit - #3988

Open
IronsideXXVI wants to merge 3 commits into
aurora-silicon:mainfrom
IronsideXXVI:j604/apple-clpc-j604-limits
Open

IronsideXXVI wants to merge 3 commits into
aurora-silicon:mainfrom
IronsideXXVI:j604/apple-clpc-j604-limits

Conversation

@IronsideXXVI

Copy link
Copy Markdown
Contributor

What: Add optional, DT-driven all-core frequency ceilings, a slow-cluster busy cap, and a sustained all-core SMC package power limit to apple-clpc, and enable J604's AC limits in t8132-j604.dts (zero runtime module parameters, zero machine-name matching):

  1. dt-bindings: power: apple,pmc: document optional board-level properties apple,all-core-frequency-max-mhz, apple,slow-cluster-busy-max-mhz, and apple,sustained-power-mw on the performance-controller node, and note sustained power regulation in apple,smc.
  2. soc: apple: clpc: evaluate all-core cluster occupancy over the full 100 ms APPLE_CLPC_POWER_MS window (80% per-CPU busy threshold, 200 ms release hold) outside the low-power profile; apply matching apple,all-core-frequency-max-mhz ceilings; cap the slowest cluster at apple,slow-cluster-busy-max-mhz while a faster cluster is busy (avoiding the J604 E-cluster 2892 MHz 2.1x power cliff while leaving E-only workloads and Low Power mode untouched); and regulate faster clusters against apple,sustained-power-mw via SMC (apple,power-key-id, default PHPC) only while all-core load holds a faster cluster (zero SMC reads at idle or single-core load, immediate release when all-core load ends). Add 3 KUnit cases to apple-clpc-policy.
  3. arm64: dts: apple: t8132-j604: wire apple,smc = <&smc> and J604's macOS-matched limits (3936/2808 MHz all-core, 2808 MHz slow-cluster busy cap, 15500 mW sustained PHPC).

Tested:

  • Offline at 899e6ebcde40 (atop aurora-silicon/linux main 33dbc9a6c6d):
    • ARM64 QEMU KUnit (drivers/soc/apple/clpc.kunitconfig, Clang 18.1.8 LLVM=1, KASAN+UBSAN): 25/25 passed (apple-clpc-gpu 16/16 + apple-clpc-policy 9/9, including new apple_clpc_all_core_window_test, apple_clpc_sustained_power_test, and apple_clpc_all_core_and_e_cap_test).
    • ARM64 Clang 18.1.8 LLVM=1 W=1 build of drivers/soc/apple/clpc.o: 0 warnings, 0 errors (tested with both CONFIG_KUNIT=y and !CONFIG_KUNIT + CONFIG_MFD_MACSMC=y).
    • make ARCH=arm64 LLVM=1 dt_binding_check DT_SCHEMA_FILES=power/apple,pmc.yaml: 0 errors, 0 warnings.
    • make ARCH=arm64 LLVM=1 CHECK_DTBS=y apple/t8132-j604.dtb: 0 new warnings on performance-controller@3.
    • tools/asahi/clpc-high-power-cleanup-tests.py: PASSED.
    • scripts/checkpatch.pl --strict --git origin/main..HEAD: 0 errors, 0 warnings, 0 checks across all 3 commits.
  • Prior J604 (M4 MacBook Pro 14, T8132) hardware validation of the identical control loop & constants (101cb8285 carried on J604 shipping kernels 1.1683–1.1687, n=10 like-for-like vs native macOS 26B123):
    • Energy mode balanced (7zz b 3 mtall): 3317.85 MIPS/W vs native macOS 3240.8 MIPS/W (102.4%, 0 faults; low-power leg 4627.35 MIPS/W).
    • CPU all-core sustained (pwrspin chain10 62 s): 3678.1 MHz/W vs native macOS 3715.0 MHz/W (99.0%, 0 faults).
    • Single-thread control (7zz b 3 mt1): 11225.5 MIPS vs native macOS 11264.5 MIPS (99.7%, p0_4464_pct=100.0% on 10/10 runs, 0 faults).

Risk: two-way · J604 (T8132) only — all new behavior is strictly opt-in via the new optional DT properties on &clpc in t8132-j604.dts. Other T8132 and non-T8132 boards have has_all_core == false and take the exact existing code path. A plain revert restores uncapped all-core behavior on J604.

Not yet: exact-head main (899e6ebcde40) bare-metal J604 hardware boot + n=10 re-read row (will be posted as a follow-up comment after booting this exact commit on J604 with the updated Stage 2 DTB).

Commit list & offline verification log summary

Commits atop 33dbc9a6c6d:

  • dc8572f1c5ec dt-bindings: power: apple,pmc: document CLPC all-core and sustained power limits
  • 32458d8676c0 soc: apple: clpc: add all-core window, slow-cluster busy cap, and sustained power limit
  • 899e6ebcde40 arm64: dts: apple: t8132-j604: configure CLPC all-core and sustained power limits

KUnit summary (qemu-system-aarch64, Clang 18.1.8, KASAN+UBSAN):

=============== apple-clpc-gpu (16 subtests) ===============
================= [PASSED] apple-clpc-gpu ==================
============== apple-clpc-policy (9 subtests) ==============
[PASSED] apple_clpc_step_khz_test
[PASSED] apple_clpc_steps_first_test
[PASSED] apple_clpc_vote_test
[PASSED] apple_clpc_floor_test
[PASSED] apple_clpc_profile_step_busy_test
[PASSED] apple_clpc_gpu_busy_clear_test
[PASSED] apple_clpc_all_core_window_test
[PASSED] apple_clpc_sustained_power_test
[PASSED] apple_clpc_all_core_and_e_cap_test
================ [PASSED] apple-clpc-policy ================
Testing complete. Ran 25 tests: passed: 25

…ower limits

Document three optional board-level CLPC properties on the PMC
performance-controller child node for non-low-power sustained multi-core
regulation:

- apple,all-core-frequency-max-mhz: per-cluster-type frequency ceilings
  when all online CPUs of a cluster are busy across the 100 ms window.
- apple,slow-cluster-busy-max-mhz: frequency ceiling for the slowest
  cluster while a faster cluster is busy.
- apple,sustained-power-mw: sustained all-core SMC package power target
  in milliwatts while all-core load holds a faster cluster.

Update the apple,smc description to cover sustained package power
regulation alongside the low-power profile and High Power mode.

Signed-off-by: Dylan Ironside <dylan@dylanironside.io>
…tained power limit

On T8132 (J604), sustained heavy multi-core workloads such as 7-Zip
mtall (~915% CPU) hit two efficiency regressions against macOS on AC:

1. E-cluster 2892 MHz power cliff: brief per-core dips let the E-cluster
   jump to 2892 MHz while P-cores are active, paying a ~2.1x power jump
   over 2808 MHz for +3% clock.
2. Unbounded 3936/4464 MHz P-cluster power: macOS regulates sustained
   heavy all-core workloads on J604 around 15.5 W PHPC (~3600 MHz active
   P clock, die ~77 C), whereas uncapped Linux draws 17.3-25+ W PHPC
   (die up to 95-100 C), losing ~6% MIPS/W and inducing thermal droop on
   subsequent single-core runs.

Add three optional, DT-driven controls in apple-clpc (inactive unless
configured by board DT; zero runtime module parameters and zero machine
name matching):

- Integrated 100 ms all-core busy window (80% per-CPU busy threshold,
  200 ms release hysteresis) applying apple,all-core-frequency-max-mhz
  per matching cluster outside the low-power profile.
- Slow-cluster busy cap (apple,slow-cluster-busy-max-mhz) while a faster
  cluster is busy outside the low-power profile, leaving E-only workloads
  and Low Power mode untouched.
- Sustained all-core SMC package power ceiling (apple,sustained-power-mw,
  using apple,smc and apple,power-key-id / PHPC) that polls SMC only
  while all-core load holds a faster cluster (zero SMC reads at idle or
  single-core load) and releases immediately once all-core load ends.

Add KUnit tests in apple-clpc-policy covering the all-core window hold,
sustained power stepping and floor/release behavior, all-core table
matching, and slow-cluster busy capping.

Signed-off-by: Dylan Ironside <dylan@dylanironside.io>
…power limits

Wire apple,smc and the J604 all-core/sustained CLPC power limits matching
macOS on AC:

- apple,all-core-frequency-max-mhz = <3936 2808>
- apple,slow-cluster-busy-max-mhz = <2808>
- apple,sustained-power-mw = <15500>

Leaves single-core bursts (4464 MHz P), E-only workloads, and idle zero-SMC
behavior unchanged.

Signed-off-by: Dylan Ironside <dylan@dylanironside.io>
@IronsideXXVI
IronsideXXVI requested review from a team as code owners December 2, 2026 20:31
@github-actions github-actions Bot added area:bringup Area from CODEOWNERS (bot) area:platform Area from CODEOWNERS (bot) blast:all Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Dec 2, 2026
@github-actions

github-actions Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Merge readiness at 899e6ebc: not ready yet

Check Detail
CI at head ok 5 checks passed
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes no requested by DjDeveloperr
Hardware row at head ok in the PR body at 899e6ebc
Conflicts ok not computed yet
PR text ok Risk: two-way · J604 (T8132) only — all new behavior is strictly opt-in via the new optional DT properties on &clpc in t8132-j604.dts. Other T8132 and non-T8132 boards have hasallcore == false and take the exact existing code path. A plain revert restores uncapped all-core behavior on J604.

Areas: area:bringup, area:platform

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

@github-actions github-actions Bot added the merge-conflict Conflicts with the base branch (bot) label Dec 2, 2026

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review at 899e6ebcde40. It's opt-in from the board DT, with no parameters and no machine names. Boards without the new properties keep the same decisions (I followed the probe and profile_limit refactor). The design needs changes before it can land.

Must change

  1. The sustained loop counts the GPU against the CPU. PHPC covers the GPU and display as well (apple_clpc_profile_step_busy_test says so). While the P cores are all busy and the GPU is working, the loop steps the P cluster down every 100 ms toward a target the CPU can't reach alone. The only floor is low_power_khz. T8132 has no table value, so unless the loader sets one, the floor is the second OPP (1260 MHz). A game, or a CPU+GPU render, would sit there. Regulate on the CPU rails (PP0b + PPbb), or take the GPU out of the reading, and set a real floor. Your rows are CPU-only, so they can't show this.
  2. Frequency matching is fragile. apple,all-core-frequency-max-mhz gives each entry to "any cluster whose table contains it". That only works on J604 because no P row equals 2808, and an entry that is in no table is ignored silently. Put the ceiling on the cluster it belongs to (the cpufreq domain or the cpu-map cluster), and warn if it isn't an OPP.
  3. "E-only workloads untouched" isn't what it does. With all six E cores busy and P idle, the all-core entry caps E at 2808, as your own KUnit case shows. Change the text or the behaviour.
  4. apple,smc is a second change on J604. Where the loader passes Low Power mode values, the node now also gets the low-power SMC loop. Split it out, or describe and test it.
  5. 80 %, 200 ms and 92 % need a basis next to them: what was measured, and why these values. The caps also apply on battery and in the performance profile, while the DT comment says "matching macOS on AC".

Conflict with main: #2856 is in now. Three hunks in clpc.c, binding and DTS merge clean. Resolution: drop your own notifier registration and the one in has_profile, call if (clpc->low_power_khz || clpc->has_all_core) apple_clpc_policy_nb_register(clpc); once, and keep both sides of the two KUnit hunks. I built that tree. I haven't pushed it, because this needs a new head anyway. #3868, #3873, #3741 and #3882 edit the same file (#3882 needs its own small merge too), so whichever lands second merges again. #4008 and #4009 merge clean with the DTS.

Checked on main 2c667a4b + this head, resolved as above: clpc.o W=1 clean with KUnit off and on, dt_binding_check for apple,pmc.yaml clean, t8132-j604.dtb CHECK_DTBS output identical to main, clpc-high-power-cleanup-tests.py passes, no checkpatch errors. KUnit not run here (arm64 only); hosted CI shows as skipped at this head.

Rows at the next head: J604 (yours): all-core on/off A/B, CPU+GPU load (P cluster clock and fps vs base), six E-core-only threads, low-power and performance profiles, battery, s2idle and deep sleep. J773g (T8132, no properties): boot, clpc status and all-core clocks same as base. J714s (T6050): platform profiles and the High Power record unchanged, since the probe path is shared.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:bringup Area from CODEOWNERS (bot) area:platform Area from CODEOWNERS (bot) blast:all Macs affected, from Merge risk (bot) changes-requested A reviewer requested changes (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