Skip to content

drm/apple: dcp: rearm Type-C IOMFB HPD completion on deep-sleep DPTX release - #4013

Merged
sithglan merged 1 commit into
mainfrom
fix/dcp-dp-s2r-resume
Dec 2, 2026
Merged

sithglan merged 1 commit into
mainfrom
fix/dcp-dp-s2r-resume

Conversation

@sithglan

@sithglan sithglan commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

What: Fix a deep-sleep resume regression on firmware 27 direct Type-C DP outputs (apple,t8142-dcpext, J813) introduced by ab187c40d66a. Because dcp_poweroff() keeps DPTX connected across DPMS off (dcp_typec_keep_dptx_on_dpms()), it skips reinit_completion(&dcp->typec_iomfb_hpd_ready) and dcp->typec_crtc_off; deep sleep then releases DPTX in dcp_s2r_ext_suspend() -> dcp_external_stop_locked() without reinitializing typec_iomfb_hpd_ready and sets typec_crtc_off only after lowering HPD. On resume, dcp_poweron() immediately returned from wait_for_completion_timeout(&dcp->typec_iomfb_hpd_ready, ...) and ran iomfb_poweron_v27() + set_digital_out_mode() ~100–150 ms before firmware published the new IOAVVideoInterface and hotPlug_notify, causing IOAVVideoInterface prepareLink() to fail with 0xe00002ec (set_digital_out_mode returned 80000104) and firmware to permanently drop the sink. This change reinitializes typec_iomfb_hpd_ready and sets typec_crtc_off (when a cable is connected) before lowering HPD on non-retained Type-C outputs in dcp_external_stop_locked(), adds two KUnit regression tests in dcp_s2r_test.c, and updates tools/asahi/dcpext26-lifecycle-tests.py.

Tested:

  • Hardware (J813, M5 Air, external Eizo EV2780 on Type-C port0 / 506e00000.dcp, exact head 2a8d8087827f on main b902937859ec, 7.3.0-aurora-dp-resume+):
    • Live KUnit apple-dcp-s2r: 5/5 PASS (including both new tests dcp_s2r_t8142_dcpext_stop_rearms_hpd_ready and dcp_s2r_t8140_retained_ext_stop_unchanged).
    • 3/3 consecutive true SoC-off deep sleeps (rtcwake -d /dev/rtc0 -m mem -s 15, boot object resumes 0 -> 1 -> 2 -> 3, wake source: NUB.SPMI0.SW3): card1-DP-1 returned status=connected enabled=enabled dpms=On on every wake with 0 prepareLink errors, 0 setmode failed, and 0 hotplug not ready warnings (cycles 1–2 at 2560x1440@59 Hz, cycle 3 at 1680x1050@60 Hz).
    • 1/1 refused-sleep power-cycle recovery (dcp_s2r_ext_cycle): card1-DP-1 returned 2560x1440@59 Hz cleanly.
    • 1/1 s2idle (rtcwake -d /dev/rtc0 -m freeze -s 10): card1-DP-1 returned connected/enabled cleanly.
    • Post-wake Wi-Fi (wlp1s0f0) and 64 MiB direct NVMe read OK; 0 kernel oops/warnings.
  • Build & host tests at exact head 2a8d8087827f:
    • W=1 drivers/gpu/drm/apple/ (LLVM 19): 0 warnings in dcp.c and dcp_s2r_test.c.
    • scripts/checkpatch.pl --strict --git aurora/main..HEAD: 0 errors, 0 warnings, 0 checks.
    • tools/testing/selftests/drivers/gpu/apple-dcp/run.sh: 101/101 PASS.
    • tools/asahi/dcpext26-lifecycle-tests.py: PASS.

Risk: two-way · Only runs inside dcp_external_stop_locked() when !dcp_is_retained_external(dcp) && dcp_is_typec_output(dcp) and dptxport[0].connected is true (specifically s2r_ext non-retained Type-C DP pipes whose dcp_poweroff() kept DPTX up, such as apple,t8142-dcpext). Retained external pipes (H17P / native26) and fixed-HDMI / internal panels are untouched (verified by dcp_s2r_t8140_retained_ext_stop_unchanged and dcpext26-lifecycle-tests.py).

Not yet: Second-board J815 / J704 row, unplug-during-sleep row, and DPMS-off-before-deep-sleep row.

…release

Commit ab187c4 ("drm/apple: dcp: keep firmware 27 Type-C DPTX
connected across DPMS off") returns early from dcp_poweroff() on
firmware 27 direct Type-C DP outputs, leaving DPTX connected across CRTC
power-off and skipping reinit_completion(&dcp->typec_iomfb_hpd_ready) and
dcp->typec_crtc_off.

During deep sleep on s2r_ext hosts such as T8142 (J813),
dcp_s2r_ext_suspend() then tears the DPTX link down via
dcp_external_disconnect(dcp, false) -> dcp_external_stop_locked(). That
path lowered HPD and released DPTX without reinitializing
typec_iomfb_hpd_ready, and only set typec_crtc_off after lowering HPD.
Consequently:

1. Firmware's synthetic unplug during suspend arrived while
   typec_crtc_off was still false, marking the still-attached connector
   disconnected.
2. On resume, dcp_poweron() saw typec_crtc_off && typec_cable_connected,
   reconnected DPTX, and immediately returned from
   wait_for_completion_timeout(&dcp->typec_iomfb_hpd_ready, ...) because
   the completion was still signaled from before sleep. It then called
   iomfb_poweron_v27() and set_digital_out_mode() ~100-150 ms before
   firmware published the new IOAVVideoInterface and hotPlug_notify,
   causing IOAVVideoInterface prepareLink() to fail with 0xe00002ec
   (set_digital_out_mode returned 0x80000104) and firmware to drop the
   sink permanently.

Prepare the same handoff to dcp_poweron() inside
dcp_external_stop_locked() before lowering HPD on non-retained Type-C
outputs: reinitialize typec_iomfb_hpd_ready and set typec_crtc_off when a
cable is attached, leaving retained H17P/ext26 external pipes unchanged.

Add KUnit regression tests in dcp_s2r_test.c covering both the T8142
V27 Type-C stop handoff and the unchanged retained H17P stop path, and
update tools/asahi/dcpext26-lifecycle-tests.py for the extracted helper.

Fixes: ab187c4 ("drm/apple: dcp: keep firmware 27 Type-C DPTX connected across DPMS off")
Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
@sithglan
sithglan requested review from a team and DjDeveloperr as code owners December 2, 2026 23:24

@RyanTheTide RyanTheTide left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed at 2a8d808. The fix is right. Non-retained Type-C pipes that keep DPTX up across DPMS off only release the link in the deep-sleep external stop, so they skipped dcp_poweroff()'s handoff. Re-initialising typec_iomfb_hpd_ready there makes dcp_poweron() wait for IOMFB's fresh VideoInterface/HPD before the modeset, which matches the prepareLink() 0xe00002ec symptom. Marking the CRTC off before lowering HPD keeps the synthetic unplug from dropping the still-attached connector. The guard is limited to !retained && typec_output, so retained externals and HDMI keep their current path.

On error handling: if the withdraw fails after the re-init, the function still goes to the 'failed' path, which sets external_error and holds the session. The re-armed completion therefore can't strand a later poweron, because no poweron proceeds on that session. Moving the withdraw into a KUNIT_STATIC_STUB_REDIRECT helper is a clean way to assert the ordering (completion reset and crtc_off set before the withdraw), and the new S2R KUnit case covers it. Approve, pending your J813 EIZO exact-head row in the PR.

@github-actions github-actions Bot added area:display Area from CODEOWNERS (bot) area:gpu Area from CODEOWNERS (bot) blast:m5 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-hw-row No hardware row at the PR head (bot) labels Dec 2, 2026
@github-actions

github-actions Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Merge readiness at 2a8d8087: ready to merge

Check Detail
CI at head ok 5 checks passed
Review ok approved by RyanTheTide
Requested changes ok none
Hardware row at head ok comment at 2a8d8087
Conflicts ok none
PR text ok Risk: two-way · Only runs inside dcpexternalstoplocked() when !dcpisretainedexternal(dcp) && dcpistypecoutput(dcp) and dptxport[0].connected is true (specifically s2rext non-retained Type-C DP pipes whose dcppoweroff() kept DPTX up, such as apple,t8142-dcpext). Retained external pipes (H17P / native26) and fixed-HDMI / internal panels are untouched (verified by dcps2rt8140retainedextstopunchanged and dcpext26-lifecycle-tests.py).

Areas: area:display, area:gpu
Merge: gh pr merge 4013 --merge (Owners and Core through the bypass: add --admin).

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

@sithglan

sithglan commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

Hardware row at 2a8d8087827f on J813 (M5 Air, external Eizo EV2780 on Type-C port0 / 506e00000.dcp, kernel 7.3.0-aurora-dp-resume+): PASS

  • Live KUnit apple-dcp-s2r: 5/5 PASS (dcp_s2r_t8142_dcpext_stop_rearms_hpd_ready + dcp_s2r_t8140_retained_ext_stop_unchanged).
  • 3/3 consecutive true SoC-off deep sleeps (rtcwake -d /dev/rtc0 -m mem -s 15, boot object resumes 0 -> 1 -> 2 -> 3, wake source: NUB.SPMI0.SW3): card1-DP-1 returned status=connected enabled=enabled dpms=On on every wake with 0 prepareLink errors, 0 setmode failed, and 0 hotplug not ready warnings (cycles 1–2 at 2560x1440@59 Hz, cycle 3 at 1680x1050@60 Hz).
  • 1/1 refused-sleep power-cycle recovery (dcp_s2r_ext_cycle): card1-DP-1 returned 2560x1440@59 Hz.
  • 1/1 s2idle (rtcwake -d /dev/rtc0 -m freeze -s 10): card1-DP-1 returned connected/enabled.
  • Post-wake Wi-Fi (wlp1s0f0) and 64 MiB direct NVMe read OK; 0 kernel oops/warnings.

@github-actions github-actions Bot added ready-to-merge Meets the merge policy: merge it (bot) and removed needs-hw-row No hardware row at the PR head (bot) labels Dec 2, 2026
@sithglan
sithglan merged commit 37a6306 into main Dec 2, 2026
6 checks passed
@sithglan
sithglan deleted the fix/dcp-dp-s2r-resume branch December 2, 2026 23:30
@DjDeveloperr

Copy link
Copy Markdown
Contributor

Post-merge check of 2a8d8087827f as merged (37a630623169, tree e551b18c45cf, which is what I had under test when it landed). The kernel change is fine and stays in. Three follow-ups.

Code. Only dcp_s2r_ext_suspend() reaches the new block; the other callers of dcp_external_stop_locked() are retained pipes. That means firmware 27 Type-C on the T8142, T8132 27.2, T8103 and T8112 dcpext. T6050 sleeps through its own path and a USB4 output normally arrives released. Before ab187c40d66a, dcp_poweroff() did the same rearm for all of them, so the J813 row is enough. If the withdraw fails, the cost is one 3 s wait and a warning on the next power-on. Presentation is already paused and the error latched there today. One correction to the review: a non-retained dcp_poweron() does not check external_error, so it does run after that failure; the 3 s is the bound.

  1. The apple-dcp selftest is 98/101, not 101/101, at this head and on main: physical-disconnect, fast-replug-bounce and dropped-swap-teardown no longer compile, because the fixture in lifecycle.py does not know dcp_external_withdraw_dptx_locked(). Fixed in selftests: apple-dcp: extract the DPTX withdrawal in the disconnect fixture #4019 (101/101).
  2. drm/apple: dcp: fix firmware-27 external and primary-HDMI s2r_ext deep sleep #3822 would undo this fix without a conflict. It merges cleanly, but its dcp_s2r_ext_disconnect() takes non-retained pipes around dcp_external_stop_locked(), sets typec_crtc_off and never rearms typec_iomfb_hpd_ready. The new KUnit case keeps passing because it calls the bypassed function. drm/apple: dcp: fix firmware-27 external and primary-HDMI s2r_ext deep sleep #3822 needs reinit_completion(&dcp->typec_iomfb_hpd_ready) before its HPD low, with a check in its disconnect test. Separately, its dcp-s2r-ext-idle-tests.py does not compile against current main (dcp_ext_idle_suspend has no stub).
  3. drm/apple: wire firmware-27 T6050 external DCPs into runtime idle off #3398 merges cleanly and leaves this path alone.

Ran on the merge tree: W=1 drivers/gpu/drm/apple/ with KUnit off and on, 0 warnings (the KUnit cases were built, not run); full host tests 1027/1028, the one failure being the selftest above; dcpext26-lifecycle-tests.py passes; checkpatch --strict 0 errors, 0 checks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:display Area from CODEOWNERS (bot) area:gpu Area from CODEOWNERS (bot) blast:m5 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) ready-to-merge Meets the merge policy: merge it (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants