Repository navigation
J714s: take port-only and wifibt-only SMC wakes as dark wakes (macsmc, dwc3, thunderbolt, ane) - #2231
Merged
Conversation
On the J714s the SMC wakes the AP for USB-C_plug alone (MBSW bit 42) about 31 s into many deep sleeps when a display, a dock and a charger are on the ports: 36 of 45 sleeps on one day, with no cable plugged or pulled and nothing changed on any port afterwards. Every such wake is a full one: user space thaws, the displays light, and a lid that stayed closed is put back to sleep only after logind's holdoff, so the machine spends about as long awake as asleep, and with the lid open it stays awake. The PM core already sends a dark wake back to sleep with user space frozen, and the DRM, display, Type-C and lid drivers already keep their outputs off and their events for such a wake. Set it here for a wake the SMC recorded for USB-C_plug and nothing else. Any other bit (the lid, the power button, the keyboard and trackpad, another plug or charger reason, or one the table doesn't name) or none at all (the PMU's RTC alarm) stays a full wake, and so does the wake after 128 dark ones in a row. The safety alarm the sleep was admitted with stays armed: the sleep controller checks it at every entry and refuses one too close to it, which ends the run with a full wake. A lid opened or a button pressed during a dark wake also ends it, as before. Each dark wake is logged with the time asleep before it. Two things the first runs showed are part of making it work. The entry right after a dark wake found the SMC's command mutex held, the notification of the event that woke it still being handled, and the prepare's trylock refused it: a dark wake's re-entry now waits for the mutex and a pending saved command, at most 2 s; a sleep a user asks for still doesn't wait. And that refused re-entry left an external display on a J714s V27 DCP unplugged: its wake replug is skipped on a dark wake, and when no resume follows (the re-entry refused) nothing made it. The skipped replug is now owed and made at PM_POST_SUSPEND. Signed-off-by: Diljit Singh <hey@djdev.me>
On the J714s the SMC sometimes wakes the AP for wifibt alone (MBSW bit 13, the N1 radio) within about a second of the entry: 7 of 189 recorded wakes on 11-15 to 11-19, on six kernels, six of them in the first or second sleep after a boot. Nothing armed it. The N1's drivers offer no WoWLAN and take the Bluetooth controller down for the sleep, and the radio is reset before every sleep. Such a wake ended the sleep, so a reboot followed by a lid close often woke again at once. macOS gets the same SMC wake and takes it as a DarkWake (its pmset logs: "DarkWake from Deep Idle ... wifibt SMC.OutboxNotEmpty"); neither OS writes an SMC wake mask around the sleep. Do the same: on the J714s a wake whose SMC record is wifibt alone is a dark wake, as one for USB-C_plug alone already is. The system sleeps again with user space frozen and the outputs off. Each re-entry resets the radio again, so at most 8 wifibt dark wakes come in a row, then a full wake, inside the existing limit of 128 dark wakes. Any other bit, more than one, or none (the RTC alarm) stays a full wake, and the field counting the dark wakes is named for both reasons now. When a radio wake can be armed (WoWLAN or a Bluetooth wake), a wake for it must be a full one again; none can be today. Signed-off-by: Diljit Singh <hey@djdev.me>
…the next sleep A dark wake (pm_set_dark_wake()) sleeps again with user space frozen through suspend_devices_and_enter() alone: the PM notifier chain runs once around the whole loop. On the J714s, the dock port's USB host is kept on its USB4 router's USB3 tunnel for the router's sleep from the PM_SUSPEND_PREPARE notifier's work (dwc3_apple_tunnel_keep()). When the PHY lost the core in the firmware sleep, the resume sets it up again with its PIPE on the tunnel; at the dark wake's re-entry nothing kept it, the router's host had nothing to park, and the PHY's CIO stop refused (-EBUSY), so the NHI's noirq suspend refused the sleep and the dark wake became a full one about 14 s later (2 of 2 on 11-19). Keep the host again in the resume that set it up, when the wake is a dark one. If that is not possible the re-entry is refused as before. Signed-off-by: Diljit Singh <hey@djdev.me>
The NHI's .complete reopens DP IN admission (apple_dpin_resume_retries()) after every resume, including a dark wake's, which sleeps again at once with the outputs off; .prepare pauses it again for the re-entry. Leave it paused through the dark gap: the final wake's PM_POST_SUSPEND reopens it as before. The pause is idempotent. Signed-off-by: Diljit Singh <hey@djdev.me>
At PM_SUSPEND_PREPARE the H17 backend blocks new work (in_sleep, session.wake_blocked) and unblocks it at PM_POST_SUSPEND. When it refuses the sleep itself (NOTIFY_BAD), the PM core's rollback gives PM_POST_SUSPEND only to the notifiers called before it, so the block stayed set and every request returned -EAGAIN until a later sleep completed. Undo the block on the refusal. Signed-off-by: Diljit Singh <hey@djdev.me>
DjDeveloperr
force-pushed
the
djdev/m5-j714s-port-dark-wake
branch
from
November 20, 2026 04:23
453f6cc to
2ce7730
Compare
apple_smc_dark_wake() runs for every board with an SMC sleep policy, and the J716c has one too. It looks its two bits up by name, so on the J716c a USB-C_plug-only or wifibt-only wake would also go dark, on a board where that was never chosen or tested. Return early unless the wake table is the J714s's. A port's wake with the lid closed is now made dark before this runs (apple_sleep_port_wake()). Count such a wake too, so the re-entry after it waits for the SMC as it does after one of this function's own; leave its log line and its decision to that rule. Signed-off-by: Diljit Singh <hey@djdev.me>
DjDeveloperr
force-pushed
the
djdev/m5-j714s-port-dark-wake
branch
from
November 20, 2026 05:50
2ce7730 to
18b4933
Compare
DjDeveloperr
marked this pull request as ready for review
November 20, 2026 05:50
This was referenced Nov 20, 2026
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 the J714s (M5 Pro), deep sleep is ended early by SMC wakes nobody asked for. They come in two kinds:
USB-C_plugalone (MBSW bit 42), about 31 s into many sleeps with a display, a dock and a charger on the ports: 36 of 45 sleeps on 2026-11-18;wifibtalone (bit 13), within about a second of the entry, mostly in the first sleep after a boot: 7 of 189 recorded wakes.macOS takes SMC wakes like these as DarkWakes and goes back to sleep without lighting anything. This series does the same through the PM core's existing dark-wake path, and fixes what a dark re-entry with the USB4 dock attached ran into.
Six commits, on
integration/aurora136ffac (after #2445, #2077 and #2274 merged):USB-C_plugalone is a dark wake.PM_POST_SUSPEND.wifibtalone is a dark wake. At most 8 in a row, inside the 128 limit. A wake for an armed radio source must be full again once one can be armed; none can today.PM_POST_SUSPEND.PM_POST_SUSPENDto the notifier that refused, so its block stayed set and every request returned -EAGAIN.With #2445. In
apple_smc_sleep_wake(), #2445's lid-closed port rule runs first and this series' J714s rule second. Inapple_smc_prepare(), #2445'smutex_lockis kept. This series' bounded wait stays at.suspend(apple_smc_sleep_prepare()).Only J714s code paths change, except commit 5, which fixes a refusal path for every H17 ANE.
Reviews (independent): both found the J716c reach, which commit 6 fixes. Non-blocking follow-ups:
.prepare..complete.Hardware. These commits, unchanged before the rebase, have been in the M5's default kernel since 2026-11-19 15:50 (
7.3.0-m5-intg26).wifibtwake at 0.68 s) re-entered and held until the RTC alarm, with every device back.USB-C_plug-only dark wake has not recurred on hardware since 11-18.The rebased composition (
integration/aurora+ #2445 + #2077 + #2274 + this) is being gated on the M5 as7.3.0-m5-intg28. Results follow here.Known issue (not this series): about 1 in 10 sleeps entered within a minute after a Type-C event on the Dell's port hangs before the commit, and the watchdog resets the machine. It is being traced separately.
🤖 Generated with Claude Code
Hardware gate (2026-11-20 00:32-00:48,
ship28c2): the compositionintegration/aurora4c4cbf0 + #2445 + #2077 + #2274 + this series (same patch-id as this head) + #2521 + #2515, built natively on the M5 as7.3.0-m5-intg28c, passed 3 of 3 real logind deep sleeps (60 s RTC alarm). Every wake was clean: Wi-Fi/BT back, three displays at native modes, 20/20 USB, audio card and amps with no latched fault, camera 90/90, AOP/ALS, Vulkan 8/8 with no GPU fault,PMP request withdrawn: 0at every entry. The final ship candidate (this onintegration/aurorade2c296 with #2445, #2077, #2274 and #2521) is gated again on the M5 now.