Repository navigation
thunderbolt, phy, drm/apple: support T8103 USB4 dock and DCPEXT deep sleep - #3178
Conversation
Add an apple,t8103-dcpext match entry with map_reg_dart, s2r_ext, s2r_disp_dart_with_dcp, and DISPEXT0 power words (0x378/0x368), and add apple,display-power on t8103's dcpext node. Without map_reg_dart, firmware 27.2 faults on stream 0 writing disp-4 (0x23b3d0000) during its first external display power-down and crashes DCPEXT. Generalize the s2r_ext domain/power-word helpers to key on hw.s2r_layout and hw.s2r_ext instead of a SoC compatible check, restore disp_dart streams on s2r_ext_start when s2r_disp_dart_with_dcp is set, and gate firmware 27.0 s2r_ext on hw.s2r_untested so T8142 keeps its existing opt-in while T8103 works with the default command line. Signed-off-by: Erik Bourget <[email protected]>
Like T8122, T8103 deep sleep cuts power to the CIO/ATC domains and shares the ATC PHY with DWC3. Set sleep_removes_domains, restart_on_wake, and phy_shared_with_dwc3 on apple_cio_t8103_hw so mem_sleep=deep tears down an attached router ahead of DWC3's PM notifier and requests fresh cable state on wake, while s2idle and freeze leave the port up unchanged. Update tools/asahi/pciec-policy-tests.py to cover T8103 alongside T8122. Signed-off-by: Erik Bourget <[email protected]>
igc_remove() unregisters its netdev and disables the PCI device without touching the PM notifier chain, so it is safe to remove during PM_SUSPEND_PREPARE when deep sleep powers down a USB4/Thunderbolt router (such as a CalDigit TS5 dock carrying an Intel I225-LMvP NIC). Signed-off-by: Erik Bourget <[email protected]>
…king tunables T8103 USB4 PCIe-C DARTs receive apple,tunable entries from the bootloader that do not set DART_T8020_CONFIG_LOCK. Check whether any tunable entry actually sets the lock bit instead of rejecting any non-NULL dart->tunables in apple_dart_save_tunnel_state() and apple_dart_restore_tunnel_state(), and reapply dart->tunables after apple_dart_hw_reset() on restore. Signed-off-by: Erik Bourget <[email protected]>
dwc3_apple_host_start() binds xhci-hcd synchronously under appledwc->lock and returns -EPROBE_DEFER if no driver binds it before platform_device_add()/device_attach() returns. When CONFIG_USB_XHCI_PLATFORM=m, the first USB host plug-in after boot raced ahead of udev loading xhci-plat-hcd and failed with -517. Declare MODULE_SOFTDEP("pre: xhci_plat_hcd") so xhci-plat-hcd is loaded before dwc3-apple.
Signed-off-by: Erik Bourget <[email protected]>
…eboot On T8103, powering off ps_atc*_cio while the ACIO host router firmware is still active (M3_STAT=0x01000000) triggers an immediate SoC reset. Similarly, rebooting with a started router leaves the router running while PCIe-C and DART shutdown callbacks tear down its devices, causing a panic in apple_dpin_irq_dispatch(). Add a sleep_router_on_stop hardware flag and enable it along with psd_power_cycle and stop_at_reboot on apple_cio_t8103_hw: - Put the host router into ACIO sleep via apple_nhi_cio_router_sleep() (M3_STAT=0x02000000) before removing NHI children. - Detach and flush the RTKit mailbox via apple_rtkit_mailbox_off() before freeing the RTKit instance. - Release and synchronously suspend ACIO power domains in reverse order. - Register the reboot notifier so a started router is stopped cleanly before reboot. Signed-off-by: Erik Bourget <[email protected]>
T8103 deep sleep powers off ps_atc*_common behind genpd's back, wiping the ATC PHY register state and clearing PIPEHANDLER_DUMMY_PHY_EN in PIPEHANDLER_NONSELECTED_OVERRIDE. Without restoring the tracked PHY mode on wake, restarting the ACIO router on an unconfigured PHY resets the SoC; without re-enabling the dummy PIPE backend when parking the PIPE, the subsequent USB4 PIPE handoff fails to lock and tunneled USB3 fails to enable. Add a sleep_drops_common flag to atcphy_hw and enable park_dummy_phy, restore_after_pd_off, and sleep_drops_common on atcphy_hw_t8103 so resume marks pd_was_off, re-enables the dummy PIPE when parking, and restores the tracked PHY mode before consumers restart. Signed-off-by: Erik Bourget <[email protected]>
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Verdict: FINISH, then merge at dbb7b44b3d99
Blockers:
drivers/thunderbolt/apple.c:3241: A router sleep error is logged and discarded. It can happen before the sleep request is sent, yetapple_cio_stop()still drops the power domains at line 3487. The new comment at line 3266 describes a T8103 SoC reset if the router is still active. Keep the domain powered until sleep succeeds or a safe fallback takes over. Return the error to the existing suspend notifier and unwind any tunnel state already changed.- The J313 dock run covers T8103. The shared DART, PCIe, and DWC3 paths still need a dock suspend and resume result on a second generation.
Checked: The successful path orders router sleep before NHI removal and power-off. The DART change retains the lock check and reapplies tunables before restoring streams.
… not sleep On T8103 the ACIO host router must be in ACIO sleep before ps_atc*_cio is powered off: dropping the domain with the router firmware still active resets the SoC. apple_cio_sleep_router_for_stop() logged a failed sleep request and apple_cio_stop() went on to remove the NHI and release the domains anyway. The request can fail before anything is sent to the router (no VSE capability, a failed config read or write) or after it (the controller never reports the sleep state). Return the sleep error and let each caller of apple_cio_stop() say what happens to a router that stays awake: - System sleep and cable changes keep the port up as it was: the NHI, the co-processor and the domains stay, PCIe-C admission reopens and a PCIe tunnel that was requested is restored, as after a tunnel teardown. The suspend notifier gets the error and refuses the sleep; the peer state recorded for the restart is committed only once the port is off. A refused unplug is retried on the next cable change. - A reboot or power-off removes the children but keeps the co-processor and the domains powered until the platform reset. - The unwind of a failed start and driver removal still power off: the start frees the co-processor, and removal detaches the domains with the device. A started port whose NHI is gone cannot send the request either, so that is reported as -ENODEV instead of being treated as asleep. Add a host test of apple_cio_stop() and apple_cio_remove_children() for each case, with negative controls, to pciec-policy-tests.py. Signed-off-by: Erik Bourget <[email protected]>
|
Note 🤖 Claude Opus 5.5 responding on behalf of erikwb @DjDeveloperr Blocker 1 is fixed in
Tested on the J313 at
|
|
Note 🤖 Claude Opus 5.5 responding on behalf of erikwb Blocker 2: second-generation dock row added at head
The three shared changes cannot run on T6050 or T8132, so this row shows no regression on a second generation but does not run them:
All three run on T8103, which the J313 rows in the PR body cover. A row that runs the |
Superseded by the review at ff817bf
DjDeveloperr
left a comment
There was a problem hiding this comment.
Verdict: approve at ff817bf9845c. Both blockers from my earlier review are resolved, so I'm dismissing it.
Blocker 1 (router sleep error ignored): fixed in ff817bf9845c.
apple_cio_sleep_router_for_stop()now returns the error. A started port with no NHI is reported as-ENODEV, not as asleep.apple_cio_stop()/apple_cio_remove_children()take an explicit choice of what to do with a router that stays awake:- System sleep and cable changes (
KEEP): nothing is removed. PCIe-C admission reopens and a requested tunnel is restored.apple_cio_sleep_teardown()returns the error, so the sleep is refused. The peer state is committed only after the port is off. - Reboot and power-off (
HOLD): the children go, but the co-processor and the domains stay powered until the reset. - Start unwind and driver removal (
FORCE): these still power off, and the reason is written down in the comments.
- System sleep and cable changes (
- The J313 run with an injected sleep failure shows the refusal path in practice:
refusing system sleep ... (-5), no reset, and the dock, DP and 2.5GbE stayed up. A real S2R on the same boot then succeeded. The newpciec-policy-tests.pycases cover each mode, with negative controls.
Blocker 2 (second-generation row): covered.
- Your J716c (T6050) dock row at this head shows 2/2 deep sleeps with no regression against the default kernel.
- As you note, the shared DART change applies only to
DART_T8020, which in this tree means T8103. The DWC3 softdep is a no-op with the T6050 config. - Not blocking: the one shared change that also runs outside T8103 is
igcjoining the orderly-removal allow-list inpcie-apple.c. It applies to the ports that power off for sleep on T8122/T8142. That path is untested until a T8122/T8142 dock row exists, so keep it under "Not yet" as the PR body does.
Checked
ff817bf9845cis a single commit on top of the reviewed head.- CI is green at this head (28 checks), and every commit is signed off.
Merging is left to the PR Merge Lane.
T8103's apple_dcp_hw_t8103_dcpext (.s2r_ext = true) lives in #3178 rather than feat/dcp-v27-ext-idle-off, leaving the dcp_s2r_domains_off() and dcp_s2r_ext_start() hunks unreachable on this stack. Narrow this PR to the T8020 display DART dark-save fix and dcp_s2r_warm_restart() wake-order fix, which apply directly to T8103 disp0 on this branch. Signed-off-by: Erik Bourget <[email protected]>
What: Enable deep sleep (suspend-to-RAM) and clean reboot on T8103 (M1) with a USB4/Thunderbolt dock and external display attached, on top of #3172 (merged). Fixes DCPEXT DART register-window mapping and S2R stop/restart, ACIO host router sleep before domain power-off and on reboot (a router that does not sleep keeps its domain powered and refuses the system sleep), ATC PHY + dummy PIPE restoration after
ps_atc*_commonpower-off, PCIe-Cigcorderly removal, non-locking PCIe-C DART tunables save/restore, anddwc3-applesoftdep onxhci_plat_hcd.Tested: J313 M1 Air at
ff817bf9845c(merged with #3171 for GPU S2R, as before), default cmdline, CalDigit TS5 dock (4K120 DSCcard1-DP-2, 2.5GbEenP1p3s0, USB2 + USB3 hubs, USB audio): 2/2 consecutive real S2R cycles (rtcwake -d /dev/rtc1 -m mem -s 12) with live Hyprland preserved + cleansystemctl rebootto the default kernel; a forced router-sleep failure (test-only module, not in this PR) refused deep sleep with the port, display and 2.5GbE kept up and no reset; no new kernel error classes against the default kernel's S2R;tools/asahi/pciec-policy-tests.pypassed. J716c (T6050, M5 Max) atff817bf9845cmerged intomain40e5e29cc915, default cmdline, same CalDigit TS5 (40 Gb/s x2, 2.5GbEenP3p3s0, two DP monitors, USB2 + USB3 hubs): 2/2 real deep sleeps resumed with dock, displays, Ethernet and USB back, 0 failed units beyond the pre-existing one, and the same kernel error lines as one deep sleep on the Mac's default kernel.Risk: two-way door · M1 (T8103), plus shared
apple-dart/pcie-apple/dwc3-applepaths (all Macs)Not yet: Other T8103 boards (J274/J293/J456/J457), s2idle/freeze regression pass with TS5 attached, a run of the
igcorderly-removal path on another Mac whose ports power off for deep sleep (T8122 or T8142, not in the lab).Details
Builds on #3172 (merged), which adds T8103 S2R and
dcp_powerDT definitions. Eight focused commits:bcdc74861256drm/apple: dcp: support T8103 DCPEXT DART register mapping and S2RAdds
apple,t8103-dcpextwithmap_reg_dart,s2r_ext,s2r_disp_dart_with_dcp, and DISPEXT0 power words (0x378/0x368), plusapple,display-power = <&dcp_power>ondcpextint8103.dtsi. Withoutmap_reg_dart, firmware 27.2 faults on stream 0 writing0x23b3d0000on external display power-down and crashes DCPEXT. Generalizess2r_exthelpers to key onhw.s2r_layout/hw.s2r_ext, restoresdisp_dartstreams ons2r_ext_start(), and gates firmware 27.0 opt-in onhw.s2r_untestedso T8142 behavior is unchanged while T8103 runs on the default command line.834e5defedc6thunderbolt: apple: tear down T8103 ACIO routers for deep sleepEnables
sleep_removes_domains,restart_on_wake, andphy_shared_with_dwc3onapple_cio_t8103_hwsomem_sleep=deeptears down an attached router ahead ofdwc3-apple's PM notifier and requests fresh cable state on wake, leaving s2idle and freeze unchanged. Extendstools/asahi/pciec-policy-tests.pyto cover T8103 alongside T8122.3e72a0ce5a9bPCI: apple: allow orderly removal of igc behind a tunneled PCIe-C portAllows
igc(such as Intel I225-LMvP inside a CalDigit TS5) to unbind cleanly duringPM_SUSPEND_PREPAREwhen deep sleep powers down the tunneled PCIe-C port.e1924d043f38iommu/apple-dart: allow PCIe-C tunnel state save/restore with non-locking tunablesChecks whether any
apple,tunableentry actually setsDART_T8020_CONFIG_LOCKinstead of rejecting any non-NULLdart->tunablesinapple_dart_save_tunnel_state()/apple_dart_restore_tunnel_state(), and reappliesdart->tunablesafterapple_dart_hw_reset()on restore.aefd301d304eusb: dwc3: apple: declare pre-load softdep on xhci_plat_hcdDeclares
MODULE_SOFTDEP("pre: xhci_plat_hcd")so synchronousxhci-hcdbinding indwc3_apple_host_start()does not race ahead ofxhci-plat-hcdloading (-517) whenCONFIG_USB_XHCI_PLATFORM=m.bbd215282ccethunderbolt: apple: sleep T8103 ACIO router before power-off and on rebootAdds
sleep_router_on_stopand enablessleep_router_on_stop,psd_power_cycle, andstop_at_rebootonapple_cio_t8103_hw. On T8103, droppingps_atc*_ciowhile the ACIO host router firmware is active (M3_STAT=0x01000000) immediately resets the SoC, and rebooting with a live router panics inapple_dpin_irq_dispatch(). Putting the host router into ACIO sleep (M3_STAT=0x02000000) before NHI removal, detaching the RTKit mailbox viaapple_rtkit_mailbox_off(), releasing/suspending ACIO power domains in reverse order, and stopping the router on reboot resolves both.dbb7b44b3d99phy: apple: atc: restore T8103 PHY and dummy PIPE state after deep sleepT8103 deep sleep lowers
ps_atc*_commonbehind genpd's back, wiping PHY registers and clearingPIPEHANDLER_DUMMY_PHY_EN. Addssleep_drops_commonand setspark_dummy_phy,restore_after_pd_off, andsleep_drops_commononatcphy_hw_t8103so wake restores the tracked PHY mode before ACIO restarts (preventing a post-wake SoC reset) and re-enables the dummy PIPE on park (preventingFailed to lock pipehandlerandusb2-port1: Cannot enableon tunneled USB3).ff817bf9845cthunderbolt: apple: keep the T8103 CIO domain up when the router does not sleepapple_cio_sleep_router_for_stop()now returns its error, and everyapple_cio_stop()caller says what happens to a router that stays awake. System sleep and cable changes keep the port up as it was (NHI, co-processor and domains stay, PCIe-C admission reopens and a requested tunnel is restored), and the suspend notifier refuses the sleep with the error. Reboot and power-off remove the children but keep the co-processor and domains powered until the reset. A failed start's unwind and driver removal still power off, because the co-processor is freed and removal detaches the domains. A started port whose NHI is gone counts as a failed sleep (-ENODEV).pciec-policy-tests.pygains a host test of the stop paths with four negative controls.Evidence
Hardware tested: J313 M1 MacBook Air (T8103, firmware 27.2) with CalDigit TS5 USB4 dock on front port (
501ac0000.cio/502280000.usb/503000000.phy) carrying 3840x2160@120Hz DSC DisplayPort monitor (card1-DP-2), Intel I225-LMvP 2.5GbE (enP1p3s0), TS5 USB2/USB3 hubs, AirPods Max USB Audio, and AC power.Build:
7.3.0-j313usb4s2r #199built fromdbb7b44b3d99merged with #3171 (feat/t8103-gpu-27-2-s2rat3577ce0e4885for live Hyprland GPU S2R) plus patchedt8103-j313.dtb(apple,display-power = <&dcp_power>ondcp@271c00000), default kernel command line.Commands & results:
python3 tools/asahi/pciec-policy-tests.py): all positive tests and negative controls passed (includingt8103-drop-sleep-removes-domains,t8122-drop-sleep-removes-domains,t8122-drop-phy-shared).rtcwake -d /dev/rtc1 -m mem -s 12):boot_id: unchanged across both cycles (695ad617-5a2d-469d-9ad9-31e0a15f6624)./sys/power/suspend_stats/success:0 -> 1 -> 2(apple-sleep: back from sleep, boot object resumes 0 -> 1 -> 2, wake sourceNUB.SPMI0Sw3IRQ).HyprlandPID4838preserved across Cycle 2.0-1(CalDigit, Inc. TS5) restored at20.0 Gb/sx2lanes.card1-DP-2: connected(3840x2160@120 Hz DSC via271c00000.dcp),card1-eDP-1: connected.enP1p3s0 UP(2500 Mbps Full Duplex),wlan0 UP.1-1(2188:5806 TS5 USB 2 Hub),1-1.4(2188:0617 TS5 USB 2 Hub),1-1.4.2(05ac:1117 AirPods Max USB Audio),1-1.5(2188:ace1 TS5 Billboard),2-1(8087:5787 USB3 HUB),2-1.4(2188:0629 TS5 USB 3 Hub) all re-enumerated cleanly.macsmc-ac/online=1,macsmc-battery/status=Full.Failed to lock pipehandler, zerousb2-port1: Cannot enable, zero DART faults, zero DCPEXT crashes, zero CIO or GPU errors.sudo systemctl rebootwith TS5 attached): shut down cleanly withoutapple_dpin_irq_dispatchpanic and booted back into default kernel.Router-sleep error path (head
ff817bf9845c):7.3.0-j313usb4b1, built fromff817bf9845cmerged with #3171 (3577ce0e4885), same DTB and default command line as #199.thunderbolt_apple.ko(not in this PR) failedapple_nhi_cio_router_sleep()once before anything was sent.rtcwake -m memreturnedwrite error,suspend_stats/failwent 0 -> 1,boot_idunchanged. The log shows the PCIe-C hierarchy removed in order,CIO host router did not go to sleep: -5,the port stays up with its domains powered,refusing system sleep: the port cannot be powered off (-5),PM: suspend exit, thenPCIe-C hierarchy restored after tunnel activationand igc relinking at 2500 Mb/s. TS5 stayed at 20 Gb/s,card1-DP-2stayed connected/enabled, and Hyprland kept the same PID. A real S2R on the same boot then succeeded (success0 -> 1).f3e33928cdb4a32c..., no test parameter), new boot: 2/2 consecutive real S2R cycles,success0 -> 1 -> 2, sameboot_id,CIO controller sleep state 0x2000000: 0before each power-off andrestarting port after system sleepafter each wake. After both cycles: TS5 at 20.0 Gb/s x 2,card1-DP-2+card1-eDP-1connected,enP1p3s0up at 2500 Mb/s, Hyprland on the same PID, USB1-1,1-1.4,1-1.4.2(AirPods Max USB Audio),1-1.5,2-1,2-1.4present, 0 failed units, no DART faults, pipehandler or USB-enable errors, DCPEXT crashes, panics or SErrors.7.3.0-j313usb4s2r #199(of_irq_parse_pcion PCIe-C re-enumeration,brcmfmac/hci_bcm4377D3hot after the wake,PS fpwm1, DCPDP2X admission, DCP init props). None from thunderbolt, ACIO or PCIe-C.systemctl rebootfrom the trial kernel with TS5 attached: normalsystemd-shutdown, noapple_dpin_irq_dispatchpanic, booted the defaultj313-usb4s2r.Second generation: J716c (T6050 / M5 Max), head
ff817bf9845c:7.3.0-ewb325+, built frommain40e5e29cc915withff817bf9845cmerged (clean merge), with the config of the Mac's default7.3.0-ewb317+. Booted once through the Mac's one-shot boot marker with the default boot arguments; the default boot was not changed. CalDigit TS5 (USB40-1at 40.0 Gb/s x 2), Intel I225-LMvP (igc,enP3p3s0), two DP monitors through the dock (card3-DP-1,card3-DP-4) pluscard3-eDP-1, TS5 USB2/USB3 hubs, on AC.mem_sleepdeep,rtcwake -m mem -s 30):suspend_stats/success0 -> 1 -> 2,fail0,apple-sleep: back from sleep, boot object resumes 0 -> 1 -> 2. Wake sources:SMC.OutboxNotEmpty(cycle 1, AC traffic) andNUB.SPMI0Sw3IRQ ... rtc(cycle 2). Both times:T6050 sleep: router asleep in place, tunnels kept, router woken in 429-431 ms (dock back),CIO PCIe-C link and DMA restored,igc ... NIC Link is Up 2500 Mbps.card3-DP-1,card3-DP-4,card3-eDP-1connected and enabled (DPMS on),enP3p3s0up and passing traffic (3/3 to the gateway through the dock, 0.22-0.27 ms; the build host reaches both of its addresses), USB1-1,1-1.4,1-1.5,2-1,2-1.4present, Wi-Fi up. NoWARNING,BUG, Oops or DART faults. Failed units: onlyaurora-peripherals.service, failed on the default kernel before the run too.7.3.0-ewb317+, same dock, after restoring the default: the same kernel error lines on both (dwc3-apple ... genpd_prepare returns -11at entry, Centauricountry update failed: -125, transient01:00.1/01:00.2 device inaccessibleon wake, DCPundeclared provider clock index 0). None is new with this PR.apple-dart,pcie-apple,dwc3-apple,thunderboltandatccode builds, boots and survives docked deep sleep with no regression. The three shared changes are not reached there: the DART tunnel save/restore only runs onDART_T8020DARTs (in this tree onlyapple,t8103-dart/apple,t8103-usb4-dart; T6050's areapple,t8110-dart, so it returns-EOPNOTSUPPbefore and after the change),apple_pcie_tunnel_remove_orderly()runs only on ports that power off for deep sleep (sleep_removes_domains: T8103, T8122, T8142; the J716c router sleeps in place and keeps its tunnels), andxhci-plat-hcdis built in (CONFIG_USB_XHCI_PLATFORM=y), so the softdep has nothing to load. On T8103 the J313 rows above run all three.