Repository navigation
thunderbolt: apple: T6020 deep sleep with a router attached - #3569
Conversation
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]>
There was a problem hiding this comment.
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 = truetostruct apple_cio_hwand populatesapple_cio_t6020_hwwith 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()toacio->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.
- Adds
- Policy tests (
tools/asahi/pciec-policy-tests.py):- Asserts all new
apple_cio_t6020_hwflags and the generalizedapple_cio_sleep_teardown()condition, and adds two negative mutation tests (t6020-drop-sleep-removes-domains,t6020-drop-displays-first) verifying the test catches regressions.
- Asserts all new
- Verification at
d213952f: J414c (M2 Max /T6021) docked to a Surface TB4 dock with 2 external displays, Ethernet, and 24 USB devices passed 4 consecutives2idledeep sleeps (with fullCIO_USB4router re-enumeration, display restoration, and clean networking/USB recovery) plusmainboot regression check. Both commits carry valid humanSigned-off-bylines.
|
code-owner ping <@422957901716652033> / @DjDeveloperr: merge train at |
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
|
Merging at |
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 dockedsystemctl suspenddeep sleep that brought back both external displays, the dock's USB and both Ethernet adapters. At d536afe onmain(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_hwgets the T8103 flags:sleep_removes_domains,restart_on_wake,phy_shared_with_dwc3,stop_at_reboot,sleep_router_on_stop.psd_power_cycleis 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.sleep_displays_firstflag: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.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/thunderboltfrom main 37a9d68 and this commit. Itsapple.cis 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.appledrm.s2r_ext_keep_hpd=1A 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; noWARNING:. Onesystemctl suspendwith the dock attached:Flag A/B from the earlier runs, with the same flags behind a test parameter:
psd_power_cycle