Skip to content

drm/apple: dcp: reconnect fixed HDMI DPTX link after deep sleep - #2771

Open
DjDeveloperr wants to merge 1 commit into
integration/aurorafrom
djdev/dcp-fixed-hdmi-s2r
Open

DjDeveloperr wants to merge 1 commit into
integration/aurorafrom
djdev/dcp-fixed-hdmi-s2r

Conversation

@DjDeveloperr

Copy link
Copy Markdown
Contributor

Summary

dcp_s2r_ext_suspend() disconnects external displays via dcp_external_disconnect() (clearing dptxport[0].connected and deactivating the LPDPTX PHY) and stops DCPEXT firmware. On resume, dcp_s2r_restart_done() re-enables Type-C reconnect work, which only reattaches Type-C routes and leaves fixed HDMI outputs (such as J773g dcpext0 with hdmi-hpd-gpios and no Type-C route) permanently disconnected because the HPD IRQ is edge-triggered.

Fix (2bc65f4a537dc)

  • Disable hdmi_hpd_irq across dcp_s2r_ext_suspend() so HPD edges cannot race firmware teardown.
  • In dcp_s2r_restart_done(), re-assert the fixed HDMI power-enable GPIOs, sample hdmi_hpd, reconnect DPTX port 0 when present, and re-enable hdmi_hpd_irq.

Independent of #2764 (git merge-tree --write-tree is clean with zero overlap).

Live Verification — 3/3 Real Deep Sleep (dcp66-m4prod5-deepsleep)

Tested on live M4 Mac mini (J773g / T8132, macOS 27.2 26B123, 7.3.0-ARCH-m4prod5):

Cycle boot object resumes Mode Set Connector State Errors
1 0 -> 1 UnifiedPipeline::mode_set_gated: 3840x2160@120 Hz DSC=YES VRR=NO link: 1 connected/enabled/On 0
2 1 -> 2 UnifiedPipeline::mode_set_gated: 3840x2160@120 Hz DSC=YES VRR=NO link: 1 connected/enabled/On 0
3 2 -> 3 UnifiedPipeline::mode_set_gated: 3840x2160@120 Hz DSC=YES VRR=NO link: 1 connected/enabled/On 0

scripts/checkpatch.pl --strict: 0 errors, 0 warnings, 0 checks. 0 oops/warnings/SErrors across all 3 wakes.

Assisted-by: LLM (Gemini:4 Neon)

@RyanTheTide

Copy link
Copy Markdown
Contributor

Review at 2bc65f4.

The Type-C dcpext path is unaffected. On a Type-C DCPEXT hdmi_hpd_irq is 0, so the new helpers do nothing (dcp.c:8689-8703), and the reconnect block needs !dcp_is_typec_output(dcp) && dcp->hdmi_hpd (9304-9305).

  • dcp.c:8601-8606, 9796-9797: on firmware 27, dcp_s2r_ext_capable() needs appledrm.s2r_untested, so this suspend/restart path only runs with that parameter set. Please state the cmdline the three rows ran with, and whether the default-cmdline deep-sleep path on J773g also leaves the fixed HDMI output disconnected.
  • dcp.c:9304-9318: this is close to a copy of dcp_enable_dp2hdmi_hpd() (4935-4955), but not the same:
    • the dcp_dptx_connect() return is ignored;
    • on no HPD it reports a disconnect instead of _dcp_poweroff();
    • only the pwren GPIOs are driven, not the PHY/crossbar setup that dcp_fixed_hdmi_reinit_locked() does under the fabric lock.
  • dcp.c:8697-8703, 9319-9320: after the connect, dcp_s2r_hdmi_irq_enable() calls dcp_fabric_run_resume(). That samples HPD a second time, and enable_irq() also replays any edge latched while the IRQ was disabled, so a second connect can follow straight after the first. Reusing dcp_enable_dp2hdmi_hpd() here, or factoring the shared part out of it, would leave one connect path.
  • dcp.c:8738, 8760-8777: the IRQ is disabled before dcp_external_disconnect() but not re-enabled when A500 or apple_rtkit_sleep_stop() fails. The crashed path (8725-8729) is the same if dcp_s2r_stop_crashed() fails. A device whose suspend fails gets no resume callback, so HPD stays off until a later sleep gets through dcp_s2r_restart_done(). restart_done() also returns early on error (9293-9297) with the IRQ still off. That one may be intended, since the display stays down until reboot, but please say so in a comment.
  • drm/apple: release a fixed HDMI link on DPMS off with DCP firmware 27 #2503 (fixed HDMI link released on DPMS off with firmware 27) changes this same state. It sets hdmi_crtc_off and leaves the retrain to dcp_poweron(). The new block connects whenever HPD is high (9314-9315), so a display that was DPMS off before the sleep would get its link trained on wake with the CRTC still off. The unplugged branch (9316-9317) also doesn't clear hdmi_crtc_off. The two merge cleanly as text, but whichever lands second needs to skip the connect while hdmi_crtc_off is set and clear it on unplug.

Testing: the J773g table covers a display that stays connected. Missing are rows for the HDMI cable unplugged during sleep, the display DPMS off before sleep, and a refused sleep followed by a hotplug. A J713 Type-C external display row through deep sleep at this head would show the dcpext path unchanged.

Assisted-by: LLM (Claude:Opus 5.5)

dcp_s2r_ext_suspend() disconnects external displays via
dcp_external_disconnect(), dropping dptxport[0].connected and
deactivating the LPDPTX PHY, and stops DCPEXT firmware. On resume,
dcp_s2r_restart_done() re-enables Type-C reconnect work, which only
reattaches Type-C routes and leaves fixed HDMI outputs (such as J773g
dcpext0 with hdmi-hpd-gpios and no Type-C route) permanently
disconnected because the HPD IRQ is edge-triggered.

Factor fixed-HDMI HPD sampling and DPTX port 0 reconnection into
dcp_fixed_hdmi_reconnect() (shared with dcp_enable_dp2hdmi_hpd(),
logging any dcp_dptx_connect() error). Across dcp_s2r_ext_suspend(),
disable hdmi_hpd_irq while firmware is stopping (re-enabling it on
pre-stop refusals and leaving it disabled while firmware is crashed or
stopped so HPD edges cannot race a stopped coprocessor). In
dcp_s2r_restart_done(), re-initialize fixed HDMI rails/fabric
(dcp_fabric_hdmi_reinit() on native outputs, or hdmi_pwren/dp2hdmi_pwren
GPIOs otherwise), reconnect via dcp_fixed_hdmi_reconnect(), and
re-enable hdmi_hpd_irq via dcp_fabric_run_resume().

Signed-off-by: Diljit Singh <hey@djdev.me>
@DjDeveloperr
DjDeveloperr force-pushed the djdev/dcp-fixed-hdmi-s2r branch from 2bc65f4 to 266cdb8 Compare November 22, 2026 09:52
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

@RyanTheTide Thanks for the review! Rebased onto integration/aurora (32bf9dd3569d2) and force-pushed R2 (266cdb85feb43) addressing all items:

  1. Unified connect path & error logging: Factored dcp_fixed_hdmi_reconnect() shared between dcp_enable_dp2hdmi_hpd() and dcp_s2r_restart_done(), logging any dcp_dptx_connect() failure.
  2. PHY/crossbar reinit & no double-connect: Calls dcp_fabric_hdmi_reinit(dcp, "after deep sleep") on external_native outputs (falling back to hdmi_pwren/dp2hdmi_pwren GPIOs otherwise), followed by dcp_fixed_hdmi_reconnect(dcp, false) and dcp_s2r_hdmi_irq_enable(dcp) (dcp_fabric_run_resume()). dcp_fabric_hdmi_resume() only updates hybrid Type-C hdmi_presence settling when dcp_hdmi_settle_enabled() is true and never calls dcp_dptx_connect(), matching upstream dcp_enable_dp2hdmi_hpd().
  3. HDMI HPD IRQ disable/re-enable on suspend/stop failure: Disables hdmi_hpd_irq during dcp_s2r_ext_suspend(), re-enables it on pre-stop refusals (dcp_external_disconnect / iomfb_queue_settle) and via dcp_s2r_restart_failed_stop() -> dcp_s2r_restart_done() on dcp_s2r_stop_streams() / dcp_s2r_stop_crashed() failures, while intentionally keeping it disabled if firmware is crashed or down.
  4. #2503 (hdmi_crtc_off) coordination: #2503 is still open and not yet in integration/aurora, so dcp->hdmi_crtc_off is not present on this base; whichever lands second will guard reconnect on hdmi_crtc_off and clear it on unplug.
  5. Verification:
    • scripts/checkpatch.pl --strict --ignore FILE_PATH_CHANGES: 0/0/0.
    • Live hardware (dcp72-m4prod11-wave5-v7tc-s2r, M4 Mac mini J773g / T8132, 7.3.0-ARCH-m4prod11 with appledrm.s2r_untested): 2/2 consecutive real deep sleeps (rtcwake -d /dev/rtc1 -m mem -s 15, boot object resumes 0 -> 1 -> 2), dcp_fixed_hdmi_reconnect: DP2HDMI HPD connected:1 -> 3840x2160@120 Hz DSC=YES (card1-HDMI-A-1: connected, dpms=On) on both wakes, zero SErrors/BUGs/WARNs.

Assisted-by: LLM (Gemini:4 Neon)

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