Repository navigation
soc: apple: t6041-sleep: refuse deep sleep when no SEP can take it - #3670
Conversation
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>
There was a problem hiding this comment.
Verdict: HOLD at 0d460a7c
Blockers:
- Hosted CI checks on
0d460a7care 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_sepunloaded (confirmingrefused: no SEP has a sleep request readyand the Mac stays up) and a T6041 positive deep-sleep row (J616c/J614corJ575cat0d460a7c).
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 matchingapple_sleep_enclave_stop_all();#elseinline stub returnsfalse.drivers/soc/apple/t6041-sleep.c(t6041_sleep_enter()): placed right after theAXI2AF_DISP_COUNTactive check and beforespin_table_hold_parked(), so a refusal returns-EBUSYcleanly with no unwind required.- No regression risk on T6041 boards whose SEP binds (
&sep_mboxokay registers its sleep hook during SEP suspend beforet6041_sleep_enter()).
Evidence
- Diff:
+28/-0across 3 files, 1 commit (0d460a7c9905), DCO present,MERGEABLEonmain. - 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.
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
|
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;
Without the guard, the same Mac with no SEP bound stalled in the commit and the watchdog reset it about 6 s after |
|
@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. |
There was a problem hiding this comment.
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.
|
Merging at |
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 newapple_sleep_enclave_registered()reads the hook without the lock, asapple_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_mboxokay), so they register and are unchanged.Tested:
LLVM=1 W=1build ofdrivers/soc/apple/sleep.oandt6041-sleep.oon main 498d53f: no warnings.checkpatch --strict: 0/0/0.apple_sepbound (7robertodantas' row on M4 Max Studio (J575c) deep sleep, one series: SEP, sleep host, PCIe/SMC/display wiring, SEP guard #3666), so the guard didn't refuse a sleep that should go ahead.apple_sepbound, deep sleep + RTC wake went through in the same boot (the enclave is back from its sleep request, no refusal). Withapple_sepnot loaded:refused: no SEP has a sleep request ready, PM exit, the Mac stayed up, 0 failed units. Without this guard the same Mac stalled in the commit and the watchdog reset it ~6 s after rtcwake (SEP power word still on at the commit).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.