Skip to content

J714s: take port-only and wifibt-only SMC wakes as dark wakes (macsmc, dwc3, thunderbolt, ane) - #2231

Merged
DjDeveloperr merged 6 commits into
integration/aurorafrom
djdev/m5-j714s-port-dark-wake
Nov 20, 2026
Merged

DjDeveloperr merged 6 commits into
integration/aurorafrom
djdev/m5-j714s-port-dark-wake

Conversation

@DjDeveloperr

@DjDeveloperr DjDeveloperr commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

On the J714s (M5 Pro), deep sleep is ended early by SMC wakes nobody asked for. They come in two kinds:

  • USB-C_plug alone (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;
  • wifibt alone (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/aurora 136ffac (after #2445, #2077 and #2274 merged):

  1. mfd: macsmc: J714s: USB-C_plug alone is a dark wake.
    • A wake record of exactly that bit is dark. Any other bit, more than one, or none (the RTC alarm) stays a full wake.
    • At most 128 dark wakes in a row, then a full wake.
    • The safety RTC alarm stays armed and is checked at every entry.
    • A lid opened or a button pressed during a dark wake ends it.
    • A dark re-entry waits up to 2 s for the SMC mutex.
    • An external V27 display's skipped replug is owed and made at PM_POST_SUSPEND.
  2. mfd: macsmc: J714s: wifibt alone 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.
  3. usb: dwc3: apple: J714s: keep a host set up again in a dark wake. The PM notifiers run once around the whole dark-wake loop. So a dock-port host that the resume set up again is kept on its USB4 router's tunnel again, or the router's CIO stop refuses the re-entry (-EBUSY).
  4. thunderbolt: apple: keep DP IN admission paused through a dark wake. It reopens at the final wake's PM_POST_SUSPEND.
  5. accel: ane: unblock requests when the ANE refuses a system sleep. The PM rollback gives no PM_POST_SUSPEND to the notifier that refused, so its block stayed set and every request returned -EAGAIN.
  6. mfd: macsmc: J714s: keep the port and radio dark wakes to the J714s. Integration's J716c now has an SMC sleep policy too, and the rule looks its bits up by name, so it would have reached the J716c untested. It now returns unless the wake table is the J714s's. A wake that soc: apple: sleep, mfd: macsmc: T6050: a port's wake with the lid closed is a dark wake #2445's lid-closed port rule already made dark is counted, so the re-entry waits for the SMC as after one of ours.

With #2445. In apple_smc_sleep_wake(), #2445's lid-closed port rule runs first and this series' J714s rule second. In apple_smc_prepare(), #2445's mutex_lock is 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:

  • Thunderbolt DP IN admission could stay closed on a non-T6050 board if a lid-closed dark wake's re-entry is refused before the NHI's .prepare.
  • The dark-wake counters reset only at .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).

  • t12: 9 of 9 sleeps clean, including a full 59-minute hold.
  • t13: a forced dark wake with the dock attached (a stray wifibt wake at 0.68 s) re-entered and held until the RTC alarm, with every device back.
  • Each run had three displays at native modes, 18/18 USB, Wi-Fi/BT, camera and GPU checked after every wake.
  • A 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 as 7.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 composition integration/aurora 4c4cbf0 + #2445 + #2077 + #2274 + this series (same patch-id as this head) + #2521 + #2515, built natively on the M5 as 7.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: 0 at every entry. The final ship candidate (this on integration/aurora de2c296 with #2445, #2077, #2274 and #2521) is gated again on the M5 now.

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
DjDeveloperr force-pushed the djdev/m5-j714s-port-dark-wake branch from 453f6cc to 2ce7730 Compare November 20, 2026 04:23
@DjDeveloperr DjDeveloperr changed the title mfd: macsmc: J714s: take a wake for USB-C_plug alone as a dark wake J714s: take port-only and wifibt-only SMC wakes as dark wakes (macsmc, dwc3, thunderbolt, ane) Nov 20, 2026
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant