Repository navigation
soc: apple: clpc: send the SMC Low Power Mode notice (J813/J815) - #3868
Conversation
apple,low-power-smc-notice: the low-power platform profile tells the SMC (apple,smc) that Low Power Mode is on, in the record that already carries High Power mode. In both bindings that carry a CLPC node. Signed-off-by: Nick <nekreshen@yandex.ru>
macOS writes the SMC's 120-byte zETM record at every power mode change. Besides the High Power float at byte 112, which the performance profile already sends, the record has a Low Power Mode float at byte 76: 1.0 while Low Power Mode is on, 0.0 otherwise. Traced on J815 (macOS 27.2.1) across four toggles and across deep sleep + wake: byte 76 is written on each mode toggle while every other slot stays 0, and the SMC retains the record across suspend without a rewrite on wake. Build one record from the profile with both floats and a single counter, so each write states the whole mode, and send it where the DT asks for the notice (apple,low-power-smc-notice). The notice is advisory: if the write fails, the low-power ceilings still apply and nothing is left to withdraw. High Power mode keeps failing the profile change without its write. Removal sends an all-off record when either flag was taken. The host test covers the combined record, a direct low-power to performance switch, the failed notice, and the missing opt-in; it still runs the pre-fix source as its negative control. Signed-off-by: Nick <nekreshen@yandex.ru>
…otice Give the M5 MacBook Air CLPC node the SMC phandle and opt into the zETM Low Power Mode notice, matching macOS on J815. Signed-off-by: Nick <nekreshen@yandex.ru>
|
Hardware row at
|
DjDeveloperr
left a comment
There was a problem hiding this comment.
Reviewed 9030039. One zETM writer that states both modes per record is right, the Low Power notice stays advisory while a failed High Power write still fails the profile change, and removal withdraws whichever flag the SMC took. Without the new property nothing changes on other Macs. The J815 row at this head covers the new path.
Because J714s, J616c, J616s and K116s use the same writer for High Power mode, merge also needs a short row on one of them at this head (performance, balanced and back, one record per switch in the debugfs status, no SMC warnings). #3646 adds the same apple,smc line to t8142-j813-j815.dtsi; whichever lands second must drop it, or dtc will reject the duplicate property.
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
|
J714s (M5 Pro, T6050) exact-head row at
|
|
Why this conflicts, and a ready resolution (main This branch sits on the older main
Please update with a merge, without a force push, so the approval at the new head can come from someone other than the pusher: Resolved text
stop(); record(false, 0); assert(!c.high_power_sent);
/* The GPU's reference outlives the device: stop drops a held low-power cap. */
reset(); c.low_power = true; gpu.cap_mw = 1250;
stop(); assert(gpu.cap_mw == 0);
#ifdef LOW_POWER_NOTICE
... your notice cases, unchanged ...
#endif
puts("CLPC High Power: profile state, cleanup ordering, zETM off, SMC failures and GPU cap passed");
# Older sources have one High Power writer; newer ones one writer for the whole mode.
notice = 'static int apple_clpc_send_mode(' in source
if notice:
defines += '\n#define LOW_POWER_NOTICE 1\n#define SEQ zetm_seq'
else:
defines += '\n#define SEQ high_power_seq'
# Older sources (--old-ref) have no apple_clpc_power_limited(); newer profile_set calls it.
names = (['apple_clpc_power_limited'] if 'static bool apple_clpc_power_limited(' in source else []) + [
'apple_clpc_send_mode' if notice else 'apple_clpc_send_high_power',
'apple_clpc_profile_set', 'apple_clpc_halt', 'apple_clpc_stop']
body = '\n\n'.join(function(source, n) for n in names)Merged onto
The hardware rows stay valid. Against main, the merged PR changes exactly the same lines in The 06:30 J815 row also covers this PR's "Not yet" line. Power-saver sent the notice, one record per switch, with no SMC warnings, and the same boot finished a clean 165 s deep sleep. The patch adds no suspend or resume code, and your trace shows the SMC keeps the record across sleep. So no separate sleep row is needed. Local checks on the merge tree (
Next step: after your merge is pushed, I'll check the five files against the blobs above, approve at that head and merge. |
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>
|
I merged How the conflicts with #3646 were resolved:
Local checks on the merge (clang 23, arm64): W=1 |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Verdict: MERGE at 82166dde5c7d54adf037e6483c11404cb3f21d7b
Blockers: none
Checked: the whole diff against main, the merge commit, how the notice sits next to #2856, the hardware rows and the heads they ran at, and local builds on the merge with current main (5fe340acef00). I didn't write the merge and read it fresh.
The merge commit. Beyond what git merges by itself it changes only apple,pmc.yaml, the J813/J815 dtsi and clpc-high-power-cleanup-tests.py, and all three are right. The lines this PR adds and removes in clpc.c and both bindings are the same as at 90300394b3d3. The one devicetree difference is the dropped second apple,smc, which main already has from #3646.
The driver.
- Locking: the SMC write runs under
sample_lockand then takes the SMC's mutex, the order the power reading already uses. The SMC drivers never call into CLPC or cpufreq policy changes with that mutex held. - With #2856:
apple_clpc_stop()dropssample_lockbefore it unregisters the cpufreq notifier, whose callback takessample_lock. So the notice can't deadlock with the ANE floor being withdrawn. #2856 doesn't change the functions that send the notice; it only moves the notifier registration in probe, after the stop action. - Suspend and resume don't touch the notice. The first write links CLPC to the SMC as its consumer, so CLPC suspends first.
- Unbind: the platform profile is gone before
apple_clpc_stop()runs, and the all-off record goes out only if the SMC took an on record. A probe error never sends anything. - Failures: a failed Low Power notice still applies the profile, and a failed off record is tried again at the next change or at unbind. A failed High Power write still fails the profile change, as before.
- Boards: only J813 and J815 have the property. In the built DTBs, J704, J714s and J773g don't. On those
lowis always false, so High Power Macs send the same records as before.
Hardware: no new row is owed. The J815 row (06:30: power-saver sends the notice, one record per switch) and the J714s row (11:38: High Power unchanged, nothing sent without the property) both ran 90300394b3d3. The driver lines they covered are unchanged; only the surrounding context moved, because of #3646, and the J815 kernel already had #3646 in it.
Not blocking:
- The two flags start as off at probe. If the SMC keeps the record over a reboot, choosing balanced on the next boot sends nothing, so an old notice would stay on until low-power is switched on and off again. High Power has the same gap today.
- The
apple,smcdescription in the bindings still names only the power reading and High Power mode.
Evidence
Local, on the merge of this head with main 5fe340acef00 (tree 48401e8d1306, all 1830 CLPC, DT, binding and script sources matched to that tree by hash). clang 23.1.3, arm64:
W=1 drivers/soc/apple/clpc.o: 0 warnings, without KUnit and withCONFIG_KUNIT=y(compiled, not run).run-host-tests.py --only clpc: 9/9, including the--old-ref 677be395negative control.dt_binding_checkonapple,pmc.yamlandapple,clpc.yaml, style check included: clean.t8142-j813,t8142-j815,t8142-j704,t6050-j714sandt8132-j773gDTBs build. J813 and J815 haveapple,smconce and the notice once.
|
Merged as
No new hardware row was needed: the J815 and J714s rows at #3873 is next; we'll merge |
Conflicts with aurora-silicon#3868 and aurora-silicon#3992, resolved to keep both sides: - apple,pmc.yaml and apple,clpc.yaml: apple,low-power-smc-notice, then apple,low-power-capacity-ceiling and apple,energy-monitor. - t8142-j813-j815.dtsi: the notice, then the ceiling and the energy monitor on the CLPC node. - clpc.c: KUnit only. Keep the T6050 GPU fabric case and the capacity ceiling and energy power cases. The other files merge cleanly. Signed-off-by: DjDeveloperr <hey@djdev.me>
What: Send the SMC's 120-byte
zETMLow Power Mode notice (byte 76 = float1.0whilelow-poweris active,0.0otherwise) via a DT opt-in (apple,low-power-smc-notice), unified with the existing High Power mode notice (byte 112), and enable it on M5 MacBook Air (J813/J815).Tested: Build- and host-tested at
90300394b3d3(clpc-high-power-cleanup-tests.py+--old-ref 677be395,clpc-gpu-demand-tests.py,ARCH=arm64 LLVM=1 W=1plain +CONFIG_KUNIT=yclpc.o,t8142-j813.dtb,t8142-j815.dtb); hardware rows at90300394: J815 PASS (power-saver notice, one record per switch, clean deep sleep in the same boot) and J714s PASS (High Power path unchanged, no notice without the opt-in), both in the PR comments.Risk: two-way door · M5 MacBook Air (J813/J815) for the new opt-in; High Power mode Macs share the unified
zETMrecord writer (covered by host tests; unaffected whenapple,low-power-smc-noticeis absent).Not yet: nothing.
Details
zETMis a 120-byte SMC record ([0x1d, 0x01, seq++, 0x00]header followed by float slots). Linux already writes byte 112 (1.0f) for High Power mode; traced on J815 (macOS 27.2.1) across repeated toggles and across a real deep sleep + wake, Low Power Mode sets byte 76 to1.0f(0.0fwhen off) with all other slots zero, and the SMC retains the record across suspend without a rewrite on wake.apple_clpc_send_high_power()withapple_clpc_send_mode(clpc, low, high)using a singlezetm_seqcounter so every profile change states the complete mode in one write.low-power: if the SMC write fails, the profile's CPU ceilings still apply andlow_power_sentstays false so driver removal has nothing to clear. High Power mode keeps its existing hard-error behavior. Unbind writes an all-off record when either flag was taken.apple,low-power-smc-noticeinapple,pmc.yamlandapple,clpc.yaml, enabled ont8142-j813-j815.dtsi(withapple,smc = <&smc>).Evidence
main(6c83a2a64539):2d3208136992dt-bindings: apple: clpc: name the SMC's Low Power Mode noticecf8263616ce1soc: apple: clpc: tell the SMC when the low-power profile is on90300394b3d3arm64: dts: apple: t8142-j813-j815: send the SMC the Low Power Mode noticeaurora-kbuildcontainer):python3 tools/asahi/clpc-high-power-cleanup-tests.py: PASS (combined record, low->perf transition, advisory failed notice, failed clear retry on unbind, missing opt-in)python3 tools/asahi/clpc-high-power-cleanup-tests.py --old-ref 677be395: PASS (negative control still fails on pre-fix source)python3 tools/asahi/clpc-gpu-demand-tests.py: PASS (all positive + negative controls)ARCH=arm64 LLVM=1 W=1):drivers/soc/apple/clpc.o(plain andCONFIG_KUNIT=y),apple/t8142-j813.dtb,apple/t8142-j815.dtb— 0 errors, 0 new warnings.