Skip to content

soc: apple: t6041-sleep: refuse deep sleep when no SEP can take it - #3670

Merged
RyanTheTide merged 1 commit into
mainfrom
sleep/t6041-sep-guard
Dec 1, 2026
Merged

RyanTheTide merged 1 commit into
mainfrom
sleep/t6041-sep-guard

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

apple_sleep_enclave_stop_all() returns 0 when no enclave has registered a sleep request, so t6041-sleep went on to the commit with the SEP still running. On a Mac Studio (J575c) with no SEP bound, that hung the Mac in the commit instead of sleeping it (7robertodantas, #3421).

The SEP registers its request from its own suspend, so by the platform entry a bound SEP always has one. t6041-sleep now refuses the sleep at that point, while a refusal is still possible, when none is registered: either no SEP is described or its probe failed. It logs refused: no SEP has a sleep request ready. A new apple_sleep_enclave_registered() reads the hook without the lock, as apple_sleep_enclave_stop_all() does, because the entry runs with interrupts off.

This is independent of the J575c series (#3653) and protects every T6041 board. J614c/J616c bind their SEP (&sep_mbox okay), so they register and are unchanged.

Tested:

Risk: two-way · M4 Max (T6041: J614c, J616c, J575c); a plain revert undoes it. Its only effect is a refusal when no enclave registered; a board whose SEP binds sees no change.

apple_sleep_enclave_stop_all() returns 0 when no enclave registered a
sleep request, so t6041-sleep went on to the commit with the SEP still
running. On a J575c with no SEP bound that hangs the Mac in the commit
instead of sleeping it (reported on linux#3421).

The SEP registers its request from its own suspend, so by the platform
entry a bound SEP always has one. Refuse the sleep there, while a refusal
is still possible, when none is registered: no SEP described, or its
probe failed. Boards whose SEP binds (J614c, J616c) are unchanged.

Add apple_sleep_enclave_registered() for it. It reads the hook without
the lock, as apple_sleep_enclave_stop_all() does, since the entry runs
with interrupts off.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Verdict: HOLD at 0d460a7c

Blockers:

  • Hosted CI checks on 0d460a7c are still queued (apple-build, host-tests, PMGR power state KUnit, SEP source checks, KUnit matrix, pr-readiness, pr-text).
  • Exact-head T6041 hardware verification is still pending (as noted in the PR body): refusal path with apple_sep unloaded (confirming refused: no SEP has a sleep request ready and the Mac stays up) and a T6041 positive deep-sleep row (J616c/J614c or J575c at 0d460a7c).

Checked:

  • drivers/soc/apple/sleep.c & include/linux/soc/apple/sleep.h: apple_sleep_enclave_registered() uses !!READ_ONCE(apple_sleep_enclave.stop) (EXPORT_SYMBOL_GPL), safe with interrupts disabled and matching apple_sleep_enclave_stop_all(); #else inline stub returns false.
  • drivers/soc/apple/t6041-sleep.c (t6041_sleep_enter()): placed right after the AXI2AF_DISP_COUNT active check and before spin_table_hold_parked(), so a refusal returns -EBUSY cleanly with no unwind required.
  • No regression risk on T6041 boards whose SEP binds (&sep_mbox okay registers its sleep hook during SEP suspend before t6041_sleep_enter()).
Evidence
  • Diff: +28/-0 across 3 files, 1 commit (0d460a7c9905), DCO present, MERGEABLE on main.
  • Code audit found no correctness or locking blockers; ready to approve once hosted CI completes green and the exact-head T6041 hardware row is posted.

@github-actions github-actions Bot added area:platform Area from CODEOWNERS (bot) blast:m4 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) labels Nov 30, 2026
@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Merge readiness at 0d460a7c: not ready yet

Check Detail
CI at head no failing: host-tests, host-tests, KUnit asahi, KUnit spi-hid-apple, KUnit avd, KUnit ave
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head ok in the PR body at 0d460a7c
Conflicts ok not computed yet
PR text ok Risk: two-way · M4 Max (T6041: J614c, J616c, J575c); a plain revert undoes it. Its only effect is a refusal when no enclave registered; a board whose SEP binds sees no change.

Areas: area:platform

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

@allanclempe

Copy link
Copy Markdown
Contributor

Both rows from the Not yet, on a J616c (M4 Max, macOS 27.2 26B123 stub) at 0d460a7 unchanged: the guard refuses when no SEP is bound and lets a bound SEP's sleep through.

Tree: main 45d7f82 + this PR (0d460a7) + #3687 + #3688 (needed for a T6041 deep sleep to get past device suspend and to wake cleanly on 27.2), nothing else; 7.3.0-1-2.1-ARCH, default command line.

  • apple_sep bound: rtcwake -d rtc1 -m mem -s 15 slept and woke in the same boot (PM: suspend entry (deep) 14:29:25, PM: suspend exit 14:29:42, apple_sep 406600000.sep: the enclave is back from its sleep request); no refusal; 0 failed units.
  • apple_sep not loaded (its module left out for one boot): t6041-sleep 508304000.sleep-controller: refused: no SEP has a sleep request ready at 14:32:56, then sleep refused before the commit: firmware never stopped from the PMP and the GPU and PM: suspend exit; the Mac stayed up, 0 failed units.

Without the guard, the same Mac with no SEP bound stalled in the commit and the watchdog reset it about 6 s after rtcwake. PMU scratch read back after the reset showed the SEP's power word still on at the commit, so this is the case the guard closes.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

@allanclempe: thank you, that's exactly the pair of rows this needed, at the exact head: the refusal with no SEP bound (and the Mac stays up), and a bound SEP's deep sleep going through. The 'without the guard: watchdog reset ~6 s after rtcwake' observation also confirms the failure it closes. I've put your rows in the PR body's Tested section. (Your comment's last paragraph still lists these as pending; I read that as a leftover, since your rows above it cover both.) Noted that T6041 deep on 27.2 also needs #3687 + #3688.

@github-actions github-actions Bot removed the needs-hw-row No hardware row at the PR head (bot) label Nov 30, 2026

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Verdict: MERGE at 0d460a7c after fresh hosted CI.

Checked: The T6041 guard checks the registered SEP hook before parked-CPU hold and irreversible entry. The J616c integration kept this commit unchanged and exercised both sides: bound SEP slept and resumed, and an absent hook refused cleanly with the system still up. The earlier watchdog reset supplies a baseline for the refusal. Keep the #3687/#3688 dependencies on the 27.2 hardware receipt.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Merging at 0d460a7c9905 (B2 merge train, 12-01 merge bar). Approval at this head: aurora-silicon-review[bot]. Row: the hardware row at 0d460a7 that the readiness check found (PR body or comment). CI: linux train L4 = main (after L3) + 34 approved PRs (#3419 dropped: conflicts): Apple driver compile pass, Apple DTBs W=1 pass, planned KUnit ane-boot/clpc/ane-pm/dcp-fabric/dcp-topology/dcp-display/macaudio/asahi/sep all pass, host tests apple-dcp + apple-scaler-recovery pass (the red host-tests on some heads were base failures since fixed on main). The rest of the hosted run is queued behind the backlog. Revert: git revert -m 1 <merge commit>.

@RyanTheTide
RyanTheTide merged commit 0c8962f into main Dec 1, 2026
49 of 64 checks passed
@RyanTheTide
RyanTheTide deleted the sleep/t6041-sep-guard branch December 1, 2026 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:platform Area from CODEOWNERS (bot) blast:m4 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) 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