Repository navigation
drm/apple: hold the HDMI unplug of a powered-off display in standby - #4317
rolotrealanis98 wants to merge 3 commits into
Conversation
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>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
There was a problem hiding this comment.
💡 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".
| 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); |
There was a problem hiding this comment.
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 👍 / 👎.
| WRITE_ONCE(dcp->hdmi_crtc_off, false); | ||
| cancel_delayed_work(&dcp->hdmi_off_unplug_wq); |
There was a problem hiding this comment.
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 👍 / 👎.
| 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); |
There was a problem hiding this comment.
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>
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>
|
Pushed
The apple-dcp Hardware at
KUnit at |
|
Confirming this same wake loop reproduces on Mac Studio M2 Ultra (J475d, |
There was a problem hiding this comment.
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.
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_offis set. This does the same for the fixed HDMI output:dcp_poweroff()markshdmi_crtc_offwhen the HDMI output has HPD and no Type-C route.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.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:
hotplug connected:0→ re-add → display back on, every ~14 shotplug connected:1, nodcp_poweron; display stays offdrivers/gpu/drm/apple/display.kunitconfig): 344 tests, 343 passed, 1 skippeddcp.o,iomfb_v27.oandiomfb_v14_7.o: 0 warnings