Repository navigation
drm/apple: hold the HDMI unplug of a powered-off display in standby - #4495
RyanTheTide merged 5 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>
…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. Signed-off-by: Rolando Trevino <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.
Signed-off-by: Rolando Trevino <122947376+rolotrealanis98@users.noreply.github.com>
… a failed HPD read Two ways the held unplug of a powered-off HDMI display could be lost: - Every disconnected callback requeued the check with mod_delayed_work(), so a display that repeated the unplug every two seconds moved the 3 s deadline each time and was never reported. Queue it with queue_delayed_work(), which leaves a pending check's deadline alone, and cancel the check when HPD comes back (a connected callback while held), so the next unplug starts a deadline of its own. - dcp_hdmi_off_unplug_work() took a negative gpiod_get_value_cansleep() result as HPD high and returned with nothing pending. An unknown level is not a display: look again after DCP_HDMI_OFF_RETRY_MS (500 ms). tools/asahi/dcp-hdmi-standby-hold-tests.py compiles the hotplug branch and the worker unchanged against a millisecond model of delayed work and a scripted HPD line, and replays one unplug, a repeated unplug, a standby pulse, unplug-replug-unplug, a failed read followed by low and by high, and a hold ended by DPMS wake. Each fix has a mutation it catches. Signed-off-by: Rolando Trevino <122947376+rolotrealanis98@users.noreply.github.com>
There was a problem hiding this comment.
Verdict: MERGE at e5d091e
Checked: Replayed all seven HDMI standby cases on this replacement using GCC and Clang ASan/UBSan. Duplicate unplug callbacks leave the original deadline in place, a replug cancels it, and a failed HPD read queues a retry. The three mutations reproduced their respective failures with both compilers. Traced the fixed connector, DPMS wake and unbind cleanup, and checked the four replacement commits’ sign-off trailers. The J716s receipt describes the earlier #4317 build.
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
satchlj
left a comment
There was a problem hiding this comment.
Reviewed at e5d091ebc881 (code review only; J716s hardware re-row at this head pending as noted in Not yet).
- Scoping
hdmi_crtc_offindcp_poweroff()strictly to fixed HDMI outputs (hdmi_off_ready && !dcp_is_typec_output && hdmi_hpd && !active_typec_route) keeps Type-C and internal panels untouched. - Using
queue_delayed_work()on held unplugs indcpep_cb_hotplug()prevents repeated firmware disconnect callbacks from postponing the 3 s deadline, while cancellinghdmi_off_unplug_wqon a connected callback cleanly absorbs transient standby HPD pulses and resets the deadline for any later unplug. - Retrying after
DCP_HDMI_OFF_RETRY_MSwhengpiod_get_value_cansleep()fails avoids mistaking an I/O error for HPD high, andhdmi_off_lock+disable_delayed_work_sync()/enable_delayed_work()across unbind/bind/remove keep the worker lifecycle race-free. - Replay host test (
dcp-hdmi-standby-hold-tests.py) and its three mutations cover all timing and error branches cleanly.
Verdict: APPROVE.
|
Hardware row at exact head
|
The publication HPD fixture exercises Type-C only. Make it fail if the HDMI standby callback queues or cancels work, matching the helpers used by the callback. Signed-off-by: DjDeveloperr <hey@djdev.me>
|
Pushed On Rolot's J716s receipt verifies that the display stays dark in standby and wakes at its original mode on the production code at this head. The remaining case is a physical removal while the fixed HDMI output is off. On the same build, leave the HDMI cable out for more than three seconds, check that Refreshed the integration onto main 8f4ed47 (tree cda38e9300ed). Its only difference from integrating e5d091e onto the same base is the rate fixture. The five DCP rate cases passed, including publication-hpd. The HDMI standby replay passed all seven cases under GCC and Clang, and all three negative controls failed as intended under both compilers. The subsequent #4512 merge on main only changes G17 files and its test. |
There was a problem hiding this comment.
Verdict: MERGE at 24c71cb082c7e313ba3d382d9defb4362d95b920
Checked: The fast-forward changes only the publication-HPD host fixture. I re-ran the fixture with the exact updated source and Clang ASan/UBSan. It now compiles and passes. The new queue and cancellation stubs still assert if Type-C enters the fixed-HDMI standby path. The production HDMI and DCP sources match the previously reviewed commit.
RyanTheTide
left a comment
There was a problem hiding this comment.
Verdict: APPROVE at 24c71cb082c7e313ba3d382d9defb4362d95b920
Blockers: none on code (CI runs queued on 24c71cb082c7).
Checked:
- Verified
e5d091ebc881..24c71cb082c7touches onlytools/testing/selftests/drivers/gpu/apple-dcp/rate.py(+2/-1 lines replacing themod_delayed_workstub withqueue_delayed_workandcancel_delayed_workguards); all productiondrivers/gpu/drm/apple/files are byte-identical toe5d091ebc881, which already passed 2-familyK114s(T6050) +J713(T8132) bare-metal verification. - Audited
dcp-hdmi.c,dcp-hdmi.h,dcp-internal.h, anddcp.c:hdmi_crtc_offhold is gated strictly on hardware/route properties (hdmi_off_ready && !dcp_is_typec_output && hdmi_hpd && !active_typec_route), serialized underhdmi_off_lock, cleared on DPMS wake / hold drop, and torn down cleanly withdisable_delayed_work_sync()on unbind/remove.
|
Hardware row at head
|
|
Hardware row at exact head
|
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: host replay of the hold at e5d091e (7 cases, gcc and clang, each fix caught by a mutation), W=1 for drivers/gpu/drm/apple. The J716s HDMI standby row was taken at #4317's fdbba2c; a row at this head follows.
Risk: two-way door · every Mac with a fixed HDMI port (a DCP with an HDMI HPD line: MacBook Pro 14/16-inch M1 Pro and later, Mac mini, Mac Studio), and only while that output's CRTC is DPMS off; Type-C outputs and internal panels are unchanged.
Not yet: a J716s HDMI standby row at this head.
This replaces #4317 with the same change on a fresh branch (that branch's history isn't rewritten), plus the two fixes the review asked for, in the last commit:
queue_delayed_work(), which leaves a pending check alone, and a connected callback while held cancels it, so the next unplug gets its own deadline.dcp_hdmi_off_unplug_work()is no longer taken as HPD high: the worker looks again after 500 ms (DCP_HDMI_OFF_RETRY_MS).tools/asahi/dcp-hdmi-standby-hold-tests.py(registered inrun-host-tests.py) compiles the hotplug branch and the worker unchanged and replays: one unplug, the unplug repeated every 2 s (reported at 3 s), a standby pulse (nothing), unplug-replug-unplug (reported 3 s after the second), a failed read then low (reported at the retry), a failed read then high (nothing), and DPMS wake before the deadline (nothing, no check left pending). Mutationsmod-delayed-work,no-replug-cancelanderror-is-higheach fail a case.@jcrowthe confirmed the same wake loop on a Mac Studio M2 Ultra (J475d) HDMI port on #4317; thanks.
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