Skip to content

drm/apple: hold the HDMI unplug after the converter's power-up HPD blink - #3667

Open
RyanTheTide wants to merge 5 commits into
mainfrom
fix/j473-hdmi-hpd-poweron-glitch
Open

RyanTheTide wants to merge 5 commits into
mainfrom
fix/j473-hdmi-hpd-poweron-glitch

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

What

When dcp_poweron() lights a display on a built-in HDMI port, the DP-to-HDMI converter powers up and drops HPD for 1-2 s. About 10 s after HPD fell, the DCP firmware reports the display unplugged and, half a second later, plugged again. The compositor sees a real disconnect/reconnect; Mutter 51.1 sometimes answers with every CRTC off, and the monitors stay dark until the next DPMS cycle (#3658).

This holds a firmware unplug that arrives in a window after that power-up blink: the mode is invalidated (as for a Type-C relink) but the connector stays connected, and the firmware's replug retrains the mode. A real unplug is still reported: if HPD is low (or unreadable) one debounce interval later, or if the firmware hasn't replugged within the window. Outside the window nothing changes. Scope: only DCPs with a fixed HDMI-A connector and hdmi-hpd-gpios in the device tree. The 500 ms debounce gets a name (DCP_HDMI_HPD_DEBOUNCE_MS); the window reuses DCP_HDMI_HOLD_MS.

Tested

  • J473 at 7ad8a08 (this head; main 972a566 + both commits), signed m2combo32 Stage 2, row dsc8-a, 2026-11-30: pass. Full DPMS battery x6 relit 24/24, 19 held unplugs each ended by the firmware's replug, 0 DCP crashes/oopses/WARNs, 0 failed units, Enforcing; saved default restored and verified.
  • J616s (M4 Pro, T6041, built-in HDMI port empty) at 7ad8a08, kernel-only, row j616s-dsc8, 2026-11-30: pass, boot Enforcing, 0 failed units, internal eDP mode list identical, no new DCP errors.
  • KUnit at 7ad8a08: dcp-fabric 121/121 incl. the route-handover case hdmi_blink_handover_test; display 180/181, topology 210/211 (1 skip each). Host --only dcp 69/69, --only apple-dcp 1/1. checkpatch --strict clean.
  • Earlier head: J473 at 106a783 (main 972a566 + this), signed m2combo32 Stage 2, row dsc7-a, 2026-11-30: pass. Full DPMS battery x6 (off/on x2, DPMS-off s2idle + on, forced off + detect per batch): relit 24/24 checks (the same battery on m2combo32 without this: 4/6 and 5/6 batches), 18 held unplugs each followed by the firmware's replug, no HDMI disconnect except the battery's deliberate forced-off step, 0 DCP crashes/oopses/WARNs, Enforcing. Saved default restored and verified.
  • Earlier head: J616s (M4 Pro, T6041, built-in HDMI port empty) at 106a783, kernel-only, row j616s-dsc7, 2026-11-30: pass, boot Enforcing, 0 failed units, internal eDP mode list identical to production, no new DCP errors.
  • KUnit (arm64 QEMU): dcp-fabric 120/120 incl. 3 new cases (glitch held, persisting low reported, outside window unchanged); display 180/181 and topology 210/211 (1 skip each).
  • Host tests: --only dcp 69/69, --only apple-dcp 1/1. checkpatch --strict clean.

Risk

Risk: two-way · every Mac with a built-in HDMI port (fixed HDMI-A + hdmi-hpd-gpios: M1/M2/M3/M4 Pro/Max laptops, Mac mini M2/M2 Pro/M4, Studio): a real HDMI unplug within ~10 s of a DPMS on is reported up to one debounce interval later.

Not yet

  • A genuine HDMI unplug/replug on the J473 with this fix (staffed; queued for Ryan).
  • A J616s row with an HDMI display attached to its own HDMI port (staffed; queued).
  • The issue's synthetic forced-off -> detect failure goes through another path and isn't addressed here.

When dcp_poweron() lights the HDMI display of a built-in HDMI port, the
DP-to-HDMI converter powers up and drops HPD for one to two seconds. The
HPD handler only logs the low edge and debounces the rising one, so the
kernel reports nothing. The DCP firmware, however, loses its link to the
converter: about ten seconds after HPD fell it reports the display
unplugged, and half a second later plugged again. On a J473 (Mac mini
M2) with macOS 27.2 firmware that happens on every DPMS on, with HDMI on
either DCP. The pair reaches the compositor as a disconnect and a
reconnect; Mutter sometimes answers with a configuration that has every
CRTC off, and the displays stay dark until the next DPMS cycle.

Track the blink per HDMI port: a HPD fall within DCP_HDMI_HOLD_MS of
dcp_poweron() starts it, the rise that holds for the debounce interval
ends it and opens a window of DCP_HDMI_HOLD_MS. An unplug the firmware
reports in that window is held: the display's mode is invalidated, as for
a Type-C relink, but the connector stays connected. The firmware's replug
ends the hold and retrains the active mode through the hotplug worker, as
any replug with no valid mode does. The unplug is still reported when HPD
is low (or cannot be read) one debounce interval later, checked again
every interval, or when the firmware has not plugged the display again
within DCP_HDMI_HOLD_MS. Unplugs outside the window are reported at once,
as before.

The state is part of the HDMI port object, which exists only for a DCP
with a fixed HDMI-A connector and an HDMI HPD GPIO in its device tree.
The 500 ms HPD debounce gets a name, DCP_HDMI_HPD_DEBOUNCE_MS, next to
the HDMI executor that applies it; DCP_HDMI_HOLD_MS moves to dcp-hdmi.h.
The apple-dcp host harness that builds dcpep_cb_hotplug() gets stubs for
the two new calls.

Link: #3658
Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>

@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 HPD hold is admitted on the fixed HDMI connector, but the deferred report resolves the mutable DCP connector again. If HDMI yields and Type-C binds that DCP during the hold, the worker can report the unplug against the new sink, or a firmware replug can retire the old hold. Bind the deferred action to the held attachment and invalidate it on yield or rebind. Please cover the route handover in a regression. The J473 relight run is useful evidence for the blink case. Genuine unplug and peer-family regressions remain.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Code-owner ping (6-point merge rule, point 6): @aurora-silicon/core @aurora-silicon/omarchy-mac @aurora-silicon/aurora-maintainers, this touches drivers/gpu/drm/apple/ (HDMI hotplug on every Mac with a built-in HDMI port). Rows at head 106a783: J473 dsc7-a (DPMS battery x6, 24/24 relit) and J616s j616s-dsc7 (boot, unchanged). Plan: merge with --admin once CI is green, an App review approves, and nobody objects within 1 h. Revert: git revert -m1 <merge>. A review or objection from any of you blocks the merge.

A held HDMI unplug was admitted on the fixed HDMI connector, but its
deferred report and the replug that ends it looked up dcp->connector
again. The hybrid DCP can change hands during the hold: the HDMI display
yields, and a Type-C display takes the pipeline. The deferred check could
then report the unplug against the Type-C sink, and that sink's own plug
could retire the HDMI hold.

Record what the hold was taken on: the fixed HDMI connector and the DCP's
attachment generation (modes_generation, which every route activation
and attachment change already advances). The deferred check, the replug
and a repeated unplug act only while the DCP still drives that same
attachment; otherwise the hold and its window are dropped without a
report. A DCP that yields its HDMI display or drives a Type-C route has
no HDMI attachment at all. The yield and the Type-C route activation
also drop the hold explicitly, before the connector changes. The yield
already reports the HDMI display gone, so dropping the hold there matches
it.

Cover the route handover in KUnit: a hold across a yield and a Type-C
bind, a replug after the handover, the HDMI display back on a new
attachment, and the explicit drop.

Link: #3658
Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Thanks, addressed in 7ad8a08 (a new commit on top of 106a783).

Held attachment: when the hold starts it now records what it was taken on: the fixed HDMI connector and the DCP's attachment generation (modes_generation, which every route activation and attachment change already advances). If the HDMI display has yielded, or the DCP is on a Type-C route, the DCP has no HDMI attachment, so no hold can be taken.

Deferred report and replug: the delayed check, the firmware replug that ends a hold, and a repeated unplug all compare the DCP's current attachment with the recorded one, under the hold's lock. If they differ, the hold and its window are dropped without a report. The deferred report then reports against the recorded HDMI connector, not dcp->connector. A Type-C sink's plug can no longer retire the HDMI hold, and a late check cannot unplug the Type-C sink.

Yield and rebind: dcp_hdmi_yield_link() and the Type-C route activation also drop the hold explicitly, before the connector changes. This follows the existing yield semantics: the yield already reports the HDMI display gone through disconnected_hpd_event(), so the held unplug is dropped and not reported a second time.

Regression: the new KUnit case hdmi_blink_handover_test covers a hold active when the HDMI display yields and a Type-C display binds, the deferred check and a later firmware replug after the handover (neither touches the Type-C sink or ends anything), the HDMI display coming back on a new attachment, and the explicit drop. The three existing cases are unchanged. Results at 7ad8a08: KUnit apple-dcp-fabric 121/121, display 180/181 (1 skipped), topology 210/211 (1 skipped); host tests --only dcp 69/69 and --only apple-dcp 1/1; checkpatch --strict clean. Hardware rows on the J473 kit are still to come.

@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 generation and sink checks plus the handover regression address the stale held event after a completed rebind. Please confirm serialization for a concurrent handover: route activation drops unplug_lock before publishing the new generation and connector, while the worker holds unplug_lock while sampling and reporting. The test covers a completed route change, so it does not establish that an event cannot be admitted or reported during publication. Keep on hold for that check and current-head J473, genuine unplug, HDMI peer and hosted evidence.

@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 fabric lock prevents a fresh hold window from opening across Type-C publication. The drop clears the existing hold under the same mutex as the worker before the generation and connector change. This addresses my route-publication concern. Keep current-head J473, genuine unplug, HDMI peer and hosted validation before landing.

The cold-boot backlight harness builds the production dcp_poweron(),
which now notes the HDMI converter's power-up for the unplug hold.
Give the harness a no-op stub for it, like its other power helpers.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Pushed b7f8c7b (test-only, no force push): backlight-coldboot-tests builds the production dcp_poweron() and failed on the new dcp_hdmi_powered_on() call (implicit declaration). It now has a no-op stub like its other power helpers. Local: host tests --only backlight 4/4, --only hdmi 7/7, --only dcp 69/69; checkpatch clean. No kernel file changed since 7ad8a08, so the J473 dsc8-a and J616s j616s-dsc8 rows (built from 7ad8a08) cover this head's kernel.

@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: MERGE at b7f8c7b7 after the remaining hosted and hardware gates.

Checked: The sole delta from the reviewed and J473-tested head is the no-op callback stub in the extracted host fixture. It does not replace a backlight assertion. Both independent host invocations passed and all five negative controls still rejected the injected errors. Retain the J473 receipt at its tested Image and the outstanding physical disconnect and HDMI peer checks.

@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-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 30, 2026
@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Merge readiness at 218e24f0: not ready yet

Check Detail
CI at head no failing: host-tests
Review no approved by DjDeveloperr, but GitHub does not count it yet (code owner from Core or Omarchy Mac needed, or approval went stale)
Requested changes ok none
Hardware row at head ok comment at 218e24f0
Conflicts ok none
PR text ok Risk: two-way · every Mac with a built-in HDMI port (fixed HDMI-A + hdmi-hpd-gpios: M1/M2/M3/M4 Pro/Max laptops, Mac mini M2/M2 Pro/M4, Studio): a real HDMI unplug within ~10 s of a DPMS on is reported up to one debounce interval later.

Areas: area:display, area:gpu

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

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Re-ran the full Linux host suite locally from a detached checkout of this exact head, b7f8c7b75757. 838/838 passed in 243 seconds, including both backlight cold-boot invocations and all five compiled negative controls.

ok backlight-coldboot-tests (0.3s)
ok backlight-coldboot-tests --negative-controls (1.5s)
838/838 passed in 243s

The GitHub-hosted rerun is still queued. The hardware evidence remains tied to the previously tested 7ad8a08f runtime, and the physical disconnect and HDMI-attached peer results remain open.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

The hosted run tested merge 97c4308c from b7f8c7b7 and old main 94104a69. Both backlight cold-boot invocations passed. The only failure in 837/838 was Apple DCP TAP #90, probe-transaction-rollback. Linux #3672 adds the missing fixture stub.

An isolated merge preview of the same PR head on main 45d7f828, tree 68c32794, passed 846/846 host cases in 174 seconds. TAP #90 and both backlight invocations passed. GitHub was still serving the older merge ref when checked. Please verify the merge ref includes #3672 before rerunning hosted CI. The physical HDMI rows and counted review remain open.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

CI note: host-tests at b7f8c7b failed one case, apple-dcp not ok 90 - probe-transaction-rollback (837/838 passed). That's a USB/Type-C provider case this PR doesn't touch, and --only apple-dcp passes locally both at b7f8c7b and with b7f8c7b merged into current main 42169a0. Re-running the failed job once.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Pushed 6eec2b7 (merge of main 42169a0, no rebase/force). The host-tests failure at b7f8c7b was not from this PR: CI tested it merged onto main 94104a6, where #3587 had broken the apple-dcp probe-transaction-rollback (tipd_init) harness; main fixed that in 6c910c2 (stub cd321x_replug_kept_attach), and reruns keep the old merge commit, so they failed the same way. Other branches pass host-tests on the same runners. The PR's own diff against main is unchanged. Local at 6eec2b7: host tests --only apple-dcp 1/1, --only dcp 69/69, --only backlight 4/4, --only hdmi 7/7. The J473 rows (dsc8-a) cover the PR's code; the next J473 candidate built from main will be re-rowed in full.

@github-actions github-actions Bot added ci-failing A check failed at the PR head (bot) merge-conflict Conflicts with the base branch (bot) labels Dec 1, 2026
DjDeveloperr
DjDeveloperr previously approved these changes Dec 2, 2026

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No blocking findings. I checked lock order (iomfb.lock, then the hold lock, then modes_lock, with only short steps under the hold lock), the delayed check against the firmware unplug and replug, drop and yield, teardown (every unbind path goes through dcp_hdmi_disable), and the real-unplug paths: HPD low after the debounce, a failed HPD read, and the 10 s cap. Macs without a fixed HDMI port have dcp->hdmi == NULL, so nothing changes for them.

Non-blocking, take what's useful:

  1. dcp_hdmi_disable() (dcp-hdmi.c ~505). It stops the check, then clears the hold without the hold lock. An unplug that lands in between is held and then wiped without a report. Suspend's HPD-low check covers a real unplug there. A one-line guard closes it: have dcp_hdmi_hold_unplug() refuse a hold when hdmi->enabled is false.
  2. The replug that ends a hold (iomfb_template.c ~3316) keeps the cached EDID. A monitor swapped inside the window keeps the old EDID. apple_connector_invalidate_edid() there covers it.
  3. The Risk line overstates scope. Desktop 26.x firmware (dcp_desktop_dp2hdmi_hpd), T6030 (dcp_v14_external_hotplug) and the M4 mini's iomfb_m4.c path never take a hold. Saying which firmware lines are covered helps the next reader.

Left before merge: a merge-up (it conflicts with main again), green CI at the merged head (the KUnit failures shown are other drivers' cancelled jobs), and the row still owed: a real cable pull 3-8 s after a DPMS on, with the disconnect reaching userspace within about half a second (J473), at the merged head or with the PR's files unchanged.

@github-actions github-actions Bot removed the needs-review No approving review from Core or Omarchy Mac yet (bot) label Dec 2, 2026
Signed-off-by: DjDeveloperr <hey@djdev.me>
@DjDeveloperr

Copy link
Copy Markdown
Contributor

Merged main into the branch as 218e24f0800b (merge commit, no rebase). Three conflicts:

  • iomfb_template.c: main added dcp_typec_fw_hotplug() (record each firmware hotplug) right where this PR adds the HDMI hold. The hold goes first, so a held unplug returns before it is recorded, the same as the relink, powered-off Type-C and T6040 relink early returns above it. A replug still reaches the record.
  • backlight-coldboot-tests.py and apple-dcp/rate.py: both sides' stubs are kept.

The merge's diff against main matches this PR's own diff in all 9 files. Local checks in the CI-pinned host-test container (aurora-linux-host-tests:ubuntu2404): apple-dcp passes (204 s), and backlight-coldboot passes 2/2 including the negative controls. dcp.c, dcp-hdmi.c, dcp-fabric.c, iomfb_v12_3.c and iomfb_v13_3.c compile with 0 warnings against a warm arm64 config. Left before merge: hosted CI at this head, re-approval at the merged head (I pushed it), and the J473 row from the review: a real cable pull 3 to 8 s after a DPMS on, with the disconnect reaching userspace within about half a second. This PR's files are unchanged, so a row on the PR's files at the old head also counts.

@github-actions github-actions Bot added needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) and removed ci-failing A check failed at the PR head (bot) merge-conflict Conflicts with the base branch (bot) labels Dec 2, 2026

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approve at 218e24f0800b.

The main merge differs from a clean git merge-tree of its parents only in the three conflicted files, and each is resolved right:

  • iomfb_template.c: the HDMI hold returns before main's dcp_typec_fw_hotplug(), like the relink, powered-off Type-C and T6040 holds above it. That record is only read by Type-C paths and by iomfb_watch_unplugged_present_h17p(), which checks dcp_is_typec_output(), so skipping it for the fixed HDMI port changes nothing. A replug still reaches it.
  • backlight-coldboot-tests.py and apple-dcp/rate.py: both sides' stubs are kept.

Checked on pc at this head:

  • make W=1 drivers/gpu/drm/apple/ plus dcp-fabric-test.o and dcp-fabric-core.o (with the fabric KUnit test enabled): 0 warnings.
  • KUnit dcp-fabric on UML (no QEMU): 121/121, including the four hdmi_blink_* cases.
  • run-host-tests.py --only apple-dcp and --only backlight-coldboot (2/2 with the negative controls) in the pinned host-test container: pass.
  • Merges cleanly with current main.

My non-blocking notes from 12-02 still apply: refuse a hold once hdmi->enabled is false, re-read the EDID on the replug that ends a hold, and narrow the Risk line to the firmware lines that take a hold.

Before merge: hosted CI, and the J473 row: a real HDMI cable pull 3 to 8 s after a DPMS on, with the disconnect reaching userspace within about 0.5 s. The merge was pushed from this account, so it needs another approver or an admin merge.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

J473 row at exact head 218e24f0: DPMS part PASS; genuine-unplug part still open (needs hands)

Mac mini M2 (J473), Acer 1920x1080 on the built-in HDMI port (card1-HDMI-A-1). A = saved 7.3.0-aurora-fleet94; B = one-shot 7.3.0-mrows3667 built from 218e24f0800b with the fleet config. (DRM_APPLE_DISPLAY_KUNIT_TEST had to be turned off: since this head merges main, it hits the #3410 modpost break appledrm.ko: symbol 'snd_pcm_lib_preallocate_free' undefined with DRM_APPLE=m + SND=m. That option only gates test code.)

A fleet94 B 218e24f0
DPMS battery: 6x (Mutter PowerSaveMode off 6 s -> on, check 16 s later) 6/6 relit, connected, CRTC active; 0 DRM hotplug uevents 6/6 relit, connected, CRTC active; 0 DRM hotplug uevents
further unattended relights (B only, 45-min window, every 40 s) - 68/68 stayed connected, no status change
HDMI: hold/drop/report lines - none: the converter's blink-unplug did not occur on this monitor in these cycles, so no hold was exercised
DCP crashes / WARN / Oops 0 / 0 / 0 0 / 0 / 0

So no false disconnect was introduced and nothing regressed. A software-only real unplug isn't possible on this J473: the Acer is on the built-in HDMI port, and the only Type-C partner is a USB hub. I armed the Mac on B for 45 minutes with a logger and a 10-second hands step for Ryan (pull the HDMI cable 3-5 s after a relight); it wasn't used, so "a genuine unplug 3-8 s after DPMS on is still reported" remains untested. The kit and logger are ready to re-arm. Restored afterwards: saved fleet94, test kernel removed, SELinux Enforcing, HDMI connected. (The only failed unit on B was speakerguardd-v2-switchtest, the speaker self-check on a non-fleet kernel, unrelated.)

@github-actions github-actions Bot removed the needs-hw-row No hardware row at the PR head (bot) label Dec 2, 2026
@github-actions github-actions Bot added the ci-failing A check failed at the PR head (bot) label Dec 3, 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:all Macs affected, from Merge risk (bot) ci-failing A check failed at the PR head (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.

2 participants