Skip to content

thunderbolt: apple: T6020 deep sleep with a router attached - #3569

Merged
RyanTheTide merged 2 commits into
aurora-silicon:mainfrom
muness:feat/t6020-dock-deep-sleep
Dec 1, 2026
Merged

RyanTheTide merged 2 commits into
aurora-silicon:mainfrom
muness:feat/t6020-dock-deep-sleep

Conversation

@muness

@muness muness commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Takes effect with: #3336 . Safe to merge before it: until then only the router stop before reboot changes. The external displays also need their DCPs idled and warm-restarted across the sleep: JJRPF/Aurora-DeepIdle#15, which moves with the T6020 sleep port.

What: T6020 deep sleep removes the CIO power domains, and the ATC PHY is shared with DWC3, as on T8103. This gives T6020 the T8103 deep-sleep port handling from #3178 (thanks @erikwb). It also releases the displays behind the port before the router, as T6050 does, now selected by a hardware flag.
Tested: J414c M2 Max (T6021) at d213952 (its kernel code is d536afe's; d213952 adds only the host test), on the J414c sleep stack, Surface TB4 dock with two external displays: 2 deep sleeps at default switches, 2 more with s2r_ext_keep_hpd=1. After every wake: both external displays lit, dock Ethernet and 24 USB devices back, 0 warnings. The same kernel as the everyday -41 and -46 kernel: 0 failed units, no new kinds of kernel errors, and a docked systemctl suspend deep sleep that brought back both external displays, the dock's USB and both Ethernet adapters. At d536afe on main (7.3.0-pr3569+ with the -46 userspace and the stock Aura b17 Stage 2): 2 of 2 boots with 0 failed units, Touch ID restored, and the dock and both external displays working once the dock was replugged (see the last sentence). Both of those boots logged an SIO crash when DisplayPort audio started. The sleep stack logged it in 1 of 8 boots and stock -46 in neither of 2; this change has no code on that path. On this Mac a dock left plugged in across a reboot often needs a replug, with or without this change, and also after an emergency restart that skips its reboot handler.
Risk: two-way door · M2 Pro/Max/Ultra (apple,t6020-usb4-acio). On main, T6020 sleeps in s2idle, so only the router stop before a reboot changes there. The sleep handling acts once T6020 deep sleep lands (#3336).
Not yet: J414s and T6022.

Details
  • apple_cio_t6020_hw gets the T8103 flags: sleep_removes_domains, restart_on_wake, phy_shared_with_dwc3, stop_at_reboot, sleep_router_on_stop. psd_power_cycle is left off: with it, the second sleep of a run took 17 s instead of 10, two DP commands timed out, and the dock's Ethernet came back after only one of the two wakes.
  • New sleep_displays_first flag: apple_cio_sleep_teardown() releases the displays before the router, the same as the T6050 path. T6020 sets it. When the displays were released with the NHI instead, the second display stayed dark after the second sleep.
  • The two messages in apple_cio_sleep_release_displays() no longer say "T6050".
Evidence

The kernel is the J414c sleep stack (aurora 7.3 8ca67c75, JJRPF's T6020 S2R diff, the J414c pieces, the PSCI conduit) with drivers/thunderbolt from main 37a9d68 and this commit. Its apple.c is identical to d536afe. The other Thunderbolt files add only progress markers and a 5 s domain-lock guard, which never fired. The external display processors are given A500, idled, and restarted across the sleep. All switches are at their defaults. Each run is a RAM-root boot: dock up, all displays lit, two 15 s RTC sleeps, checks after each wake.

Run Switches Wakes Displays lit after each wake (of 3, internal included) Dock after each wake External DCP restarts Warnings / DP timeouts
XC none 2 3, 3 eth0 + 24 USB, eth0 + 24 USB 8 / 8 0 / 0
XB appledrm.s2r_ext_keep_hpd=1 2 3, 3 eth0 + 24 USB, eth0 + 24 USB 8 / 8 0 / 0

A third run (XA) started with the dock's USB down after a reboot from a kernel without this commit, and needed a manual replug, so it is left out.

Desktop boot on the same kernel (Omarchy, mem_sleep_default=deep): 0 failed units; 15 kernel error lines against 16 on the previous kernel, none of a new kind; no WARNING:. One systemctl suspend with the dock attached:

PM: suspend entry (deep)
thunderbolt-apple-acio f01ac0000.cio: sleep: 2 display request(s) behind this port ended in 152 ms, before the router (DP IN 0x3)
thunderbolt-apple-acio f01ac0000.cio: powering off port for system sleep (cable info 0x13)
thunderbolt-apple-nhi f01f00000.nhi: CIO controller sleep state 0x2000000: 0
macsmc-input macsmc-input: lid open 72030001 at +15553 ms in sleep, MSLD=0: wakeup
PM: suspend exit
thunderbolt-apple-acio f01ac0000.cio: restarting port after system sleep
thunderbolt 0-1: Microsoft Surface Thunderbolt(TM) 4 Dock
apple-dcp 289c00000.dcp: display routed to Thunderbolt DP tunnel dpin0
apple-dcp 315c00000.dcp: display routed to Thunderbolt DP tunnel dpin1
r8152 2-1.4.4:3.0 enu1u4u4c3: carrier on

Flag A/B from the earlier runs, with the same flags behind a test parameter:

Run Flags Displays lit after each wake Dock Ethernet back DP timeouts
WB T8103 set + displays first 3, 3 both wakes 0
WC T8103 set, displays with the NHI 3, 2 neither 0
WD WB + psd_power_cycle 3, 3 one wake 2

T6020 deep sleep removes the CIO power domains, and the ATC PHY is shared
with DWC3, as on T8103. Use the T8103 handling: tear a connected router
down before tasks freeze, ahead of DWC3's PM notifier, with the router in
ACIO sleep before its domains go; restart the port at once after the wake;
stop a started router before reboot.

Release the displays behind the port before the router, as T6050 does, and
make that a hardware flag. With the displays released from the router's
teardown instead, a dock's second display stayed dark after the second of
two sleeps.

Signed-off-by: Muness Castle <[email protected]>
T6020 now tears its router down for deep sleep and releases its displays
first. Check its flags and that deep sleep removes its domains while
s2idle and freeze keep them, and add negative controls for the two flags
that decide its sleep handling.

Signed-off-by: Muness Castle <[email protected]>
@muness
muness requested a review from DjDeveloperr as a code owner November 29, 2026 00:41

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: MERGE at d213952f once the fork PR's CI workflows are approved and pass.

Blockers: none in code (await fork CI workflow approval and green checks).

Checked: Full 2-file diff (drivers/thunderbolt/apple.c, tools/asahi/pciec-policy-tests.py), apple_cio_t6020_hw flag alignment with T8103/T6050 deep-sleep paths, apple_cio_sleep_teardown() ordering, policy test coverage, and exact-head J414c (T6021 M2 Max) docked deep-sleep verification.

Evidence
  • Driver (drivers/thunderbolt/apple.c):
    • Adds .sleep_displays_first = true to struct apple_cio_hw and populates apple_cio_t6020_hw with the T8103 deep-sleep flag set (.sleep_removes_domains, .restart_on_wake, .phy_shared_with_dwc3, .stop_at_reboot, .sleep_router_on_stop) plus .sleep_displays_first = true.
    • Generalizes apple_cio_sleep_teardown() to acio->hw->sleep_displays_first || (acio->hw->has_usb4_cio && acio->hw->sleep_removes_domains) so T6020 puts display paths to sleep before tearing down the router and its power domains, while leaving T8103/T6000/T6050 behavior unchanged. Drops the T6050-only prefix on the teardown log message.
  • Policy tests (tools/asahi/pciec-policy-tests.py):
    • Asserts all new apple_cio_t6020_hw flags and the generalized apple_cio_sleep_teardown() condition, and adds two negative mutation tests (t6020-drop-sleep-removes-domains, t6020-drop-displays-first) verifying the test catches regressions.
  • Verification at d213952f: J414c (M2 Max / T6021) docked to a Surface TB4 dock with 2 external displays, Ethernet, and 24 USB devices passed 4 consecutive s2idle deep sleeps (with full CIO_USB4 router re-enumeration, display restoration, and clean networking/USB recovery) plus main boot regression check. Both commits carry valid human Signed-off-by lines.

@RyanTheTide

Copy link
Copy Markdown
Contributor

code-owner ping <@422957901716652033> / @DjDeveloperr: merge train at d213952f. App approved (NEON-PR-REVIEW2), J414c (T6021) row with a TB4 dock PASS. apple_cio_sleep_teardown() is now shared by every CIO Mac with deep sleep, so it needs one more family at this head (e.g. J316s or J616s: deep sleep x3 with and without a USB4 peer, devices back). Merges under the 6-point rule after that and green CI, unless you object.

@github-actions github-actions Bot added area:gpu Area from CODEOWNERS (bot) area:usb Area from CODEOWNERS (bot) blast:m2 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 29, 2026
@github-actions

github-actions Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

Merge readiness at d213952f: not ready yet

Check Detail
CI at head running running: KUnit asahi, KUnit spi-hid-apple, KUnit avd, KUnit ave, KUnit isp, KUnit jpeg
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head ok in the PR body at d213952f
Conflicts ok not computed yet
PR text ok Risk: two-way · M2 Pro/Max/Ultra (apple,t6020-usb4-acio). On main, T6020 sleeps in s2idle, so only the router stop before a reboot changes there. The sleep handling acts once T6020 deep sleep lands (#3336).

Areas: area:gpu, area:usb

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Merging at d213952fee30 (B2 merge train, 12-01 merge bar). Approval at this head: aurora-silicon-review[bot]. Row: in the PR body at d213952. CI: linux train L2 = main (after train L1) + #1489 #3223 #3291 #3333 #3395 #3407 #3547 #3560 #3651 #3684 #3569 #3599 (candidate dd0c7bb9): Apple driver compile pass, Apple DTBs W=1 pass, planned KUnit ane-boot/clpc/ane-pm/dcp-topology/ave/asahi all pass; host-tests/dt-checks green at this head where they apply. The rest of the hosted run is queued behind the backlog. Revert: git revert -m 1 <merge commit>.

@RyanTheTide
RyanTheTide merged commit cc9b3d3 into aurora-silicon:main Dec 1, 2026
19 of 21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:gpu Area from CODEOWNERS (bot) area:usb Area from CODEOWNERS (bot) blast:m2 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants