Repository navigation
soc: apple: sleep: t8103: refuse deep sleep when SEP or AOP is unbound - #3850
Conversation
t8103_sleep_soc previously left gate_coprocs unset, so apple_sleep_gate_failed() accepted suspend-to-RAM even when apple_sep or apple_aop was not loaded or bound. Because both drivers are loadable modules in asahi.config, a boot without either module still ran the S2R commit -- clearing SEP_PG_WAIT over a running SEP or omitting the AOP sleep handshake -- which stalls WFI until the 60 s WD1 commit watchdog cold-resets the SoC. Register apple,sep and apple,t8103-aop as strict refusal gates on t8103_sleep_soc with strict_gate_inventory enabled so apple_sleep_refuse() aborts S2R before offlining CPUs or quiescing displays whenever either coprocessor is missing, unbound, or (for SEP) lacks a registered sleep stop callback. Add KUnit coverage in apple_sleep_test_t8103_gates for the T8103 gate table and refusal conditions. Signed-off-by: Erik Bourget <erik@ebourget.net>
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
KUnit can rerun a suite through debugfs while other users of the SEP sleep callback are active. Pass the prepared state explicitly so tests exercise the refusal gates without clearing, replacing or restoring the live callback. Signed-off-by: DjDeveloperr <hey@djdev.me>
|
Follow-up The existing J313 receipt covers the refusal logic at the previous head. @erikwb, when #3845 is available for the docked build, please repeat the J313 SEP refusal and bound SEP+AOP checks at this head for the merge record. The existing #3845 head f41cc5e already provides the docked PIODMA prerequisite. A batched J313 build containing both heads unchanged is enough for this receipt and can run while the separate J616s control is pending. Please keep the positive bound SEP+AOP check at the late-refusal boundary, since full T8103 resume also resets on baseline. |
DjDeveloperr
left a comment
There was a problem hiding this comment.
The T8103 refusal change at d0b5fa8b9fdc is sound. A missing or unbound SEP or AOP refuses entry before commit. With both bound, the gate also requires SEP's registered stop callback. The KUnit test now supplies that state directly and leaves the live callback alone.
I ran the production inventory and refusal functions in a native host harness across all 18 combinations of SEP and AOP presence/binding and callback registration. Only the fully bound, prepared combination passed, both at the PR head and with the diff applied to main at 6c83a2a64539. The hosted build and host tests passed. The KUnit matrix skipped this suite at this head.
@erikwb, #3845 is on main. On your docked J313 baseline, please record the unbound-SEP refusal and clean unwind, then the bound SEP+AOP pass up to refuse_late, with the candidate SHA. Those two observations cover this change independently of #3359 or a full T8103 wake. Your recorded physical run covers c298b6d01b11.
|
J313 docked retest at
This run did not exercise live AOP unbind or full deep sleep. |
|
Updated the PR description to fix the S2R ordering, clarify what the bound
|
RyanTheTide
left a comment
There was a problem hiding this comment.
Reviewed at d0b5fa8b9fdc (non-author, non-pusher, 12-01 bar).
Registering apple,sep and apple,t8103-aop as strict_unbound refusal gates with strict_gate_inventory = true on t8103_sleep_soc ensures T8103 aborts S2R before commit whenever either coprocessor is unbound or SEP lacks a prepared stop callback. Passing sep_prepared as a parameter to apple_sleep_gate_failed() keeps KUnit off the live SEP callback cleanly. Hosted CI (11 checks) and the exact-head J313 docked retest at d0b5fa8b9fdc both pass.
|
Merging at |
|
Post-merge local check: the merge landed the tree that was tested. Hosted CI ran on the older main
|
What: Add strict
apple,sepandapple,t8103-aoprefusal gates (strict_gate_inventory = true) tot8103_sleep_socindrivers/soc/apple/sleep-t8103.h, with KUnit coverage indrivers/soc/apple/sleep-test.c, so T8103 aborts deep sleep before commit instead of stalling into a 60 s WD1 cold-reset whenapple_seporapple_aopis unloaded or unbound.Tested: J313 (M1 MacBook Air, T8103, docked, firmware 27.2, default kernel command line) at
d0b5fa8b9fdcin a composite trial kernel (origin/maind3de772ac0c1+d0b5fa8b9fdc,#3507,#3332,#3359,#3334/#3410,#3300,#3289, composite807c3bbf2263):3/3bound SEP+AOP dockeddeepS2R wake-resume passes (T8103: AOP bound: DRAM stays up for it,2 coprocessors up and stopped,SEP power state 0x1000270f at the commit,apple_sep: the enclave is back from its sleep request,0WARN/Oops/SError); live unbound AOP (24ac00000.aop) refused-EBUSY(suspend_statsfail+1,aop isn't bound,refused: 1 coprocessors that must stop or gate are still running, GPU/DCP/NHI unwound and dock recovered); live unbound SEP (242400000.sep) refused pre-commit in1.83 swith-EBUSY(refused: SEP has no prepared irreversible sleep request, alongsideaop isn't boundbecause AOP could not be rebound,0WARN/Oops). Neither AOP (unbindETIMEDOUT; rebind fails-ETIME/-62) nor SEP (rebind fails-EBUSY) can be rebound live after unbind; rebooting from that SEP+AOP-unbound state recovered cleanly to the stock daily kernel over SSH in34 s(0failed units). Earlier J313 docked check atd0b5fa8b9fdc(merged into71565fddc90das731692cdd8ec, CalDigit TS5, Aura Stage 21.0.0b18-gd8eb8ad4) also passedapple_sleep.refuse_late=1(1.78 spre-apple_sleep_enclave_stop()unwind) and standalone unbound SEP (1.83 swith AOP bound; an earlier reboot from that SEP-unbound run did not return over SSH and required a power cycle). Host harness atd0b5fa8b9fdc(and applied tomain6c83a2a64539) passed all 18 SEP/AOP/callback combinations; CI (apple-build,host-tests,KUnit plan,pr-text) green atd0b5fa8b9fdc.Risk: two-way door · T8103 (M1) Macs using
apple,t8103-sleep.Not yet: Other T8103 boards (
J274,J293,J456,J457— no hardware on site); note that live unbind/rebind testing is limited to single-boot refusal checks because neither AOP (-ETIME) nor SEP (-EBUSY) supports live rebind after unbind (standalone unbound-SEP refusal with AOP still bound was verified at731692cdd8ec).Details
On T8103,
t8103_sleep_socpreviously leftgate_coprocs = NULL. BecauseCONFIG_APPLE_SEPandCONFIG_APPLE_AOPare loadable modules inarch/arm64/configs/asahi.config, a boot where either module was missing or unbound still committed S2R:apple_sep,apple_sleep_enclave.stopwasNULL,apple_sleep_enclave_stop()returned0, andt8103_sleep_commit_regs()clearedSEP_PG_WAITover a running SEP.apple_aop,t8103_sleep_begin()clearedt->aop_slp_ddrwithout refusing.Changes:
drivers/soc/apple/sleep-t8103.h: addt8103_gate_coprocs[]("apple,sep"and"apple,t8103-aop", both with.strict_unbound = true) and enable.strict_gate_inventory = trueont8103_sleep_soc. Neither entry setsmust_stoporallow_unstarted, soapple_sleep_gate_prepare()(called fromapple_sleep_prepare()) performs no MMIOof_iomap(). Becausesleep_gate_node()usesfor_each_compatible_node(), even a DT wheresep@242400000remainsstatus = "disabled"(beforeapple_sepapplies its OF changeset) resolves asg->sep = true, g->bound = false. Duringapple_sleep_enter()— after secondary CPUs are offlined (pm_sleep_disable_secondary_cpus()) and devices suspend, and beforeapple_sleep_cpus_hold(),display_off(),apple_sleep_enclave_stop(), or S2R commit —apple_sleep_refuse()callsapple_sleep_gate_failed(s, apple_sleep_enclave_registered())and returns-EBUSYcleanly so suspend unwinds.drivers/soc/apple/sleep.c: passsep_preparedexplicitly intoapple_sleep_gate_failed(struct apple_sleep *s, bool sep_prepared)fromapple_sleep_refuse()viaapple_sleep_enclave_registered()so KUnit exercises all gate combinations without mutating the liveapple_sleep_enclavecallback.drivers/soc/apple/sleep-test.c: addapple_sleep_test_t8103_gatesverifyingt8103_sleep_soc's strict gate inventory,apple,sepandapple,t8103-aopentries, andapple_sleep_gate_failed()refusal/pass behavior across missing SEP stop callback, both bound, unbound SEP, and unbound AOP.Evidence
d0b5fa8b9fdc:apple-build,host-tests,KUnit plan,pr-text,readinesspassed atd0b5fa8b9fdc.DjDeveloperr): ran production inventory andapple_sleep_gate_failed()across all 18 combinations of SEP/AOP presence/binding and callback registration; only the bound + prepared case passed, both atd0b5fa8b9fdcand applied tomain(6c83a2a64539).d0b5fa8b9fdcmerged ontoorigin/maind3de772ac0c1with#3507,#3332,#3359,#3334/#3410,#3300,#3289, composite807c3bbf2263, firmware 27.2, docked, default kernel command line):rtcwake -d /dev/rtc1 -m mem -s 20):3/3docked wake-resume passes (T8103: AOP bound: DRAM stays up for it,2 coprocessors up and stopped,SEP power state 0x1000270f at the commit,apple_sep: the enclave is back from its sleep request),0WARN/Oops/SError.24ac00000.aop):rtcwakefailed (rc 1,-EBUSY,suspend_statsfail+1), loggingaop isn't boundandrefused: 1 coprocessors that must stop or gate are still running, with GPU (deep sleep refused before commit), DCPs, and NHI unwinding cleanly and dock returning. The unbind loggedEndpoints did not acknowledge their shutdown within 5000 ms ... Failed to stop AOP ETIMEDOUT, and live rebind fails (RTKit: endpoint discovery failed: -62,-ETIME), leaving AOP unbound until reboot.242400000.sep):rtcwakerefused pre-commit in1.83 s(rc 1,-EBUSY), loggingrefused: SEP has no prepared irreversible sleep request(alongsideaop isn't boundbecause AOP remained unbound),0WARN/Oops. Live SEP rebind fails-EBUSY("the SEP was already booted or registered on this boot ... cannot be repeated"), so neither AOP nor SEP can be rebound live after unbind.34 s(0failed units).DjDeveloperr,d0b5fa8b9fdcmerged into71565fddc90das731692cdd8ec, firmware 27.2, Aura Stage 21.0.0b18-gd8eb8ad4, default kernel command line):apple_sleep.refuse_late=1):apple_sleep_gate_failed()passed (establishing SEP had a prepared sleep request and AOP was bound; the generic2 coprocessors up and stoppedlog does not establish physical stop because neithert8103_gate_coprocsentry setsmust_stop) and entry reachedrefuse_latebeforeapple_sleep_enclave_stop(), returning-EBUSYin1.78 sand unwinding cleanly.242400000.sepunbound while AOP stayed bound): missing prepared SEP request refused pre-commit in1.83 s(refused: SEP has no prepared irreversible sleep request) on the same boot;0WARN/SError/Oops,0failed units; dock display and Ethernet recovered after each unwind. (Rebooting from that earlier run did not return over SSH and required a power cycle; the subsequentd0b5fa8b9fdccomposite run recovered over SSH in34 s.)c298b6d01b11(identical runtime T8103 gate tables indrivers/soc/apple/sleep-t8103.h):scripts/checkpatch.pl --strict --git HEAD:0 errors, 0 warnings, 0 checks, 132 lines checked.make ARCH=arm64 LLVM=1 W=1 KCFLAGS="-Werror" drivers/soc/apple/sleep.o(withCONFIG_APPLE_SOC_SLEEP_KUNIT_TEST=y):0warnings,0errors.kunit.py run --arch arm64 --make_options LLVM=1 ... apple-sleep-soc-data):17/17passed, includingapple_sleep_test_t8103_gates.1.0.0b18-gd8eb8ad4, default kernel command line) on batched test merge ofc298b6d01b11+#3845(f41cc5ef9c47):echo 242400000.sep > /sys/bus/platform/drivers/apple_sep/unbind, thenrtcwake -d /dev/rtc1 -m mem -s 10):RTCWAKE_RC=1 ELAPSED=2s, loggedrefused: SEP has no prepared irreversible sleep requestandrefused: 1 coprocessors that must stop or gate are still running, unwound cleanly (PM: suspend exit).apple_sleep.refuse_late=1): logged2 coprocessors up and stopped(gate-pass log confirming SEP prepared + AOP bound, not physical stop) andtest: refused at the last check (refuse_late)beforeapple_sleep_enclave_stop(), unwound cleanly (0failed units,eDP-1+DP-2connected).