Skip to content

drm: apple: t8132: keep an external display across a deep sleep - #2200

Open
niteria wants to merge 2 commits into
aurora-silicon:integration/aurorafrom
niteria:j713/m4-ext-sleep
Open

niteria wants to merge 2 commits into
aurora-silicon:integration/aurorafrom
niteria:j713/m4-ext-sleep

Conversation

@niteria

@niteria niteria commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Deep sleep with an external display attached crashes the M4 (T8132) external DCP on its restart after the wake, and the display stays dark until a reboot. This keeps the display across the sleep: it is released before the DCP powers down and connected again after, with the DRM connector held meanwhile so the compositor sees no unplug.

The crash

A deep sleep stops a dcpext and powers it down whole (eb34e77); its firmware starts from reset after the wake. With its DPTX port still connected and a display attached (4K@30 or 1080p@60, USB-C to HDMI, either port), the restarted firmware crashes at once: RTKit "co-processor has crashed", an SError with the async error at 0x286100688 every time. The enable then fails with -67, DPTX calls time out, and a replug doesn't bring the display back. With nothing attached the restart is clean.

The change

  1. dptxep: let a dcpext take its link down. The firmware sets its link rate to 0 from within set_hpd(0). In DP alt mode that goes to the ATC PHY, whose configure may refuse it (-EOPNOTSUPP) once the PHY has left DP mode, as the T8132 ATC PHY does; the firmware then waits on its own call and answers nothing else, so set_hpd(0), release_display and the next connect all time out. A rate 0 that the PHY refuses with -EOPNOTSUPP is answered as done, for any DCP. No other PHY driver returns -EOPNOTSUPP for a rate 0, so nothing changes on other SoCs.
  2. t8132: keep an external display across a deep sleep. In the deep-sleep suspend, before A500: HPD low, the display released with dcp_dptx_disconnect(), the crossbar output parked. After the restart the route is unparked and the Type-C work connects the display again. A release call that timed out is dropped once the firmware is stopped: the firmware that starts from reset never answers it, and the connect after the wake would otherwise wait 15 s for it. Meanwhile the DRM connector is held (connected, the modes of the link it had, its hotplugs held back), for an output that took the hold at PM_SUSPEND_PREPARE, since its PM_POST_SUSPEND is what ends it. The PM_POST_SUSPEND replays wait for the reconnects together, 3 s at most, so each modeset finds its link up. A display unplugged during the sleep ends its wait as soon as that is known. When the replay is done (for an output that wasn't replayed, when the wait is over), the hotplug held meanwhile goes out. The release's own HPD low is among those held, so the compositor probes once after every such sleep and finds what changed: a display gone, also from a CRTC that was off, or a new link or sink. A failed replay sets the link status BAD and sends it too.

The release is in the DCP's suspend, not the PM_SUSPEND_PREPARE notifier: there atcphy_suspend refuses the sleep with -EBUSY.

Tested

J713 (MacBook Air M4), integration/aurora a7dd26e + #2166 (EDID) + these commits as an out-of-tree appledrm.ko, dcpext handover (chosen.asahi,j713-dcpext=1, atcphy0/1 apple,dp-alt-mode), Aura b13.1, a Samsung 4K (3840x2160@30) and a 1080p display over USB-C to HDMI adapters, RTC wake (rtc1):

  • without this: 5 of 5 deep sleeps crashed the DCP on its restart.
  • with it, both ports in use (4K and 1080p, either way round): 7 of 7 deep sleeps (4 at the greeter, 3 under Hyprland) set each display's mode once; Hyprland kept 3840x2160@30 and its layout. Each display is back 1.6-2.1 s after the DCP's restart. With the held hotplug (the last 2), each connector then gets one hotplug after its replay, and neither the greeter's fbdev nor Hyprland sets its mode again.
  • HDMI cables pulled during the sleep: the wait ends on the Type-C unplug (~2.4 s), and Hyprland drops the output, through the failed replay's hotplug if it was on, through the held hotplug if it was off (the 4K turned off in Hyprland with DPMS, the 1080p on, both pulled). Without the held hotplug, the off output sent no uevent, its connector stayed connected, and Hyprland kept it as a phantom monitor.
  • with the review fixes (the hold only for an output whose PM notifier took it, a timed-out release call dropped over the stop, one deadline for all the waits): 6 of 6 deep sleeps under Hyprland, both displays, with test-only knobs (not part of these commits) to force each case:
    • plain: as above, each display back within 1.8 s of the DCP's restart, one hotplug each, layout kept.
    • a release call that timed out (a fake one left by the release): dropped once the firmware is stopped, and the wake is the same as the plain one. Kept over the stop instead (the behaviour before the fix), the connect after the wake waits 15 s for it, both replays fail and the displays are dark for ~16.5 s.
    • the reconnects delayed 5 s: both waits end at the one 3 s deadline, 21 ms apart; the failed replays' hotplugs, then Hyprland brings both back ~6.4 s after the wake.
    • no hold taken (as for an output without the PM notifier): nothing is held, the replays fail at once and Hyprland brings both back within 1.6 s; a display unplugged after that is dropped at once.
    • both HDMI cables pulled during the sleep, the 1080p off (DPMS): both waits end on the Type-C unplug (2.0 s after the restart), and Hyprland drops both.

These runs had the rate-0 rule limited to T8132 dcpexts; on the Air that is the same as without the limit.

Based on cb57d4a, the integration/aurora merge before #2135, since with #2135 the M4 Air doesn't deep-sleep. It merges cleanly onto current integration/aurora and onto #2166, and doesn't depend on it.

Host tests (tools/asahi/run-host-tests.py, full run): 425/425 on each commit and on the base.

🤖 Generated with Claude Code

@niteria
niteria force-pushed the j713/m4-ext-sleep branch 2 times, most recently from 5924bd0 to 0184115 Compare November 18, 2026 18:35
@niteria
niteria marked this pull request as ready for review November 18, 2026 19:22
@niteria
niteria requested a review from erikwb November 18, 2026 19:22
@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks for this; the 7/7 and 6/6 sleep runs with both ports in use are convincing.

One small point. We select protocol-level behaviour for every device that speaks the protocol, not for the chip where it was seen. In drivers/gpu/drm/apple/dptxep.c:690-691, a rate-0 set_link_rate on a PHY that has already left DP mode is answered as done only when dcp_is_t8132_ext(). The reasoning in the comment (the link is already down, and a refusal leaves the firmware waiting on its own call) holds for any dcpext whose ATC PHY leaves DP alt mode.

Could you drop the dcp_is_t8132_ext() term so the -EOPNOTSUPP && !phy_link_rate case is treated as done everywhere? If another firmware relies on getting the error, please say which in a comment. We can run no-regression rows on our M1 Pro, M2, M4 Pro and A18 Pro. The T8132 sleep release itself looks fine as it is.

A dcpext's firmware sets its link rate to 0 when its HPD goes low, from
within the set_hpd(0) call. In DP alt mode the rate goes to the ATC PHY,
whose configure may refuse it (-EOPNOTSUPP) once the PHY has left DP
mode, as the T8132 ATC PHY does when the display is released for a deep
sleep. The refusal goes back to the firmware, which then waits on its
own call and answers nothing else: the set_hpd(0) and the
release_display after it time out, and the next connect does too.

A link going down on a PHY that is out of DP mode is down already: answer
the rate 0 as done, whichever DCP asks. No other PHY driver refuses a
rate 0 with -EOPNOTSUPP: they take the link down, or fail with another
error that goes back as before.

Assisted-by: LLM
Signed-off-by: Bartosz Nitka <niteria@gmail.com>
A deep sleep powers a T8132 dcpext down whole (iomfb_m4_ext_stop()), and
its firmware starts again from reset after it. Firmware that starts with
its DPTX port still connected brings the link up on hardware the sleep
reset, and crashes (an SError) with any display attached.

So in its deep-sleep suspend, before A500 while its firmware still runs,
the display is released as an unplug releases it (HPD low, then
dcp_dptx_disconnect()) and its crossbar output is parked. The cable
stays connected: after the restart the route is unparked and the type-C
work connects the display again, as for a plug. A suspend that fails
after the release connects it again at once. A release call that timed
out is never answered by the firmware that starts from reset: it is
dropped once the firmware is stopped, so that the connect after the
wake does not wait for it.

DRM does not see that release and reconnect. From the release until the
replay of its state at PM_POST_SUSPEND, the connector is held: it stays
connected, its modes are those of the link it had (the link's capacity
is kept at the release; its rate is 0 meanwhile), and its hotplugs wait.
Only an output that took the hold at PM_SUSPEND_PREPARE is held, as its
PM_POST_SUSPEND is what ends the hold. The replays wait for their
displays to be connected again (each one's D575 and its sink's timing
catalog), together and 3 s at most, before any takes the modeset locks,
so that each modeset finds its link up. A display unplugged during the
sleep ends its wait as soon as that is known (no cable at the reconnect,
or the type-C unplug after it). When the replay is done (for an output
that was not replayed, when the wait is over), the hotplug held
meanwhile goes out. The release's own HPD low and rate 0 are among the
hotplugs held, so one goes out after every such sleep, and the
compositor finds what the sleep changed: a display gone, also one whose
CRTC was off, or a new link or sink. A replay that fails sets the link
status BAD and sends the hotplug as well.

Assisted-by: LLM
Signed-off-by: Bartosz Nitka <niteria@gmail.com>
@niteria

niteria commented Nov 19, 2026

Copy link
Copy Markdown
Contributor Author

Done in 3e2fe31: the dcp_is_t8132_ext() term is gone, so a rate 0 that the PHY refuses with -EOPNOTSUPP is answered as done whichever DCP asks. The comment and the commit message no longer name T8132; the commit is now "drm: apple: dptxep: let a dcpext take its link down".

No firmware gets that error for a rate 0 today, so none can rely on it: the T8132 ATC PHY is the only PHY driver that returns -EOPNOTSUPP for one. The others:

  • ATC t8103 (M1, M1 Pro/Max, M2, M2 Pro/Max): 0.
  • ATC t8122 (M3, M3 Pro/Max, M5) and t8140 (A18 Pro): take the link down; 0 or that sequence's error.
  • t6040 (M4 Pro/Max): -EINVAL while its DP PHY is powered off, otherwise it takes the link down.
  • t6050 ATC: -EIO or -EPIPE while faulted or not enabled, otherwise it takes the link down.
  • LPDPTX: 0; the t6050 type -ENODEV while inactive.

So on the M1 Pro, M2, M4 Pro and A18 Pro the firmware gets the same answers as before, and the no-regression rows there would confirm it. On T8132 the change is a no-op, so the Air runs stand.

Host tests (full run): 425/425 on each commit.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks for 3e2fe31 and for the per-PHY survey of what a rate-0 request returns; that makes the no-op on the other machines easy to follow. This reads right to us.

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.

2 participants