Skip to content

soc: apple: clpc: send the SMC Low Power Mode notice (J813/J815) - #3868

Merged
DjDeveloperr merged 4 commits into
aurora-silicon:mainfrom
m0d16l14n1:j815/t8142-lpm-smc-notice
Dec 2, 2026
Merged

DjDeveloperr merged 4 commits into
aurora-silicon:mainfrom
m0d16l14n1:j815/t8142-lpm-smc-notice

Conversation

@m0d16l14n1

@m0d16l14n1 m0d16l14n1 commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

What: Send the SMC's 120-byte zETM Low Power Mode notice (byte 76 = float 1.0 while low-power is active, 0.0 otherwise) 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=1 plain + CONFIG_KUNIT=y clpc.o, t8142-j813.dtb, t8142-j815.dtb); hardware rows at 90300394: 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 zETM record writer (covered by host tests; unaffected when apple,low-power-smc-notice is absent).
Not yet: nothing.

Details
  • zETM is 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 to 1.0f (0.0f when off) with all other slots zero, and the SMC retains the record across suspend without a rewrite on wake.
  • Replaces apple_clpc_send_high_power() with apple_clpc_send_mode(clpc, low, high) using a single zetm_seq counter so every profile change states the complete mode in one write.
  • Advisory on low-power: if the SMC write fails, the profile's CPU ceilings still apply and low_power_sent stays 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.
  • Opt-in via apple,low-power-smc-notice in apple,pmc.yaml and apple,clpc.yaml, enabled on t8142-j813-j815.dtsi (with apple,smc = <&smc>).
Evidence
  • Commits on main (6c83a2a64539):
    • 2d3208136992 dt-bindings: apple: clpc: name the SMC's Low Power Mode notice
    • cf8263616ce1 soc: apple: clpc: tell the SMC when the low-power profile is on
    • 90300394b3d3 arm64: dts: apple: t8142-j813-j815: send the SMC the Low Power Mode notice
  • Host tests (aurora-kbuild container):
    • 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)
  • Kernel builds (ARCH=arm64 LLVM=1 W=1): drivers/soc/apple/clpc.o (plain and CONFIG_KUNIT=y), apple/t8142-j813.dtb, apple/t8142-j815.dtb — 0 errors, 0 new warnings.

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>
@m0d16l14n1

Copy link
Copy Markdown
Contributor Author

Hardware row at 90300394 — MacBook Air 15-inch (M5, J815, T8142): PASS (kernel 7.3.0-aurora-j815-dev carrying 90300394b3d3 alongside #3646 and #3873).

  • SMC Low Power Mode notice (lpmkit-20261202-091704, notice test):
    • DT property apple,low-power-smc-notice present on /soc/power-management@382700000/performance-controller@1.
    • Debugfs smc power mode tracked every profile transition with exactly one SMC zETM write per switch:
      • balanced: high power off, low power off (20 records sent)
      • low-power (power-saver): low power on (21 records sent)
      • balanced: low power off (22 records sent)
    • No SMC write warnings in dmesg.
  • Note: Tested without the lpm-kit deep-sleep-under-load step (the same boot completed a 165 s deep sleep cleanly prior to the test: suspend_stats/success=1, fail=0, apple-clpc suspend 16 us / resume 9 us). Also note that #3646 and #3868 both add apple,smc = <&smc>; to &clpc in t8142-j813-j815.dtsi, so whichever merges second will drop its duplicate line on rebase.
  • Regressions: 0 new kernel err/crit log lines, 0 failed systemd units, 0 crashes.

@m0d16l14n1
m0d16l14n1 marked this pull request as ready for review December 2, 2026 06:30
@m0d16l14n1
m0d16l14n1 requested review from a team and DjDeveloperr as code owners December 2, 2026 06:30
DjDeveloperr
DjDeveloperr previously approved these changes 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.

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.

@github-actions github-actions Bot added area:bringup Area from CODEOWNERS (bot) area:gpu Area from CODEOWNERS (bot) area:platform Area from CODEOWNERS (bot) blast:m5 Macs affected, from Merge risk (bot) ci-failing A check failed at the PR head (bot) door:two-way Revertible or not, from Merge risk (bot) labels Dec 2, 2026
@github-actions

github-actions Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Merge readiness at 82166dde: not ready yet

Check Detail
CI at head ok no CI for this change (the hardware row is the gate)
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head no no line with the head SHA 82166dde, a Mac and a result in the PR body or a comment
Conflicts ok none
PR text ok Risk: two-way · M5 MacBook Air (J813/J815) for the new opt-in; High Power mode Macs share the unified zETM record writer (covered by host tests; unaffected when apple,low-power-smc-notice is absent).

Areas: area:bringup, area:gpu, 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 ready-to-merge Meets the merge policy: merge it (bot) and removed ci-failing A check failed at the PR head (bot) labels Dec 2, 2026
@DjDeveloperr

Copy link
Copy Markdown
Contributor

J714s (M5 Pro, T6050) exact-head row at 90300394b3d35c5ffebcc5bbf4fdc88a1b56ca1b: PASS

  • Candidate: origin/main (2225082e1d18) + exact #3868 (90300394b3d35c5ffebcc5bbf4fdc88a1b56ca1b) in consolidated 4-PR boot b0ccb5fce773 (7.3.0-m5-pr3898-b0ccb5fc), verified identically across two candidate boots (63bd561e-b30d-4ad1-942c-b4205ce9f924 and 40c311c4-ea02-4fa3-97b9-9b6327464b5a), SLC on (16 planes), SEP writes enabled.
  • DT (/proc/device-tree/soc@200000000/power-management@286806000/performance-controller@1/): apple,high-power-mode present; apple,low-power-smc-notice absent.
  • CLPC zETM debugfs (/sys/kernel/debug/286806000.power-management:performance-controller@1/status):
    1. Initial (performance): smc power mode: high power on, low power off (1 records sent)
    2. powerprofilesctl set balanced: high power off, low power off (2 records sent)
    3. powerprofilesctl set performance: high power on, low power off (3 records sent)
    4. powerprofilesctl set balanced: high power off, low power off (4 records sent)
    5. powerprofilesctl set power-saver: high power off, low power off (4 records sent) (unchanged — no low-power SMC notice sent on J714s)
    6. powerprofilesctl set balanced: high power off, low power off (4 records sent)
  • Health & handback: 0 new CLPC/SMC/zETM kernel errors; GPUBench Vulkan RT rt.scene medium b541b83e PASS pre/post (403.2–403.7 FPS, 0 GPU/MMU faults); clean stock 7.3.0-m5-pr67 handback (hw released ok).

@github-actions github-actions Bot added merge-conflict Conflicts with the base branch (bot) and removed ready-to-merge Meets the merge policy: merge it (bot) labels Dec 2, 2026
@DjDeveloperr

Copy link
Copy Markdown
Contributor

Why this conflicts, and a ready resolution (main 50addca5)

This branch sits on the older main 6c83a2a6. It doesn't carry #3646's commits. #3646 landed in main at 16:43 and changed the same lines, so these are real textual conflicts:

  1. Documentation/devicetree/bindings/power/apple,pmc.yaml: both sides add properties at the same spot. Keep both: main's apple,low-power-mw, apple,power-key-id and apple,low-power-gpu-cap, then your apple,low-power-smc-notice.
  2. tools/asahi/clpc-high-power-cleanup-tests.py: two hunks. Keep main's GPU-cap case and its apple_clpc_power_limited handling, and add your notice cases and the send_mode/SEQ switch. The resolved text is below.
  3. arch/arm64/boot/dts/apple/t8142-j813-j815.dtsi merges without a conflict marker, but &clpc ends up with apple,smc = <&smc>; twice, and dtc rejects that (ERROR (duplicate_property_names): .../performance-controller@1:apple,smc: Duplicate property name). Drop your apple,smc line and keep apple,low-power-smc-notice;.

drivers/soc/apple/clpc.c and apple,clpc.yaml merge cleanly.

Please update with a merge, without a force push, so the approval at the new head can come from someone other than the pusher:

git fetch https://github.com/aurora-silicon/linux.git main
git merge FETCH_HEAD
# fix the three files as below
git add -u && git commit --no-edit && git push
Resolved text

t8142-j813-j815.dtsi, in clpc: performance-controller@1:

			apple,smc = <&smc>;
			apple,power-key-id = "PPSM";
			apple,low-power-gpu-cap;
			/* Tell the SMC when the low-power platform profile is on. */
			apple,low-power-smc-notice;

clpc-high-power-cleanup-tests.py, end of the C cases:

    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");

main():

    # 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 50addca5, this gives tree 47e174363275, with these blobs:

File Blob
apple,pmc.yaml ae4ba82bea30
apple,clpc.yaml 061f1ccf77c4
t8142-j813-j815.dtsi d3b4368d6732
clpc.c 8c47aa91baf5
clpc-high-power-cleanup-tests.py 7c44f4ec6ae7

git ls-tree HEAD -- <file> after your merge should show the same blobs, unless main touches these files again in the meantime.

The hardware rows stay valid. Against main, the merged PR changes exactly the same lines in clpc.c, apple,clpc.yaml and apple,pmc.yaml as 90300394 does. The only DT difference is the dropped duplicate apple,smc, which main already has from #3646. Your J815 row ran with #3646 in the same kernel, so it booted this DT. The test script differs only in harness plumbing. So the J815 row (06:30) and the J714s row (11:38), both at 90300394, cover the merged content.

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 (ssh pc, clang 23, ARCH=arm64 LLVM=1):

  • W=1 drivers/soc/apple/: 0 errors and no warnings in clpc.c. The only warnings are the existing set-but-unused ones in display-gate.c. clpc.o with CONFIG_KUNIT=y is also clean.
  • W=1 t8142-j813.dtb and t8142-j815.dtb: clean. A plain git merge, which keeps the duplicate apple,smc, fails dtc with the error above. The resolved DT compiles.
  • dt_binding_check on apple,pmc.yaml and apple,clpc.yaml (dtschema 2026.9, style check included): clean.
  • CHECK_DTBS on J813/J815: the same single existing warning as main (aliases: 'disp0_piodma'), nothing new.
  • checkpatch on the three commits: 0 errors, 0 warnings.
  • Host tests:
    • clpc-high-power-cleanup-tests.py: PASS.
    • The --old-ref 677be395 negative control still fails, as it should.
    • g17-m5-governor-stop-tests.py: PASS (5/5).
    • clpc-gpu-demand-tests.py fails at t6041_from_dt on plain main too, after arm64: dts: apple: t6041: keep light GPU busy tier at DCS 0 #3965's T6041 DT change, so that failure isn't from this PR.
  • KUnit is compile-only here (no QEMU). The hosted KUnit clpc job passed at 90300394, and the merge doesn't touch those cases.

Next step: after your merge is pushed, I'll check the five files against the blobs above, approve at that head and merge.

@github-actions github-actions Bot added merge-conflict Conflicts with the base branch (bot) and removed merge-conflict Conflicts with the base branch (bot) labels Dec 2, 2026
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>
@DjDeveloperr

Copy link
Copy Markdown
Contributor

I merged main (2c667a4be5a6, with #3646, #3992 and #2856) into this branch as a normal merge commit, 82166dde5c7d. Your three commits are unchanged.

How the conflicts with #3646 were resolved:

  • apple,pmc.yaml: both sides kept; main's low-power properties first, then apple,low-power-smc-notice.
  • t8142-j813-j815.dtsi: no conflict marker, but apple,smc was there twice. Main's line stays, and only apple,low-power-smc-notice is added.
  • clpc-high-power-cleanup-tests.py: main's GPU cap case and your notice cases are both kept.
  • clpc.c merged cleanly. The lines this PR adds and removes are the same as at 90300394. soc: apple: clpc: hold the M4 (T8132) memory, fabric and P-cluster floors for ANE work #2856 doesn't touch the notice: among the CLPC profile, sampling, stop, suspend and resume functions, it only changes probe.

Local checks on the merge (clang 23, arm64): W=1 clpc.o and its C users, 0 warnings, also with KUnit on and with ACPI off. The J813, J815, J714s and J773g DTBs build, and CHECK_DTBS reports the same warnings as with main's devicetree and bindings. dt_binding_check and the binding style check pass. run-host-tests.py --only clpc passes 9/9. checkpatch is clean on all three commits. KUnit was compiled, not run.

@github-actions github-actions Bot added needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) and removed merge-conflict Conflicts with the base branch (bot) labels 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.

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_lock and 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() drops sample_lock before it unregisters the cpufreq notifier, whose callback takes sample_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 low is 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,smc description 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 with CONFIG_KUNIT=y (compiled, not run).
  • run-host-tests.py --only clpc: 9/9, including the --old-ref 677be395 negative control.
  • dt_binding_check on apple,pmc.yaml and apple,clpc.yaml, style check included: clean.
  • t8142-j813, t8142-j815, t8142-j704, t6050-j714s and t8132-j773g DTBs build. J813 and J815 have apple,smc once and the notice once.

@DjDeveloperr
DjDeveloperr merged commit 01ccbcd into aurora-silicon:main Dec 2, 2026
@DjDeveloperr

Copy link
Copy Markdown
Contributor

Merged as 01ccbcdbd87f with the admin bypass, for two reasons:

  • Hosted CI did not run at 82166dde5c7d: the runs ended in startup_failure or action_required. Local checks stand in, on the merge with main 5fe340acef00. The landed tree is the tested one, 48401e8d1306. They are W=1 clpc.o with and without KUnit (0 warnings; KUnit compiled, not run), run-host-tests.py --only clpc (9/9), dt_binding_check on both bindings, and the J813, J815, J704, J714s and J773g DTBs.
  • The last push was ours (the merge of main), so our approval doesn't satisfy the last-push rule. The review was done by an agent that didn't write that merge.

No new hardware row was needed: the J815 and J714s rows at 90300394b3d3 cover the same driver lines.

#3873 is next; we'll merge main into it.

DjDeveloperr added a commit to m0d16l14n1/linux that referenced this pull request Dec 2, 2026
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>
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:gpu Area from CODEOWNERS (bot) area:platform Area from CODEOWNERS (bot) blast:m5 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-hw-row No hardware row at the PR head (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