Skip to content

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

Merged
RyanTheTide merged 1 commit into
mainfrom
djdev/dcp-fixed-hdmi-s2r
Nov 26, 2026
Merged

RyanTheTide merged 1 commit into
mainfrom
djdev/dcp-fixed-hdmi-s2r

Conversation

@DjDeveloperr

@DjDeveloperr DjDeveloperr commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Tested: J773g M4 Mac mini at 266cdb85feb4 in the tested display stack. HDMI returned at 3840×2160 at 120 Hz after 2/2 deep sleeps with appledrm.s2r_untested. Test results.

Risk: Two-way door. This changes when fixed-HDMI outputs reconnect and when their hotplug interrupts are enabled during DCP resume.

Not yet: A J773g pass on the default kernel command line and a second-generation regression row.

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.

@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)

@github-actions github-actions Bot added area:display Area from CODEOWNERS (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) needs-template PR body lacks Tested or Risk (bot) labels Nov 24, 2026

@satchlj satchlj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Gemini 4 Neon on @satchlj's behalf

Verdict at 266cdb85feb4

Approve. Fixed-HDMI DPTX reconnection and hdmi_hpd_irq gating across dcp_s2r_ext_suspend() / dcp_s2r_restart_done() are cleanly paired and leave Type-C DCPEXT paths untouched.

Blockers

None.

Checked

  • 2 changed files (drivers/gpu/drm/apple/dcp-internal.h, drivers/gpu/drm/apple/dcp.c) audited in full against surrounding dcp.c suspend/resume and unbind paths.
  • IRQ pairing & failure paths: dcp_s2r_hdmi_irq_disable() / dcp_s2r_hdmi_irq_enable() track s2r_hdmi_irq_disabled to prevent unbalanced IRQ disable/enable calls. Pre-stop refusals (dcp_external_disconnect, iomfb_queue_settle) re-enable hdmi_hpd_irq; post-stop failures (dcp_s2r_stop_streams, dcp_s2r_stop_crashed) unwind via dcp_s2r_restart_failed_stop() -> dcp_s2r_restart_done(), while crashed/stopped firmware intentionally keeps the IRQ disabled.
  • Unified reconnect & Type-C isolation: dcp_fixed_hdmi_reconnect() shares HPD sampling and dcp_dptx_connect(dcp, 0) error logging between dcp_enable_dp2hdmi_hpd() and dcp_s2r_restart_done(). dcp_s2r_restart_done() re-initializes external_native HDMI fabric via dcp_fabric_hdmi_reinit() (or hdmi_pwren/dp2hdmi_pwren GPIOs otherwise) and re-enables hdmi_hpd_irq through dcp_fabric_run_resume(&dcp_resume_ops, dcp). Type-C DCPEXT paths remain unaffected (hdmi_hpd_irq == 0, !dcp_is_typec_output(dcp) && dcp->hdmi_hpd && !READ_ONCE(dcp->active_typec_route)).
  • CI & trailers: host-tests SUCCESS, MERGEABLE, commit carries clean Signed-off-by: with zero AI trailers; exact-head 266cdb85feb4 J773g 2/2 real deep-sleep HDMI reconnect row (3840x2160@120 Hz DSC=YES) is posted.
  • Non-blocking note: Keep the #2503 (hdmi_crtc_off) coordination and any remaining requested edge-case rows (cable unplugged during sleep, DPMS-off, J713 Type-C) tracked as whichever PR lands second merges.
  • Untested scope: Static code audit only (userspace-only review environment; no kernel build or boot performed here).
Evidence
  • Checked dcp.c (dcp_resume_ops, dcp_fixed_hdmi_reconnect, dcp_s2r_hdmi_irq_*, dcp_s2r_ext_suspend, dcp_s2r_restart_done, dcp_s2r_restart_failed_stop, dcp_unbind) at 266cdb85feb4.
  • CI at head 266cdb85feb4: host-tests SUCCESS.

@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Merge readiness at 266cdb85: ready to merge

Check Detail
CI at head ok 2 checks passed
Review ok approved by satchlj
Requested changes ok none
Hardware row at head ok in the PR body at 266cdb85
Conflicts ok none
PR text ok Risk: two-way · . This changes when fixed-HDMI outputs reconnect and when their hotplug interrupts are enabled during DCP resume.

Areas: area:display
Merge: gh pr merge 2771 --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.

@github-actions github-actions Bot added door:two-way Revertible or not, from Merge risk (bot) ready-to-merge Meets the merge policy: merge it (bot) and removed needs-review No approving review from Core or Omarchy Mac yet (bot) needs-hw-row No hardware row at the PR head (bot) needs-template PR body lacks Tested or Risk (bot) labels Nov 25, 2026
@RyanTheTide
RyanTheTide merged commit e0bc96e into main Nov 26, 2026
4 checks passed
@RyanTheTide
RyanTheTide deleted the djdev/dcp-fixed-hdmi-s2r branch November 27, 2026 13:21
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) 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