Skip to content

drm: apple: no bad link for the HPD of a Type-C CRTC enable (DPMS wake loop) - #2023

Closed
sithglan wants to merge 1 commit into
aurora-silicon:integration/aurorafrom
sithglan:thomas/dcp-typec-enable-bad-link
Closed

sithglan wants to merge 1 commit into
aurora-silicon:integration/aurorafrom
sithglan:thomas/dcp-typec-enable-bad-link

Conversation

@sithglan

Copy link
Copy Markdown
Contributor

A DPMS off and on of a USB-C display can end in an endless loop. In it, wlroots destroys and re-creates the output about three times a second. The display stays dark and the desktop gets sluggish until the output is disabled or the cable is pulled. This fixes the loop.

The loop

  1. DPMS off of a Type-C output releases its DPTX session (dcp_poweroff()).
  2. DPMS on enables the CRTC. dcp_poweron() reconnects DPTX before this commit's mode set.
  3. The firmware answers the reconnect with an HPD. The hotplug worker runs before the mode set, sees connected with no valid mode, sets the link-status property BAD and replays the CRTC.
  4. wlroots answers a bad link by destroying the output it is enabling (connector DP-2: Bad link detected, Destroying output 'DP-2'). That disables the CRTC (set_hpd(0) via apple_crtc_atomic_disable() → dcp_poweroff()), and the firmware tears the video interface down.
  5. The output comes back, its enable reconnects DPTX, and the cycle repeats from step 3.

The tree already guards this wlroots cycle twice:

  • the worker skips a CRTC that is powered off (typec_crtc_off);
  • the hotplug callback skips the HPD that dcp_poweron() waits for (typec_poweron_hpd).

Neither covers the window in which the CRTC enable runs. typec_crtc_off is cleared at the start of dcp_poweron(), and typec_poweron_hpd is cleared before the asynchronous worker runs.

The fix

apple_crtc_atomic_enable() marks the enable pending (typec_enable_pending) before dcp_poweron(), and clears the mark once the commit's mode set has run, or on its failed: path. While the enable is pending, or a mode set is in flight (mode_state.changing), the hotplug worker neither reports a bad link nor replays the CRTC. The hotplug event itself is still sent. A mode set that fails still ends in a bad link once the enable is done.

Testing

Reproduced on a J813 (M5 MacBook Air, macOS 27.2 stub, Linux at EL2). The kernel was our J813 tree with the external display commits of #1806, and the display was an EIZO EV2780 directly on the rear USB-C port. Under sway 1.12, swaymsg 'output * power off', 12 s, swaymsg 'output * power on', three rounds each:

per round DP-2 after the wake
before ~50 hotplugs, ~25 CRTC enables and teardowns off, no mode
after 2–3 hotplugs, 1 enable, 1 teardown (the DPMS off) on, 2560x1440@59.95
  • After the fix, sway's debug log for the whole session has no Bad link detected and no Destroying output 'DP-2'. There were no hotplugs while idle.
  • The cause was traced with tracepoints, a temporary log in dptxport_set_hpd() (the set_hpd(0) came from sway's commit through apple_crtc_atomic_disable()), and sway -d.
  • On this branch, which is integration/aurora c0a2a75 plus this commit:
    • tools/asahi/run-host-tests.py: 321/321.
    • drivers/gpu/drm/apple/ builds with defconfig + asahi.config (LLVM 22).
    • apple_drv.c and iomfb.c build with W=1 and no warnings.
    • checkpatch --strict is clean.

The T8142 external display path itself is #1806 (draft). The code changed here is the generic Type-C DCP path, and it applies to integration unchanged.

cc @Acelogic @DjDeveloperr @RyanTheTide @LiamRay10

A DPMS off of a Type-C output releases its DPTX session; the enable
that follows reconnects it in dcp_poweron() before the mode set of the
same commit. The HPD the firmware answers that reconnect with runs the
hotplug worker while the mode is not set yet, and the worker reported
the link bad and replayed the CRTC. wlroots answers a bad link by
destroying the output, which disables the CRTC it was enabling; the
next enable does the same, forever.

On a J813 with an EIZO EV2780 on USB-C, every DPMS off and on ended in
that loop: about three cycles a second ("connector DP-2: Bad link
detected", "Destroying output 'DP-2'"), the display dark and the
desktop sluggish, until the output was disabled or the cable pulled.

Mark the CRTC enable as pending, from before dcp_poweron() until its
mode set has run, and let the worker report a bad link, or replay the
CRTC, only when no such enable and no mode set is in flight. A mode set
that fails still ends in a bad link once the enable is done.

Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
@sithglan

Copy link
Copy Markdown
Contributor Author

This commit is already in integration/aurora as 72300a2 (patch-identical, through the J813 series #2135). Nothing is left to merge, so I'm closing this PR.

@sithglan sithglan closed this Nov 18, 2026
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