Skip to content

drm/apple: serialize HDMI suspend release under fabric lock - #3214

Open
AxxzyWasTaken wants to merge 1 commit into
aurora-silicon:mainfrom
AxxzyWasTaken:pr/dcp-suspend-hdmi-lock
Open

AxxzyWasTaken wants to merge 1 commit into
aurora-silicon:mainfrom
AxxzyWasTaken:pr/dcp-suspend-hdmi-lock

Conversation

@AxxzyWasTaken

@AxxzyWasTaken AxxzyWasTaken commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Closes: #3071

What: Align the suspend-side HDMI release path in dcp_platform_suspend() with the resume-side dcp_hdmi_unplugged_in_sleep() helper by moving it into dcp_hdmi_suspend() in drivers/gpu/drm/apple/dcp-fabric.c and sharing the unplugged release logic via dcp_hdmi_release_unplugged_locked():

  • Hold dcp_typec_fabric_lock across the dcp->active_typec_route check, link release, and hybrid fabric presence update (called after disable_irq(dcp->hdmi_hpd_irq) so IRQ synchronization never nests under the fabric mutex).
  • Treat only an explicit gpiod_get_value_cansleep(dcp->hdmi_hpd) == 0 reading as unplugged, preventing transient negative GPIO errnos from dropping a live HDMI display across sleep.
  • Call dcp_fabric_hdmi_unplugged_locked(dcp) when releasing a connected HDMI display whose HPD is explicitly low (including unplugged T6030 native outputs), without arming a spurious 10 s presence hold on already-disconnected ports, while still cleaning up any stale dptxport[0] link.
  • Kick hybrid_wq in dcp_hdmi_capacity_available() so a yielded Type-C port still recovers after wake once the resume settle hold expires after a suspend-time unplug (when hybrid_wq was disabled).
  • Extend tools/asahi/dcp-hdmi-sleep-unplug-tests.py and tools/asahi/run-host-tests.py to cover the suspend helper, negative GPIO errnos, idle/stale-DPTX links, borrowed native pipelines, and fabric lock placement around disable_irq() across 12 killed mutations.

Tested: make ARCH=arm64 LLVM=1 drivers/gpu/drm/apple/ and W=1 drivers/gpu/drm/apple/dcp.o drivers/gpu/drm/apple/dcp-fabric.o: clean, 0 warnings.

  • tools/asahi/run-host-tests.py --only dcp-hdmi-sleep-unplug: 13/13 passed (control + 12 killed mutations under ASan/UBSan).
  • tools/testing/selftests/drivers/gpu/apple-dcp/run.py: 96/96 passed; tools/asahi/run-host-tests.py --only dcp: 71/71 passed; --only display-sleep-merge (1/1), --only tunnel-route (1/1), --only tiled-split (2/2).
  • scripts/checkpatch.pl --strict --git HEAD~1..HEAD: 0 errors, 0 warnings, 0 checks.

Not yet: Boot and suspend/resume testing on Apple Silicon hardware with an attached HDMI display or T6030 native HDMI output.

Risk: two-way · all Macs with fixed or hybrid HDMI outputs (dcp suspend/resume HDMI release path; plain revert restores previous behavior).

dcp_platform_suspend() checked dcp->active_typec_route without
dcp_typec_fabric_lock, treated negative gpiod_get_value_cansleep()
errors (<= 0) as unplugged, and disconnected the HDMI connector and
DPTX port without calling dcp_fabric_hdmi_unplugged_locked().

That diverged from the resume-side dcp_hdmi_unplugged_in_sleep() in
three ways: a concurrent Type-C route transition could race the check
and release, a transient GPIO read error could drop a live HDMI display
whose HPD stays high after wake (leaving it dark), and an HDMI display
unplugged before suspend left hybrid HDMI/Type-C fabric state stale
because dcp_hdmi_unplugged_in_sleep() returns early once the connector
is already disconnected.

Move the suspend-side HDMI release into dcp_hdmi_suspend() in
dcp-fabric.c, called after disable_irq(dcp->hdmi_hpd_irq) so IRQ sync
never nests under dcp_typec_fabric_lock, and share the unplugged
release path with dcp_hdmi_unplugged_in_sleep() via
dcp_hdmi_release_unplugged_locked():

- Hold dcp_typec_fabric_lock across the active_typec_route check, link
  release, and fabric presence update (preserving the established
  dcp_typec_fabric_lock -> hpd_mutex -> tb_lock and
  dcp_typec_fabric_lock -> dcp_peer_lock lock orders).
- Treat only an explicit gpiod_get_value_cansleep(dcp->hdmi_hpd) == 0
  reading as unplugged so negative GPIO errnos keep an attached link.
- Notify dcp_fabric_hdmi_unplugged_locked() when releasing a connected
  HDMI display whose HPD is explicitly low (including T6030 native
  outputs that are unplugged at suspend), without arming a spurious
  presence hold when no HDMI display was connected; release a stale
  DPTX port link if connected without an active DRM connector.
- Kick hybrid_wq in dcp_hdmi_capacity_available() so a yielded Type-C
  port still recovers once the resume settle hold expires after a
  suspend-time unplug (when hybrid_wq was disabled).

Extend tools/asahi/dcp-hdmi-sleep-unplug-tests.py and
tools/asahi/run-host-tests.py to cover the suspend helper, GPIO errors,
idle/stale-DPTX links, borrowed native pipelines, and fabric lock
placement around disable_irq() across 12 killed mutations.

Signed-off-by: AxxzyWasTaken <[email protected]>
@AxxzyWasTaken
AxxzyWasTaken requested review from a team and DjDeveloperr as code owners November 26, 2026 08:29
@github-actions github-actions Bot added area:display Area from CODEOWNERS (bot) area:gpu Area from CODEOWNERS (bot) blast:all 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) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 26, 2026
@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Merge readiness at f1e87917: not ready yet

Check Detail
CI at head ok 20 checks passed
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head ok comment at f1e87917
Conflicts ok none
PR text ok Risk: two-way · all Macs with fixed or hybrid HDMI outputs (dcp suspend/resume HDMI release path; plain revert restores previous behavior).

Areas: area:display, area:gpu

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

@github-actions github-actions Bot added ci-failing A check failed at the PR head (bot) and removed ci-failing A check failed at the PR head (bot) labels Nov 26, 2026

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The new suspend helper keeps the fabric lock across the route-ownership check and link release. HPD IRQ synchronization remains outside the lock, and only an explicit low reading is treated as unplugged. The exact-head host fixture passed. I also checked that the native-release, GPIO-error and borrowed-native controls fail with their corresponding mutations. Code approved. Hold for hosted CI and the affected HDMI hardware paths: attached suspend/resume, unplug while asleep, Type-C recovery on a hybrid route, and a native T6030 output.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Tested f1e8791 on J473 (M2 mini, fixed DP2HDMI output on dcp 271c00000 with an Acer on HDMI, plus an MSI on USB-C): PASS, as part of a batch boot.

Kernel: 7.3.0-aurora-ibg14b = main d8c60437 + no-ff merges of #3250 c12e5891, #3238 d1c27c87, #3230 f6a5d7a1 and #3214 f1e87917 (each head is an ancestor; the only conflict was the tools/asahi/run-host-tests.py registry). Signed combo27 config, combo27 J473 Stage 2, saved production options. Host tests on the composed tree: fw-window-gc 11/11, try-bind 10/10, legacy-wq-prepub-abort 10/10, dcp-hdmi-sleep-unplug 13/13.

Row (one guarded one-shot, restored to fleet89 after):

  • Desktop row: GNOME session, vkcube, glxgears, WebGL; all sinks muted.
  • 3 short s2idle cycles (rtc, 15 s) with HDMI + USB-C displays attached, plus 1 after load: 4/4 rc=0, triangle/vkcube pass after each, HDMI DCP powered back with HPD connected each time.
  • Heavy compute 3 rounds (gpubench-vk light, heavy, alu and bw at depths 1..64): 12/12 ok, klog_bad 0.
  • GL render.postfx 8/8 loops, then 10 fresh Vulkan clients 10/10. GNOME shell PID unchanged for the whole boot.
  • 0 GPU faults, timeouts, recoveries or firmware crashes. Enforcing, 0 failed units.
  • The one red check is AVC=2, both from restorecon writing the harness's own Firefox log file (setfiles_t on var_lib_t). That is fixture noise, not this kernel.

Evidence: traces/gpu/20261129-ib-g14batch/20261129-005245-j473-ibg14b-a.

For this PR: 4 s2idle cycles with HDMI attached. Each resume logged dcp_poweron: DP2HDMI HPD connected:1, the output was back and the GPU checks passed after each one. There were no DCP errors or fabric warnings. This row didn't include an unplug during sleep.

@RyanTheTide

Copy link
Copy Markdown
Contributor

code-owner ping <@422957901716652033> / @DjDeveloperr: merge train at f1e87917. The App approved this head. Rows: J473-exact-head, display. This merges under the 6-point rule 1 h from now, once hosted CI is green, unless you object.

@github-actions github-actions Bot removed ci-failing A check failed at the PR head (bot) needs-hw-row No hardware row at the PR head (bot) labels Nov 28, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor

Status of the remaining hardware cases from the review:

  • Attached suspend/resume: done. J473 fixed DP2HDMI with an Acer on HDMI, 4/4 s2idle cycles with the output back each time (drm/apple: serialize HDMI suspend release under fabric lock #3214 (comment)).
  • Unplug while asleep (J473) and Type-C recovery on a hybrid route (K114s dcpext0 Type-C → HDMI): both need a cable moved by hand. They're queued as one combined physical item for the next staffed J473/K114s window.
  • Native T6030 output: there's no M3 Pro/Max in the lab. I've asked for it from outside; failing that it needs a maintainer disposition here.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Merge-train review at f1e87917: Verdict: merge after the three remaining hardware cases REVIEW6 listed (08:28): HDMI unplugged while asleep, Type-C recovery on a hybrid route, and native T6030 output. The App approval and the J473 4/4 s2idle-with-HDMI row stand. I found no code issue beyond that review. The cable cases need hands (RYAN-QUEUE) and T6030 needs an M3 Pro/Max owner (<@422957901716652033>?).

@RyanTheTide

Copy link
Copy Markdown
Contributor

Baseline for the unplug-while-asleep case (J473, Ryan's hands, 14:35): on m2combo30, which does not contain this PR, pulling the Acer HDMI during s2idle and replugging after wake leaves HDMI-A-1 disconnected. At resume the dcpext DPTX remote-port command 7 times out (-110), and the later HPD irq fires but triggers no hotplug. Evidence: traces/display/20261129-j473-3214-hdmi-pull/. The same row on a kernel carrying this PR (f1e87917) is queued for the next hands slot. It will show whether releasing the link at suspend avoids the stuck remote port.

This branch has not been deployed

No deployments
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:all Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

drm/apple: dcp_platform_suspend() HDMI release lacks fabric lock, drops link on GPIO error, and skips fabric unplug

2 participants