Skip to content

drm/apple: hold the HDMI unplug of a powered-off display in standby - #4317

Open
rolotrealanis98 wants to merge 3 commits into
aurora-silicon:mainfrom
rolotrealanis98:pr/apple-dcp-hdmi-standby-hold
Open

rolotrealanis98 wants to merge 3 commits into
aurora-silicon:mainfrom
rolotrealanis98:pr/apple-dcp-hdmi-standby-hold

Conversation

@rolotrealanis98

@rolotrealanis98 rolotrealanis98 commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

What: keep a powered-off fixed-HDMI display connected while it drops HPD going into standby, and report the unplug only if HPD is still low 3 s later. The hold ends on DPMS wake, on a new attachment, and at unbind.
Tested: J716s HDMI standby row at fdbba2c (in the comments), KUnit, host tests and W=1 (Testing below and in the comments).
Risk: two-way door. T6050 (M5) fixed HDMI output while its CRTC is DPMS off; Type-C outputs and internal panels are unchanged.

A display on the fixed HDMI port that goes to standby after DPMS off can drop HPD for about a second. The firmware reports that as an unplug (unplug_gated), dcpep_cb_hotplug() disconnects the connector, and the replug a moment later makes the compositor re-add the output and light it. The lock screen turns it off again, and the cycle repeats about every 14 s, so an idle desktop never stays dark.

The Type-C path already ignores this while typec_crtc_off is set. This does the same for the fixed HDMI output:

  • dcp_poweroff() marks hdmi_crtc_off when the HDMI output has HPD and no Type-C route.
  • While it's set, an unplug in dcpep_cb_hotplug() keeps the connector connected and schedules a 3 s check. dcp_poweron() clears the flag and reconnects the link as it already does.
  • If HPD is still low after 3 s, the check reports the unplug (disconnected_hpd_event()), so a real removal while the display is off still disconnects.

satchlj's #2503 (closed) also suppressed this unplug; this is a narrower take on the same problem.

Testing

J716s (M5 Pro 16"), dcpext1 HDMI, firmware 27.3, 2560x1600@165 monitor, Omarchy 4.6:

Case Before After
DPMS off, monitor enters standby (HPD low ~0.8 s) hotplug connected:0 → re-add → display back on, every ~14 s only hotplug connected:1, no dcp_poweron; display stays off
Idle cycle: screensaver 150 s → lock 300 s → lock-screen DPMS off wakes repeatedly stays off until unlock
Unlock after ~30 min off — 2560x1600@165 restored, no kernel warnings
  • KUnit (drivers/gpu/drm/apple/display.kunitconfig): 344 tests, 343 passed, 1 skipped
  • W=1 for dcp.o, iomfb_v27.o and iomfb_v14_7.o: 0 warnings
  • checkpatch: clean

A display whose HDMI CRTC is off goes to standby, and some drop HPD for
about a second as they do. The firmware reports that as an unplug, and
the replug after it makes the desktop light the returning display; the
lock screen turns it off again and the cycle repeats every ~14 s.

As for a powered-off Type-C output, keep the connector connected and let
dcp_poweron() connect the link again. HPD still low 3 s later is reported
as the unplug.

Signed-off-by: Rolando Trevino <122947376+rolotrealanis98@users.noreply.github.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-04T13:26:51.498754Z ca05cd7 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@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 Dec 4, 2026
@github-actions

github-actions Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

Merge readiness at fdbba2ce: not ready yet

Check Detail
CI at head ok 4 checks passed
Review no needs one approving review from Core, Omarchy Mac or Aurora Maintainers (not the author)
Requested changes no requested by aurora-silicon-review
Hardware row at head no no line with the head SHA fdbba2ce, a Mac and a result in the PR body or a comment
Conflicts ok none
PR text ok Risk: two-way · . T6050 (M5) fixed HDMI output while its CRTC is DPMS off; Type-C outputs and internal panels are unchanged. A display on the fixed HDMI port that goes to standby after DPMS off can drop HPD for about a second. The firmware reports that as an unplug (unplug_gated), dcpep_cb_hotplug() disconnects the connector, and the replug a moment later makes the compositor re-add the output and light it. The lock screen turns it off again, and the cycle repeats about every 14 s, so an idle desktop never stays dark. The Type-C path already ignores this while typec_crtc_off is set. This does the same for the fixed HDMI output: - dcp_poweroff() marks hdmi_crtc_off when the HDMI output has HPD and no Type-C route. - While it's set, an unplug in dcpep_cb_hotplug() keeps the connector connected and schedules a 3 s check. dcp_poweron() clears the flag and reconnects the link as it already does. - If HPD is still low after 3 s, the check reports the unplug (disconnected_hpd_event()), so a real removal while the display is off still disconnects. satchlj's #2503 (closed) also suppressed this unplug; this is a narrower take on the same problem.

Areas: area:display, area:gpu

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

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ca05cd72ff

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread drivers/gpu/drm/apple/dcp.c Outdated
cancel_work_sync(&dcp->t6040_link_work);
cancel_delayed_work_sync(&dcp->t6040_plug_wq);
cancel_delayed_work_sync(&dcp->s2r_prewarm_off_wq);
cancel_delayed_work_sync(&dcp->hdmi_off_unplug_wq);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Disable the HDMI timeout during component teardown

When a non-retained HDMI DCP is removed with hdmi_crtc_off set, this cancellation runs before component_del() shuts down the CRTC and firmware callbacks. dcpep_cb_hotplug() can therefore requeue the timeout during teardown, and neither dcp_comp_unbind() nor the resource-release path drains it again. The callback can subsequently access the released HPD GPIO or the dcp freed by dcp_release_context(), causing a use-after-free. Disable and drain this work during component unbind so that late firmware callbacks cannot enqueue it after cancellation.

Useful? React with 👍 / 👎.

Comment thread drivers/gpu/drm/apple/dcp.c Outdated
Comment on lines +5875 to +5876
WRITE_ONCE(dcp->hdmi_crtc_off, false);
cancel_delayed_work(&dcp->hdmi_off_unplug_wq);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Synchronize DPMS wake with an executing unplug check

If a DPMS wake overlaps the three-second timeout, dcp_hdmi_off_unplug_work() may already have read hdmi_crtc_off as true and sampled HPD low. cancel_delayed_work() does not wait for an executing callback, so clearing the flag here cannot prevent that callback from reporting a disconnect after wake has reconnected the link. This invalidates the restored mode and removes the output despite HPD being high. Synchronize the worker's check-and-report with wake, or synchronously drain it before reconnecting.

Useful? React with 👍 / 👎.

Comment thread drivers/gpu/drm/apple/dcp.c Outdated
return;
WRITE_ONCE(dcp->hdmi_crtc_off, false);
dev_info(dcp->dev, "HDMI display unplugged while its CRTC was off\n");
disconnected_hpd_event(dcp->connector);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Bind the delayed unplug to its original HDMI attachment

In the hybrid HDMI-yield path, dcp_typec_route_activate() can replace dcp->connector with a Type-C connector before the new CRTC is enabled. Its dcp_hdmi_drop_hold() call retires only the pre-existing blink hold; it neither clears hdmi_crtc_off nor cancels this new timeout. If the pending timeout runs with HDMI HPD low before Type-C power-on clears the flag, this call publishes a false unplug for the still-attached Type-C sink. Associate the timeout with the fixed HDMI attachment and retire it on route changes instead of reporting against the mutable current connector.

Useful? React with 👍 / 👎.

…und DCP

The held unplug of a powered-off HDMI output could outlive its reason:

- Unbind and remove only cancelled the timeout before firmware callbacks
  stopped, so a late cb_hotplug(0) could queue it again and run it after
  the DCP was released. Disable it first thing in dcp_comp_unbind() and
  in remove; dcp_comp_bind_pipe() enables it again.
- DPMS wake cleared the flag and cancelled without waiting, so a worker
  already past its check could report the unplug after the link came
  back. hdmi_off_lock now covers the worker's check and report, and the
  wake ends the hold under it.
- A Type-C display taking the pipeline (dcp_hdmi_drop_hold()) left the
  hold armed, and the worker reported against dcp->connector, by then the
  Type-C one. The hold now ends with the attachment, the worker gives up
  on an active Type-C route, and it reports the HDMI connector.

The apple-dcp and backlight host fixtures learn the new fields and helper.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: rolotrealanis98 <122947376+rolotrealanis98@users.noreply.github.com>
@github-actions github-actions Bot added the area:gpu Area from CODEOWNERS (bot) label Dec 4, 2026
system_wq is deprecated; the J716s run warned on the first hold
("work func dcp_hdmi_off_unplug_work enqueued on deprecated workqueue").
The check reads a GPIO and reports a hotplug: any CPU will do.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: rolotrealanis98 <122947376+rolotrealanis98@users.noreply.github.com>
@rolotrealanis98

Copy link
Copy Markdown
Contributor Author

Pushed 6ce952121d24 and fdbba2cec238 on top (normal pushes) for the three Codex findings:

  • Teardown (P1): dcp_comp_unbind() disables the timeout first thing, before any of its early returns, and remove does the same, so a late cb_hotplug(0) can't queue it once the DCP is going away. dcp_comp_bind_pipe() enables it again.
  • Wake race (P2): hdmi_off_lock covers the worker's check and report; DPMS wake ends the hold under it, so a worker already past its check can't report after the link is back.
  • Route change (P2): dcp_hdmi_drop_hold() ends the hold too; the worker gives up on an active Type-C route and reports fixed_connector, not dcp->connector.
  • fdbba2ce queues the check on system_dfl_wq; the J716s warned about system_wq on the first hold.

The apple-dcp publication-hpd / stale-crtc-poweroff and backlight-coldboot host fixtures learn the new fields and helper.

Hardware at fdbba2cec238: J716s (MacBook Pro 16-inch, M5 Pro), dcpext1 HDMI, firmware 27.3, 2560x1600@165 monitor. Kernel 7.3.0-g2f1563239302 = the J716s daily with this branch's three commits (the daily has no dcp_hdmi_drop_hold(), so the route-change path isn't exercised on this board), HDMI-port DTB from #4300.

Case Result
DPMS off on HDMI-A-1, monitor enters standby (HPD low 0.8 s) cb_hotplug() holding unplug of powered-off HDMI output, then only connected:1; no disconnect, no re-add
3 s check after the HPD came back no report
Left off for 180 s stayed off (dpmsStatus: 0), connector connected
DPMS on 2560x1600@165 restored
Warnings no workqueue warning; scanout stop was not confirmed on each power-off, as on e1292792 before these commits

KUnit at 6ce95212: dcp-fabric 122/122, dcp-topology 242 passed + 1 skipped, dcp-display 343 passed + 1 skipped. W=1: 0 warnings for dcp.o, dcp-hdmi.o, iomfb_v27.o (and iomfb_v12_3.o/iomfb_v13_3.o at fdbba2ce).

@github-actions github-actions Bot added blast:m5 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) and removed needs-hw-row No hardware row at the PR head (bot) needs-template PR body lacks Tested or Risk (bot) labels Dec 4, 2026
@jcrowthe

jcrowthe commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

Confirming this same wake loop reproduces on Mac Studio M2 Ultra (J475d, apple,t6022, os-fw 13.5, system-fw 26.6.2, linux-aurora 7.3.0-6-1-ARCH, aura 1.0.0b18) with a Dell U2718Q on die-1 HDMI (dcpext0_die1). Running an equivalent hdmi_crtc_off hold patch locally stops the repeated wake loop on DPMS off.

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

Verdict: FINISH, then merge at fdbba2c

Failure: The held-unplug branch in iomfb_template.c:3367–3372 calls mod_delayed_work() on every disconnected callback. A replay held physical HPD low and sent duplicate disconnected notifications every two seconds. At twelve seconds the connector was still connected because each notification moved the three-second deadline. Keep the deadline for the same held unplug so duplicate callbacks cannot postpone it indefinitely.

Failure: dcp.c:5729–5731 treats a negative GPIO read result as asserted HPD and returns without scheduling another check. In the exact worker replay, one -EIO at the deadline lost the unplug. HPD then read low again, but the connector stayed connected with no pending work. Handle the read error separately from a high HPD level.

Failure: Commits 6ce952121d24 and fdbba2cec238 contain AI co-author trailers. Please provide the same fix on a fresh branch with human attribution and without force-pushing the existing branch.

Checked: Both timeout failures reproduced with GCC and Clang. A single uninterrupted low, a standby pulse that returned high, DPMS wake and unbind all passed in the offline replay. Reviewed the whole diff, including route checks and the fixed connector selection. The J716s hardware result is the author's.

@github-actions github-actions Bot added changes-requested A reviewer requested changes (bot) needs-hw-row No hardware row at the PR head (bot) labels Dec 5, 2026

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:m5 Macs affected, from Merge risk (bot) changes-requested A reviewer requested changes (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)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants