Repository navigation
soc: apple: clpc / drm/asahi: g17: hold the low-power target with the CPUs and the GPU (J813/J815) - #3646
Conversation
|
@sithglan @gig3m: this is ready for testing. Would you have a few minutes to try it on a J813 (or J815)? It needs this PR and aurora-silicon/aura#580 (the loader passes the target). Thank you! A suspend/resume in Power Saver with the profile still |
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
There was a problem hiding this comment.
Verdict: CHANGES_REQUESTED at f99c021e
Blockers:
- PR-introduced
host-testsCI failures (6failures across 3 harnesses in run46296641487):tools/asahi/clpc-gpu-demand-tests.pyandtools/asahi/clpc-high-power-cleanup-tests.py: fail to compile withimplicit declaration of function 'apple_clpc_power_limited'because the slicedapple_clpc_sample()andapple_clpc_profile_set()now callapple_clpc_power_limited(). Includeapple_clpc_power_limited()in both harnesses.tools/asahi/g17-m5-governor-stop-tests.py(base + all 3 mutations): fails to compile witherror[E0609]: no field 'port' on type '&mut Firmware'atlet cap = self.port.power_cap_mw();, and--mutation drop-ineligible-restorefails withAssertionError: mutation drop-ineligible-restore does not applybecauseself.governor.restore()was updated toself.governor.restore_capped(cap). Update the harness's mockFirmwareand mutation target to match.
- Stale GPU power cap on CLPC provider removal (
drivers/soc/apple/clpc.c):apple_clpc_stop()withdraws CPUmax_qosceilings, clears SMC high-power mode, and detachesclpc->gpu->wake = NULL, but never zeroesclpc->gpu->cap_mw. Becausestruct apple_clpc_gpuis reference-counted and outlives CLPC unbind whileasahiholds its reference, unbindingapple-clpcwhilelow-poweris active leavesapple_clpc_gpu_power_cap()returning the last non-zero cap indefinitely. ClearWRITE_ONCE(clpc->gpu->cap_mw, 0)inapple_clpc_stop()afterapple_clpc_halt(clpc)(and cover it inapple_clpc_gpu_provider_removal_test/apple_clpc_gpu_cap_test). - Untested behavior change on T6050 (
drivers/gpu/drm/asahi/g17/mod.rs,g17/thermal.rs): On T6050,thermal::enabled()is true andapple,low-power-mwis set, soGovernor::tick()now appliescap_mwto the GPU budget before stepping CPU clusters (explicitly listed as untested underRisk:/Not yet:). Please add a T6050 hardware row exercisinglow-powerunder GPU load (and confirmingbalanced/ idle restore back to calibrated max), plus an exact-head J815/J813 row after updating the PR.
Checked:
- DT bindings (
Documentation/devicetree/bindings/power/apple,pmc.yaml,apple,clpc.yaml) andarch/arm64/boot/dts/apple/t8142-j813-j815.dtsi:apple,power-key-idregex (^[A-Za-z0-9#!]{4}$),apple,low-power-mw, andapple,smc = <&smc>passdt-checks. drivers/soc/apple/clpc.c&include/linux/soc/apple/clpc.h:apple_clpc_power_limited()avoids 100 ms polling without an SMC,apple_clpc_gpu_cap_down()/apple_clpc_gpu_cap_up()step GPU cap down first (1/8steps down to1/4target) while active and restore it after CPU ceilings,apple_clpc_resume()resetspower_mw = -1, clustermax_khz = 0, and activegpu->cap_mw = low_power_mw, and!CONFIG_APPLE_CLPCinline stub returns0.drivers/gpu/drm/asahi/g17/{clpc.c,clpc.h,mod.rs,port.rs,power.rs,thermal.rs}: FFI wiring is NULL-safe (gpu ? READ_ONCE(gpu->cap_mw) : 0),Governor::set_maximum()marksself.unpublished = truewhen Region C diverges fromself.budget_mw(e.g., after wake/recovery),Governor::capped()appliescap_mwdown toSTEP_MWwithout lifting toFLOOR_MW, and boththermal::enabled()and!thermal::enabled()paths release the cap when idle.- CI at
f99c021e:apple-build,dt-checks,rust-build,source,pr-text,DWC3/ATCmatrix, and all KUnit suites (includingKUnit clpcandKUnit asahi) passed; onlyhost-testsfailed (826/837).
Evidence
- Diff reviewed:
linux#3646atf99c021e46cbd1aaa456af895b5384d966755d42(+309/-32, 11 files, 4 commits,MERGEABLEonmain). - Failing
host-testsjob (run 46296641487,job 141526587268,826/837):- PR-introduced (6):
clpc-gpu-demand-tests,clpc-high-power-cleanup-tests,g17-m5-governor-stop-tests(base + 3 mutations). - Unrelated to this PR (5):
apple-scaler-recovery-tests,g17-output-fence-tests(base + 3 mutations).
- PR-introduced (6):
- Nit (non-blocking): in
apple_clpc_gpu_cap_down(),min_cap = clpc->low_power_mw / APPLE_CLPC_GPU_CAP_MIN_DIVcould evaluate to0if a synthetic DT ever suppliedlow_power_mw < 4, causingREAD_ONCE(gpu->cap_mw) ?: clpc->low_power_mwto re-initialize the cap on the next tick;max(clpc->low_power_mw / APPLE_CLPC_GPU_CAP_MIN_DIV, 1U)avoids that edge case cleanly.
f99c021 to
ed8b022
Compare
|
Thanks for the review. Addressed in ed8b0229 (folded into the four commits):
|
There was a problem hiding this comment.
Verdict: HOLD at ed8b022d for the refreshed J815/J813 row. The source now clears the cap on provider stop and gates GPU capping on the DT property. The harness updates cover the provider cleanup and the new Rust and C interfaces. No failed hosted checks were visible on this head. Record the current-head hardware result or maintainer acceptance of equivalence before landing.
|
Hardware row at
|
There was a problem hiding this comment.
Verdict: MERGE at ed8b022d99ae
Converts this App's earlier review at the same head to an approval under the 12-01 merge bar (better than before and doesn't break; block only on a shown failure). No code blocker was found in it. The merge gate (a row on one Mac at this head + fast CI) is tracked by pr-readiness, not held here.
Checked: Code reviewed in the earlier App review at this head (6108232146).
Follow-ups (not blocking): current-head J815/J813 row or maintainer equivalence acceptance
The low-power platform profile holds an SMC power reading at apple,low-power-mw. That reading has always been PHPC, which does not carry the package power on every machine: on the M5 MacBook Airs it reads about 30 mW at any load. Add apple,power-key-id, the four-character SMC key of the reading (PHPC when absent), and apple,low-power-gpu-cap, which lets the limit cap the GPU's power budget first, and describe apple,low-power-mw in both bindings that carry a CLPC node, as the boot loader passes it from the ADT. Signed-off-by: Nick <nekreshen@yandex.ru>
The low-power profile's power loop read PHPC and stepped only the CPU clusters. Where PHPC does not follow the package power there is nothing to hold, and a GPU load above the target walks the CPU clusters down to their lowest state while the GPU keeps its whole budget. - Read the SMC key the node names in apple,power-key-id (PHPC by default, so existing boards read what they read before). - Poll only with an SMC to read: a target without apple,smc keeps the static ceiling and queues no 100 ms work. - With apple,low-power-gpu-cap, give the GPU a share of the steps through its CLPC input: a cap that starts at the target, takes each step down first while the GPU is active, down to a quarter of the target, and gets its steps back last, after the CPU clusters. apple_clpc_gpu_power_cap() returns it to the GPU driver, 0 outside the power-limited low-power profile and on boards without the property, which keep stepping only the CPUs. Unbinding the CLPC drops the cap, as the GPU's reference outlives it. - After a sleep, start again from the ceiling and the cap's start, and act on the first reading after the wake. - debugfs shows the key, the target and the cap. - Host tests: the sliced sample and profile code calls apple_clpc_power_limited(); a target polls only with an SMC; stop drops the cap. Signed-off-by: Nick <nekreshen@yandex.ru>
The CLPC's low-power profile hands the GPU a power cap (apple_clpc_gpu_power_cap()). Apply it to the host power budget word in Region C while the GPU is busy, as a ceiling on whatever the budget governor would publish, with or without the thermal controller. An idle GPU goes back to the calibrated maximum as before. The cap is not raised to the thermal controller's own floor: it limits the whole GPU for the platform, not the controller's output range. The governor stop host test gets the port's cap. The governor also publishes again when the budget word no longer holds the last published budget, as after the firmware's initialization data is written again on a wake or a recovery. Signed-off-by: Nick <nekreshen@yandex.ru>
The MacBook Airs' low-power profile has only its CPU ceiling. Give the CLPC the SMC and name PPSM as the power reading to hold: the SoC power the SMC measures, updated once a second and live under Linux. PHPC reads about 30 mW at any load here, and the SMC's package power keys (PZC0, PZC1) read 0 under Linux. On J815 PPSM follows the package power within about 1 W under load (correlation 0.99 over a 7-minute mixed CPU/GPU run). With a boot loader that passes the ADT's Low Power target as apple,low-power-mw, the profile holds PPSM at it with the CPU ceilings and the GPU cap (apple,low-power-gpu-cap: a GPU load takes the limit on the GPU's budget first). Without it only debugfs changes: it shows the reading. Signed-off-by: Nick <nekreshen@yandex.ru>
ed8b022 to
6fe3caf
Compare
|
Rebased onto
|
|
Hardware row at
|
DjDeveloperr
left a comment
There was a problem hiding this comment.
Looks right. The cap only lowers the GPU budget, and only on boards that opt in. It takes its steps first while the GPU is active and gives them back last. It's dropped on a profile change (power_next is reset, so profile_limit runs right away), on unbind, and restarted after a wake. A target without an SMC no longer polls for nothing. On boards without apple,low-power-gpu-cap the GPU budget path is unchanged, and m5_power_budget() keeps the new set_maximum() call M5-only. I started the hosted CI that was waiting for approval.
Two hardware gates are left. Neither is a code change:
- A J813 or J815 row at this exact head on its own. The J815 PASS at
6fe3caf3ran with #3868 and #3873, which also changeclpc.c. The J813 row was ated8b022d, before the rebase that resolved conflicts inclpc.c,g17/and the J813/J815 DT. Power Saver under an all-core load and under vkcube, Balanced unchanged, and one deep sleep in Power Saver are enough. - A second-generation row, because CLPC and the M5 governor are shared. I've queued our J714s at this head: Balanced and Performance unchanged, Power Saver still steps only the CPU clusters, and one sleep/wake.
|
Merging at |
Conflicts and duplicates against aurora-silicon#3646, resolved to keep both sides: - apple,pmc.yaml: main's low-power properties, then apple,low-power-smc-notice. - t8142-j813-j815.dtsi: no textual conflict, but both sides add apple,smc to the CLPC node and dtc rejects the duplicate. Keep main's and add only apple,low-power-smc-notice. - clpc-high-power-cleanup-tests.py: main's GPU cap case and apple_clpc_power_limited() handling, and the notice cases with the send_mode/SEQ switch. drivers/soc/apple/clpc.c merges cleanly, with aurora-silicon#2856 and aurora-silicon#3992 in main. Signed-off-by: DjDeveloperr <hey@djdev.me>
What: on the M5 MacBook Airs (J813, J815) the low-power platform profile is only a CPU ceiling. This makes it also hold a power reading at the machine's Low Power target, with the CPU ceilings and (where the DT opts in with
apple,low-power-gpu-cap) a cap on the GPU's power budget, as the profile already does with PHPC on T6050. The DT names the SMC reading (apple,power-key-id, PHPC by default); J813/J815 use PPSM, because PHPC and the SMC's package keys do not follow the load there under Linux. The target comes from the ADT through the boot loader (aurora-silicon/aura#580).Tested: J815 (MacBook Air 15" M5), this series on j815/nightly4 6c8d964c01f1 (main 37a19f9 + #2549 + other open PRs) with aurora-silicon/aura#580 (target 5000 mW from the ADT): Power Saver through
powerprofilesctlholds PPSM at 4.95 W under an all-core load (Balanced 23.1 W), 4.54 W under vkcube with the CPU ceilings untouched, 4.91 W with both (Balanced 22.8 W); one deep sleep in Power Saver under load woke OK and kept holding (4.72 W); 0 new kernel errors, 0 failed units, 0 suspend failures. Hardware at f99c021; ed8b0229 adds theapple,low-power-gpu-capopt-in (set on J813/J815, so their behaviour is the same), drops the cap on CLPC unbind and updates the host tests (clpc-gpu-demand,clpc-high-power-cleanup,g17-m5-governor-stopand its 3 mutations pass locally).Risk: two-way door. J813/J815 through their DT (and the loader PR); boards without
apple,power-key-idkeep PHPC. Other boards are unchanged: the GPU cap needsapple,low-power-gpu-cap, which only J813/J815 set, so T6050 keeps stepping only its CPU clusters. The cap and the ceilings only ever lower the clocks and the budget; Balanced and Performance are unchanged.Not yet: J813; a J815 run at ed8b0229 (same DT behaviour); more sleep cycles (one so far). One idle PPSM snapshot of 656 W was seen once in debugfs (the samples around it are normal); it costs one step and is being looked at.
Details
Why PPSM. On J815 under Linux, PHPC reads ~30 mW at any load, and
PZC0/PZC1(package power under macOS) read 0 in every boot snapshot we have (83 boots).PPSMis live (1.9 to 17 W across those snapshots) and updates once a second. Measured on J815 under macOS, sampling allP*keys every 250 ms through a mixed CPU/GPU run of about 7 minutes, PPSM follows PZC0 with r = 0.989 (PPSM - PZC0: median 0.7 W at 4-6 W, 1.4 W at idle, 2.3 W above 10 W). Holding PPSM at the target is therefore somewhat stricter than holding the package figure; no offset is added.Commits.
dt-bindings: apple: clpc:apple,power-key-idin both bindings that carry a CLPC node, andapple,low-power-mwinapple,pmc.yaml.soc: apple: clpc:apple,low-power-gpu-cap;apple_clpc_gpu_power_cap(), 0 outside the power-limited profile;drm/asahi: g17: M5: the cap is a ceiling on the Region C host power budget while the GPU is busy, with or without the thermal controller; an idle GPU goes back to its maximum. The cap is not raised to the thermal controller's floor. The governor also publishes again when the word no longer holds its last budget (e.g. after the init data is written again on a wake).arm64: dts: apple: t8142-j813-j815:apple,smc,apple,power-key-id = "PPSM"andapple,low-power-gpu-capon the CLPC node, so both Airs get it.Front ends. The profile is the existing
apple-clpcplatform profile, so KDE, GNOME andpowerprofilesctlswitch it through power-profiles-daemon: Power Saver =low-power. Distro kernels without ACPI also need #2549 for the class to exist. power-profiles-daemon builds that only read/sys/firmware/acpi/platform_profileneed the class-device patch the alarm package carries.Related. #3488 (skip idle clusters on the step down) is complementary: with this PR a GPU load takes its steps on the GPU first where the DT opts in. A board such as T6050 can opt in later with its own hardware row (#3450).
Deep sleep. The CLPC already halts on suspend and the device link to the SMC orders it before the SMC. On resume the low-power loop now starts again from its ceiling. Nothing is written to the SMC or the PMP.
Evidence
J815 hardware run (Power Saver =
low-power, target 5000 mW, P ceiling 2220 MHz; PPSM sampled once a second from the CLPC's debugfs):GPU phase, seconds 9-15 (power / cap, mW):
4925/5000 5012/4375 5950/3750 6846/3125 5732/2500 5637/1875 5656/1250J815, Linux,
macsmc-hwmonkey dump at boot (mW), newest boots:J815, macOS, 250 ms SMC samples over the run (1650 samples): corr(PZC0, PPSM) 0.989, corr(PZC0, PHPS) 0.999, PHPC 0.02-0.04 W throughout.
Build (Docker, LLVM 19, Rust 1.99):