Repository navigation
apple-sleep: don't let the debug link's cut wake the sleep (debug rig only) - #1374
Closed
DjDeveloperr wants to merge 7 commits into
Closed
DjDeveloperr wants to merge 7 commits into
DjDeveloperr wants to merge 7 commits into
Conversation
On a debug cable, the sleep driver cold-resets the debug port's controller in the SMC's noirq suspend, to end the KIS link. The SMC takes that as a cable pulled and plugged back. It had been warned of the sleep (MBSE = slpw) at .prepare, and it woke the AP right after the commit for USB-C_plug or acdetach. On a J700, 223 of 223 sleeps that sent the reset woke 0.15 to 0.27 s after the commit, with the RTC alarm 10 to 19 s away, though the outbox had been quiet for 500 ms before the AP idle notice. All 154 sleeps that sent no reset ran to their alarm. macOS never resets a port controller around a sleep, and writes nothing to the SMC then but MBSE and the AP power notices. So when the debug link is up at .prepare, warn the SMC in the noirq suspend instead, after the cut and its events, and leave macOS's shortest measured gap, 770 ms, before slpa. A sleep without a debug cable is unchanged. Signed-off-by: Diljit Singh <hey@djdev.me>
…pened A dark wake for a closed lid sleeps again, and .prepare refuses that sleep if the lid reads open by then: the user opened it. A dark wake can also come with the lid open, for the debug link's cut on a debug cable. The lid reads open at .prepare there too, and the sleep would be refused for a lid that never moved. Note at the dark wake whether the lid was closed, and refuse only then. A failed read keeps the old behaviour. Signed-off-by: Diljit Singh <hey@djdev.me>
A dark wake sleeps again with user space still frozen. Rearming the debug link in its .complete brought KIS back, and the next entry cut it again, so a wake for the cut's own events would come again. Keep the rearm pending until a wake that isn't dark. The setup after the cold reset still runs. Signed-off-by: Diljit Singh <hey@djdev.me>
…as a dark wake If the SMC still wakes the AP for the cut's own events, sleep again through the PM core's dark wake, as for a lid closing. That needs all three: only the SMC's AIC sources woke the SoC, the wake record has nothing but acattach, acdetach or USB-C_plug, and this sleep sent the reset. The link then stays down, so the next entry doesn't cut it, and runs to its alarm like the 154 J700 sleeps that sent no reset. Any other source or reason gives a normal wake. Without a debug cable there is no cut, so a charger plugged in during the sleep wakes the machine as before. Signed-off-by: Diljit Singh <hey@djdev.me>
…ug-cut-wakes Brings in #1208's aop-bootargs host test fix. No conflicts. Signed-off-by: Diljit Singh <hey@djdev.me>
Signed-off-by: Diljit Singh <hey@djdev.me>
This was referenced Nov 9, 2026
Closed
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On a debug cable, the sleep driver cold-resets the debug port's controller to end the KIS link. The SMC takes that as a cable pulled and plugged back. On a J700 it woke the AP right after the commit in all 223 retained sleeps that sent the reset, with
USB-C_plugoracdetachin MBSW. All 154 sleeps without the reset ran to their alarm. Without a debug cable there's no link and no cut, so this only affects the rig.slpw) only after the cut, with macOS's 770 ms beforeslpa.acattach/acdetach/USB-C_plug, and this sleep sent the reset. For it, macsmc-input refuses the next sleep only for a lid that opened, and tipd rearms the link only at a full wake.No wake source is masked. These are the random-wakes lane's four patches, written against #1313, ported to the generic
apple-sleepdriver.Untested on hardware.
🤖 Generated with Claude Code