Repository navigation
soc: apple: clpc: add DT-driven all-core window, slow-cluster cap, and J604 sustained power limit - #3988
soc: apple: clpc: add DT-driven all-core window, slow-cluster cap, and J604 sustained power limit#3988IronsideXXVI wants to merge 9 commits into
Conversation
…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>
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
DjDeveloperr
left a comment
There was a problem hiding this comment.
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
- The sustained loop counts the GPU against the CPU. PHPC covers the GPU and display as well (
apple_clpc_profile_step_busy_testsays 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 islow_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. - Frequency matching is fragile.
apple,all-core-frequency-max-mhzgives 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 thecpu-mapcluster), and warn if it isn't an OPP. - "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.
apple,smcis 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.- 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.
…limits # Conflicts: # drivers/soc/apple/clpc.c
Address review feedback on CLPC all-core and sustained power bindings: - Move apple,all-core-frequency-max-mhz and apple,slow-cluster-busy-max-mhz from &clpc to the individual apple,cluster-cpufreq domain nodes alongside the new apple,sustained-frequency-min-mhz floor so each limit binds explicitly to its cluster and validates against that cluster OPP table. - Add apple,sustained-power-key-ids (required alongside apple,sustained-power-mw and apple,smc) so sustained CPU regulation sums dedicated CPU cluster rails instead of package PHPC (which includes GPU and display power). - Clarify that these optional limits apply outside the low-power platform profile (balanced and performance, on AC and battery). Signed-off-by: Dylan Ironside <dylan@dylanironside.io>
…limits Address review feedback on CLPC all-core and sustained CPU limits: - Regulate sustained all-core CPU power using the summed SMC CPU rails listed in apple,sustained-power-key-ids (separate from the low-power profile PHPC power_key) so GPU and display loads never throttle CPU. - Enforce an explicit per-cluster sustained frequency floor (apple,sustained-frequency-min-mhz, with a >= max_freq/2 fallback if unset) instead of falling back to the second OPP (1260 MHz). - Read per-cluster apple,all-core-frequency-max-mhz, apple,slow-cluster-busy-max-mhz, and apple,sustained-frequency-min-mhz from each cluster performance-domains node and warn if any value is not a valid OPP in that cluster frequency table. - Keep slow-cluster-only workloads uncapped when only apple,slow-cluster-busy-max-mhz is configured on the slow cluster. - Document the J604 measurement basis for the 80% busy threshold, 200 ms release hold, and 92% step-up hysteresis next to the constants, and expand apple-clpc-policy KUnit coverage for OPP validation, explicit and fallback floors, and uncapped E-only load. Signed-off-by: Dylan Ironside <dylan@dylanironside.io>
Update J604 CLPC limits to address review feedback: - Place the P-cluster all-core ceiling (3936 MHz) and sustained floor (3096 MHz) on &cpufreq_p, and the slow-cluster busy cap (2808 MHz) only on &cpufreq_e so 6-thread E-only work stays uncapped while P is idle. - Regulate sustained CPU power at 13.5 W summed across the CPU cluster rails (PP0b P-cluster + PPbb E-cluster, excluding GPU PP1b and display). - Clarify that these limits apply outside low-power (balanced and performance, AC and battery; J604 has no High Power mode) and that wiring apple,smc on &clpc also enables the existing low-power SMC PHPC loop when the boot loader supplies Low Power mode values. Signed-off-by: Dylan Ironside <dylan@dylanironside.io>
|
@DjDeveloperr Thanks for the thorough review and merge guidance. Forward-merged
Verified offline at
Live J604 hardware rows at |
The all-core, slow-cluster and sustained ceilings drop only when the sampler runs. 32 ms after the last CPU demand the memory floor is released and the T8132 sampler turns deferrable, so it runs again only when the CPU that owns the timer takes a tick. The all-core hold is 200 ms: once the load stops, the ceilings outlive it until that CPU wakes, and a thread that starts on another CPU meanwhile runs at the all-core ceiling, or down to the sustained floor, for that long. Keep sampling on time while a ceiling is held, as for a held vote. It drops at most two 100 ms windows later and the sampler is deferrable again. After a sleep take the first sample on time as well: the reset clears the recorded ceiling but not the frequency QoS request. Boards without the properties sample as before. The host test runs apple_clpc_sample() with a held ceiling and fails without the check. Signed-off-by: DjDeveloperr <hey@djdev.me>
The nested condition guards settings that nothing reads without a low-power ceiling or High Power mode, so boards do not need it. Keep the block as it was and only add the sustained limit's keys to its condition. This also drops a misindented store that the DT setup has already done. The ceilings' comment still said the sustained limit reads the package power; it reads the CPU rails. Signed-off-by: DjDeveloperr <hey@djdev.me>
DjDeveloperr
left a comment
There was a problem hiding this comment.
Verdict: FINISH, then merge, at 136204e3ee9b. The five points from the earlier review are fixed in code, so I'm clearing it. Only hardware rows are left.
Blockers: none in the code. The rows below.
Checked: merged with main 5d506042; no parameters, no chip or board gates in the driver; KUnit, host tests, W=1 and DT checks.
The earlier points
- The sustained loop reads PP0b + PPbb, so GPU and display power no longer count. Both keys are 4-byte
fltwatts on T8132 (apple-pmp-thermalalready checks that). Any failed read fails the whole sum and the step is skipped; an unchanged sum takes no step. The floor is 3096 MHz on J604, half of max without the property. - The limits sit on each cluster's cpufreq node. A value that isn't an OPP warns and is ignored.
- Six E threads with P idle get no ceiling.
- The Low Power loop that
apple,smcbrings is described. Testing it is a row. - 80 %, 200 ms and 92 % have their basis next to them, and the text now says which profiles and power sources apply.
I pushed two small commits
6dc15236ba6e: the sampler turns deferrable 32 ms after the CPU demand ends, but the ceiling is held for 200 ms. On T8132 it then stayed on until the CPU with the timer woke, so a new thread on another CPU ran capped, down to 3096 MHz. It now samples on time while a ceiling is held, and once after a wake. The host test covers it and fails without the fix.136204e3ee9b: the SMC setup in probe is main's block again with one more condition, plus a stale comment.
No change without the properties: traced for T6030, T6050, T8140 and T8132: same SMC setup, same profile ceilings, same sampling, and the policy notifier from #2856 is registered in the same cases.
The J604 values. 3936/2808 match what macOS 27.2 held on our J773g with ten threads, and #524 measured 4416/4464 MHz at 5.0-5.4 W a core against 3.1 W at 3936. 13.5 W is derived (about 15.5 W PHPC less the non-CPU share) and 3096 is a chosen floor, so the A/B decides them.
Rows at this head
- J604 (author), base vs head on AC: all-core score, P/E time in state, PP0b + PPbb, PHPC; the same with four P-only threads and a SIMD-heavy all-core load. Pass: more efficient than base, and no score below macOS on the same load. #524 has 3876 MHz drawing more than 3936, so if the clock flips between 3756 and 3876 in a steady run, say so.
- J604 also: CPU+GPU load (P clock and fps vs base), six E-only threads reach 2892 MHz, single thread right after an all-core load reaches 4464 MHz, low-power with the new PHPC loop, balanced, performance, battery, s2idle and deep sleep.
- J773g (T8132) and J714s (T6050): no change against base.
Evidence
- Merge tree
b3fa7f87d8cdat5a4e1824503eequals GitHub's test merge; main1ab453e8adds only a workflow file. - KUnit on UML
apple-clpc*26/26 at this head'sclpc.c.clpc-gpu-demand-tests.py,clpc-high-power-cleanup-tests.py,clpc-ane-cpu-opp-tests.pypass; negative controlboard-ceiling-deferrablefails as it should. - arm64 GCC 16.2 W=1
clpc.owith KUnit off and on: no warnings.checkpatch --strictclean on both commits. dt_binding_checkclean for both bindings.t8132-j604.dtbCHECK_DTBS W=1 output identical to main; the DTB differs only by the new properties and phandle numbers.
Nit: the 92 % comment says one step is about 1 W. By #524's model four cores from 3756 to 3876 MHz is about 1.7 W.
All five points are fixed at 136204e; only hardware rows are left (see the review at that head).
There was a problem hiding this comment.
Verdict: REQUEST CHANGES at 136204e
Failure: apple_clpc_profile_limit() at clpc.c:1762 only takes a sustained-power step when the milliwatt value changes. The exact controller arithmetic with the J604 OPPs and 13,500 mW target steps from 3936 to 3876 MHz on the first valid 14,000 mW sample. Five more valid 14,000 mW samples leave it at 3876 MHz, while 14,001 mW immediately steps to 3756 MHz. The controller stops moving toward the target while power is still over budget and the frequency is above the configured floor. Let valid repeated over-budget samples continue the existing step-down.
Checked: Both changed bindings pass dt-doc-validate. Reviewed the per-cluster property lookup, OPP bounds, CPU-rail selection, slow-cluster cap and QoS release. The exact CLPC host suite and its held-ceiling control passed.
Follow-ups: Please split the larger production change into smaller reviewable PRs where dependencies permit.
|
On the review at One thing to add to the J604 A/B set: |
Intended, same rule as the low-power ceiling on main; answered in the thread. The J604 set will show power_reads/power_updates.
|
@DjDeveloperr Thanks for clearing the code review, pushing the held-ceiling timer and probe cleanups ( |
|
Re-checked One thing for the J604 A/B: use a base that has #3882, and the head merged with that same |
|
Thanks for re-checking |
|
Follow-up note from J604 ( On J604, we found that applying Keeping the reviewed head |
|
Additional follow-up note from J604 ( In Keeping the reviewed head |
|
@IronsideXXVI This branch now conflicts with
Could you forward-merge |
What: Add optional, DT-driven per-cluster all-core ceilings, a slow-cluster busy cap, and a sustained all-core SMC CPU-rail power limit to
apple-clpc, and enable J604's limits int8132-j604.dts(zero runtime module parameters, zero machine-name matching):dt-bindings: cpufreq: apple,cluster-cpufreq: document optional per-cluster propertiesapple,all-core-frequency-max-mhz,apple,slow-cluster-busy-max-mhz, andapple,sustained-frequency-min-mhzdirectly on the cluster cpufreq domain node (&cpufreq_p/&cpufreq_e), validated against that cluster's OPP table.dt-bindings: power: apple,pmc: document optionalapple,sustained-power-mwandapple,sustained-power-key-ids(required together withapple,smcviadependentRequired) onperformance-controller, separate from the low-power profile'sapple,power-key-id(PHPC).soc: apple: clpc:apple,all-core-frequency-max-mhz,apple,slow-cluster-busy-max-mhz, andapple,sustained-frequency-min-mhzfrom each cluster'sperformance-domainsnode and warn (dev_warn) if any configured frequency is not a valid OPP in that cluster's table.APPLE_CLPC_POWER_MSwindow (80%per-CPU busy threshold,200 msrelease hold) outside the low-power profile (bothbalancedandperformanceprofiles, on AC and battery).apple,slow-cluster-busy-max-mhzonly while a faster cluster is busy — leaving slow-cluster-only workloads (e.g. 6-thread E-only with P idle) completely uncapped.apple,sustained-power-mwby summing the dedicated CPU cluster SMC power rails listed inapple,sustained-power-key-ids(e.g.PP0b+PPbbon J604, excluding GPUPP1band display), with an explicit per-cluster floor (apple,sustained-frequency-min-mhz, or a>= max_freq / 2fallback if unset) and92%step-up hysteresis. Polls SMC only while all-core load holds a faster cluster (zero SMC reads at idle or single-core load) and releases when all-core load ends.apple-clpc-policyKUnit coverage for OPP validation, explicit/fallback floors, uncapped 6-thread E-only load, and busy-P E-cap.arm64: dts: apple: t8132-j604: configure&cpufreq_p(3936 MHzall-core max,3096 MHzsustained min),&cpufreq_e(2808 MHzslow-cluster busy max only), and&clpc(apple,smc = <&smc>,apple,sustained-power-key-ids = "PP0b", "PPbb",apple,sustained-power-mw = <13500>). Note: wiringapple,smc = <&smc>on J604&clpcalso enables the existing low-power SMCPHPCpower-budgeting loop whenever the boot loader passes Low Power mode values from ADT.Measurement basis for control constants (J604, T8132):
80%per-CPU busy across100 ms: Under7zz b 3mtall (~915% total CPU on 4P+6E), active P-cores run ~88–96% busy per 100 ms window while brief 20 ms scheduling dips previously caused ~6–9.5% turbo leak at4464 MHz.80%over100 mscleanly separates sustained all-core load from single/few-thread bursts.200 msrelease hold (two100 mswindows): Bridges brief I/O or lock dips between all-core blocks without spiking to4464 MHz, while releasing within 200 ms so subsequent single-thread runs hit4464 MHzimmediately.92%step-up threshold (8%deadband): Parallels the low-power profile's90%deadband, sized to the13.5 WCPU-rail budget so one P-cluster OPP step (~120 MHz / ~1.0 W) does not oscillate between adjacent OPPs.13500 mW(PP0b+PPbb) target &3096 MHzfloor: Matches J604's ~15.5 WPHPCsustained envelope minus ~1.5–2.3 W non-CPU SoC/fabric/display draw insidePHPC(measured on J604:PP0b = 10.77 W,PPbb = 2.38 Wunder heavy 10-thread burn vsPHPC ~ 15 W), with3096 MHz(a verified J604 P-cluster OPP) preventing deep CPU throttling.PLATFORM_PROFILE_LOW_POWER(bothbalancedandperformance, on AC and battery; J604 has no High Power mode).Tested:
136204e3ee9b(two small commits on top of5a4e1824503e), merged withmain5d5060423c0e:apple-clpc*): 26/26 (apple-clpc-policy10/10,apple-clpc-gpu16/16).clpc-gpu-demand-tests.py(with the new held-ceiling case and its negative control),clpc-high-power-cleanup-tests.pyandclpc-ane-cpu-opp-tests.pypass.clpc.owith KUnit off and on: no warnings.checkpatch --strictclean on both commits.dt_binding_checkfor both bindings clean;t8132-j604.dtbCHECK_DTBS W=1 output identical tomain(DT files unchanged since5a4e1824503e).5a4e1824503e(forward-mergedorigin/main49fa570626f5including#2856and#3801):drivers/soc/apple/clpc.kunitconfig, Clang 18.1.8LLVM=1, KASAN+UBSAN): 26/26 CLPC subtests passed (apple-clpc-gpu16/16 +apple-clpc-policy10/10, includingapple_clpc_t6050_gpu_fabric_test,apple_clpc_all_core_window_test,apple_clpc_sustained_power_test, andapple_clpc_all_core_and_e_cap_test).LLVM=1 W=1build ofdrivers/soc/apple/clpc.o: 0 warnings, 0 errors with bothCONFIG_KUNIT=n(CONFIG_MFD_MACSMC=y) andCONFIG_KUNIT=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 dt_binding_check DT_SCHEMA_FILES=cpufreq/apple,cluster-cpufreq.yaml: 0 errors, 0 warnings.make ARCH=arm64 LLVM=1 CHECK_DTBS=y apple/t8132-j604.dtb: 0 new warnings (output identical tomain).tools/asahi/clpc-high-power-cleanup-tests.pyandtools/asahi/clpc-ane-cpu-opp-tests.py: PASSED.scripts/checkpatch.pl --strict --git 9f09f0787..5a4e1824503e: 0 errors, 0 warnings, 0 checks across all 3 rework commits.Risk: two-way · J604 (
T8132) only — all new behavior is strictly opt-in via the optional DT properties on&cpufreq_p,&cpufreq_e, and&clpcint8132-j604.dts. Other T8132 (e.g. J773g) and non-T8132 boards (e.g. J714s / T6050) havehas_all_core == falseand take the exact existing code path. A plain revert restores uncapped all-core behavior on J604.Not yet: hardware rows at the current head. J604: all-core on/off A/B (score, P/E clock residency, PP0b+PPbb and PHPC), four P-only threads, a SIMD-heavy all-core load, CPU+GPU load (P clock and fps vs base), six E-only threads at 2892 MHz, single thread right after an all-core load, low-power (new PHPC loop), balanced and performance profiles, battery, s2idle and deep sleep. J773g (T8132 without the properties) and J714s (T6050, shared probe path): no change against base.
Commit list & offline verification summary
Forward commits atop
origin/mainmerge9f09f0787(49fa570626f5):47f942d2f1f2dt-bindings: apple: move CLPC limits to cpufreq domains and add CPU keyse450562323ccsoc: apple: clpc: regulate sustained CPU power on CPU rails with OPP limits5a4e1824503earm64: dts: apple: t8132-j604: use per-cluster CLPC limits and CPU rails6dc15236ba6esoc: apple: clpc: sample on time while a board ceiling is held136204e3ee9bsoc: apple: clpc: look up the SMC and its power key in one blockKUnit summary (
qemu-system-aarch64, Clang 18.1.8, KASAN+UBSAN):