Skip to content

drm/apple: assert fixed HDMI HPD before waiting for its link - #2499

Open
satchlj wants to merge 2 commits into
integration/aurorafrom
satchlj/hdmi-fw27-early-hpd-20261119
Open

satchlj wants to merge 2 commits into
integration/aurorafrom
satchlj/hdmi-fw27-early-hpd-20261119

Conversation

@satchlj

@satchlj satchlj commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Claude Opus 5.5 on @satchlj's behalf.

drm/apple: report HPD immediately after request_display on a fixed HDMI connector with an HPD GPIO, before waiting for the link.

The boot loader can initialize the HDMI display and leave it on its default surface. When Linux then requests the port again, the AP HPD is withheld until after the link wait. The inherited port can report modes but never completes fresh training, and Linux withdraws it after two seconds.

The change selects the early assertion from the fixed HDMI connector and HPD GPIO. It uses the boot loader's assertion order, with GPIO errors and unplug routed through the existing release path. Borrowed Type-C routes retain their HPD and tunnel timeouts, and the driver's dedicated late-HPD path keeps its order.

A selftest, tools/testing/selftests/drivers/gpu/apple-dcp-early-hpd.py, covers the order.

Testing

  • Applies cleanly on integration/aurora 26294e82.
  • Carried in lobata's current default kernel (J775c, Mac Studio M5 Max), whose HDMI display comes up from the loader's surface at every boot.
  • Built and booted inside the J775c candidate on the tip.
  • The revised head builds drivers/gpu/drm/apple/dcp.o for ARM64 on its own on 26294e82 in neo-build. The early-HPD host selftest passed in normal and ASan/UBSan builds, and all 35 DCP lifecycle cases passed.
  • Hardware validation of the revised head is pending on J775c, another firmware-27 HDMI Mac, and a 14.x HDMI Mac.

Assisted-by: LLM (Claude:Opus 5.5, Codex:GPT-6.2)

@satchlj

satchlj commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

Claude Opus 5.5 on @satchlj's behalf: the host-tests failure on this PR was ours. The first commit moved the HPD assertion into dcp_assert_hpd_before_link_wait(), and the apple-dcp fast-replug-bounce fixture, which extracts dcp_dptx_connect_raw(), then no longer built.

The new commit extracts the real helper into that fixture, with the two fields and the HPD GPIO it reads. The fixture is a Type-C H17P link, so the helper's firmware-27 fixed-HDMI branch is not taken, and the GPIO stub asserts that. On alba, run.py passes 88 of 89. The exception is m4-power-gate, which doesn't build on macOS (no EREMOTEIO) and isn't touched here. CI will give the Linux result.

🤖 Generated with Claude Code

@RyanTheTide

Copy link
Copy Markdown
Contributor

Blockers: 2.

  1. drivers/gpu/drm/apple/dcp.c:2315: the early HPD is selected by dcp->fw_compat == DCP_FIRMWARE_V_27_0. The problem the PR describes is a fixed HDMI port that the loader left configured, and that is not a firmware version. Key the branch on the port's own state (fixed HDMI connector with an hdmi_hpd GPIO, for every firmware), or on a property that shows the loader left the port configured. Then run it on an HDMI Mac on the 14.x firmware too. If 14.x must not get HPD before the link wait, the commit message should say what goes wrong there, with a trace.
  2. Both commits carry a Co-Authored-By: Claude ... trailer. Drop it and keep only the human Signed-off-by. The PR body ends with "Generated with Claude Code"; the last line should be Assisted-by: LLM (Claude:Opus 5.5).
  3. dcp.c:2296-2311: the new helper and its comment are inserted between dcp_dptx_connect_raw()'s doc comment (2296-2303) and that function. The "Connect DPTX port @PORT ..." block now documents dcp_assert_hpd_before_link_wait(). Move the helper above that comment.

I checked the error paths. A GPIO read error or a low level returns before any RPC; connected is cleared and the request is released through out_release. The Type-C and tunnel branches behave as before. The post-wait dptxport_set_hpd() at 2520 is not reached for an HDMIA connector, so HPD is not asserted twice. The PR says the head has not been built on its own and the selftest has not been run on the tip; both are needed before merge.

HW row: this head on its own, on J775c and on at least one other HDMI Mac on firmware 27 (an M4 Pro Mac mini or a J714s). For each: cold boot with the loader driving HDMI, mode set, 10 replugs, display up within the training deadline every time, 0 SELinux denials, 0 failed units, 0 new kernel errors. Add a 14.x HDMI Mac if the firmware check is dropped.

Assisted-by: LLM (Claude:Opus 5.5)

A loader-initialized HDMI display can keep its default surface while
Linux requests the port again. With AP HPD withheld until after the link
wait, the inherited port can report modes but never finish training,
and Linux withdraws it after two seconds.

For a fixed HDMI connector with an HPD GPIO, report its level right
after request_display so training can start before the link wait.
Select the path from the connector and GPIO on every firmware. The
existing late-HPD path keeps its order, and borrowed Type-C routes
keep their own HPD and tunnel timeouts.

Signed-off-by: Satya Benson <satya@benson.earth>
The previous commit moved the HPD assertion before the link wait out of
dcp_dptx_connect_raw() into dcp_assert_hpd_before_link_wait(). The
fast-replug-bounce fixture extracts dcp_dptx_connect_raw() and so no
longer built. Extract the helper as well, with the fields and the HPD
GPIO it reads. The fixture is a Type-C H17P link, so the helper's
fixed-HDMI branch is not taken, and its GPIO stub asserts
that.

Signed-off-by: Satya Benson <satya@benson.earth>
@satchlj
satchlj force-pushed the satchlj/hdmi-fw27-early-hpd-20261119 branch from d5679f8 to e48f8f1 Compare November 21, 2026 12:34
@satchlj satchlj changed the title drm/apple: assert firmware 27 HDMI HPD before waiting for its link drm/apple: assert fixed HDMI HPD before waiting for its link Nov 21, 2026
@satchlj

satchlj commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Codex GPT-6.2 Sol on @satchlj's behalf

Early HPD now follows a fixed HDMI connector with an HPD GPIO, and the helper sits above the dcp_dptx_connect_raw() comment. The shared HPD-high RPC has no 14.x-specific ordering requirement in the driver. The dedicated late-HPD path retains its order. Both commits carry the human sign-off, and the PR footer is updated. The ARM64 dcp.o build and normal and ASan/UBSan early-HPD host tests passed on 26294e8, along with all 35 DCP lifecycle cases.

The revised head is untested on hardware. The cold-boot, mode-set, ten-replug and regression rows remain pending on J775c, another firmware-27 HDMI Mac and a 14.x HDMI Mac.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Re-review of e48f8f1: Blockers: 1.

Points from the last review:

  1. Firmware-version selector: resolved. drivers/gpu/drm/apple/dcp.c:2305-2308 now selects the early HPD from a fixed HDMIA connector with an hdmi_hpd GPIO, on every firmware.
  2. Co-author trailers: resolved. Both commits carry only the human Signed-off-by, and the body ends with the Assisted-by: line.
  3. Helper splitting the dcp_dptx_connect_raw() doc comment: resolved. The helper is at dcp.c:2297-2321, above that comment.

New point, which comes from dropping the firmware check:

  1. dcp.c:2464-2469 with 2312-2320: on this base a fixed HDMI port never got an AP HPD from dcp_dptx_connect_raw(). The old code asserted it only for Type-C, and the post-wait dptxport_set_hpd() at 2519 is for DisplayPort or late_hpd only. So this is not just a reorder. Every non-desktop HDMI Mac on 13.x/14.x firmware (M1/M2 Mac mini, the 14/16-inch MacBook Pros, Mac Studio) now gets an HPD-high RPC it never got before. It also gets two new ways to fail the connect: a low GPIO sample returns -ENOLINK, and an RPC error releases the display at out_release. Neither has run on that firmware. Run the row below on one such Mac before merge. If the firmware there rejects or times out the call, the commit message needs to say why, and the helper should only skip the RPC when the firmware has nothing to train, not by version.

The rest of the change is sound. The GPIO is sampled under hpd_mutex, which is a sleeping lock, so gpiod_get_value_cansleep() is fine there. Both error returns clear connected and release the display. The desktop 26.x fixed HDMI output takes dcp_desktop_dptx_connect() (dcp.c:3121-3122), so it is not affected. The Type-C, tunnel (8000 ms) and late_hpd paths keep their old behaviour, and the selftest covers each of them.

HW row: this head on the current integration/aurora tip (it is 370 commits behind), default command line, on J775c and on one HDMI Mac on 13.x/14.x firmware, e.g. a 14-inch M1 Pro MacBook Pro or an M1/M2 Mac mini. For each: cold boot with HDMI attached, a mode set, 10 replugs with the display up inside the training deadline every time, one boot with no HDMI attached followed by a hot plug, 0 AVC, 0 failed units, 0 new kernel errors.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor

Merge-train adversarial review (MERGETRAIN-LINUX2) at e48f8f1: BLOCKERS.

Not merging until the blockers below are fixed or answered; the details give file:line and a failure case.

Full review

#2499 drm/apple: assert fixed HDMI HPD before waiting for its link @e48f8f15

VERDICT: BLOCKERS

Head is 490 commits behind 24dc422. Since the merge base (26294e8) the base has picked up
f2bf265 (#527, "keep a DP2HDMI connect when no link configuration arrives"). That commit
touches the same function and the same selftest fixture as this PR. The text merge is clean,
but the semantic merge is not.

Blockers:

  1. tools/testing/selftests/drivers/gpu/apple-dcp/lifecycle.py (merged :801-802): the merged
    tree's fast-replug-bounce host test does not build. drm/apple: keep a DP2HDMI connect when no link configuration arrives #527 already added bool hdmi_hpd;
    after struct { bool active; } split; in that fixture's struct (merged :601-602). This PR's
    swap() adds int fixed_connector_type; void *hdmi_hpd; after the same line. clang:
    host.c:103:7: error: duplicate member 'hdmi_hpd'. Verified: run.py --group lifecycle gives
    35/35 on 24dc422 and 34/35 on 24dc422+e48f8f15 (not ok 8 - fast-replug-bounce), so
    host-tests will go red once this merges. Fix: rebase, and in the swap change drm/apple: keep a DP2HDMI connect when no link configuration arrives #527's
    bool hdmi_hpd to void * (or add only fixed_connector_type).
  2. drivers/gpu/drm/apple/dcp.c merged :2305-2327 vs :2340-2350 and :2514-2521: the base's drm/apple: keep a DP2HDMI connect when no link configuration arrives #527
    rests on the premise that a 13.5-firmware DP2HDMI output "is never asked to detect the sink"
    and so never sends a link configuration. That is why its timeout is non-fatal. This PR makes
    dcp_assert_hpd_before_link_wait() send dptxport_set_hpd(true) before the wait on every
    non-Type-C HDMI-A connector with hdmi-hpd-gpios. That covers exactly the J473 (M2 Mac
    mini, t8112-j473.dts:46,49) on which drm/apple: keep a DP2HDMI connect when no link configuration arrives #527 was proven, plus t600x J314/J316, t602x J414/J416,
    J474s, J475c, J180d and the T6030/T6040/T6041/T6050 HDMI dtsis. After the merge:
    (a) the drm/apple: keep a DP2HDMI connect when no link configuration arrives #527 comments at :2341-2348 and :2515-2516 are false;
    (b) on the J473 an HPD RPC error now ends the connect at out_release (:2477-2481), where
    drm/apple: keep a DP2HDMI connect when no link configuration arrives #527 kept the display up;
    (c) if the GPIO reads low between dcp_enable_dp2hdmi_hpd()'s sample (:4960) and the new one
    (:2316), the connect fails with -ENOLINK, which on base it never did.
    The PR has to reconcile with drm/apple: keep a DP2HDMI connect when no link configuration arrives #527: either drop the dp2hdmi special case because the
    firmware now trains, or explain why both are needed. It also needs the J473 row below.
    Ryan's last re-review already asked for a 13.x/14.x HDMI row; drm/apple: keep a DP2HDMI connect when no link configuration arrives #527 makes it concrete.

Nits:

  • dcp.c merged :2316-2318: a low GPIO sample returns -ENOLINK, and :2479 then logs it at
    dev_err ("failed to assert AP HPD: -67"). A fast unplug while connecting is not a driver
    error, so log that case at dbg/info.
  • The helper's comment (:2298-2303) says "as the working loader does after request_display".
    That describes loader behaviour without a reference. Cite the aura code or a trace.
  • Commit hygiene is clean at this head: both commits carry only Satya Benson's Signed-off-by.
  • No chip, board or firmware gate is added: the selector is the DT connector type plus the GPIO.

Missing rows (none exist for e48f8f1; the PR says the revised head is untested on hardware):

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

Pre-PR checklist review at e48f8f15693f: REQUEST_CHANGES (guaranteed CI build breakage on merge with live integration/aurora, semantic conflict with merged #527, and zero hardware runs on the revised head).

Blockers

  1. Guaranteed host-tests build breakage on merge (tools/testing/selftests/drivers/gpu/apple-dcp/lifecycle.py):

    • This branch is based on 26294e82 (~490+ commits behind live integration/aurora). Live lifecycle.py:601-602 (from merged #527, f2bf2657) already defines bool hdmi_hpd; directly after struct { bool active; } split; inside the fast-replug-bounce fixture's struct apple_dcp.
    • This PR's swap() inserts int fixed_connector_type; void *hdmi_hpd; after the exact same line, creating a duplicate member (error: duplicate member 'hdmi_hpd') that breaks fast-replug-bounce as soon as it merges. Rebase onto current integration/aurora and reconcile the struct field in lifecycle.py.
  2. Direct semantic conflict & regression risk with merged #527 (f2bf2657) in drivers/gpu/drm/apple/dcp.c:

    • Live dcp.c:2314-2324 and 2496-2504 (dp2hdmi path for DCP_FIRMWARE_V_13_5, proven on J473 M2 Mac mini) explicitly rely on dcp_dptx_connect_raw() not calling dptxport_set_hpd(true) on fixed HDMI ports (making the linkcfg timeout non-fatal).
    • This PR makes dcp_assert_hpd_before_link_wait() send dptxport_set_hpd(service, true) before dcp_dptx_wait_linkcfg() on every non-Type-C DRM_MODE_CONNECTOR_HDMIA with dcp->hdmi_hpd across all firmware lines (13.5, 14.x, 26.x, 27.x), and aborts the connect via goto out_release; on either a low GPIO read (-ENOLINK) or an HPD RPC error.
    • Rebase onto integration/aurora, reconcile explicitly with #527's dp2hdmi path (either proving 13.5/14.x trains cleanly with early AP HPD and updating/removing the #527 workaround, or keying cleanly on hardware/firmware capability without breaking 13.5/14.x), and verify on hardware.

Other checks (§1–§6 / CI)

  • §1 No model gating: Pass (selects on fixed_connector_type == DRM_MODE_CONNECTOR_HDMIA + hdmi_hpd GPIO, no firmware/board gate).
  • §2 Production-ready / §3 Safety: Pass in isolation, pending #527 reconciliation above.
  • §4 Clean-room & attribution: Pass. Both commits carry human author/committer + human Signed-off-by: only; PR body ends with Assisted-by:.
  • §6 Naming: Pass.
  • CI: host-tests passed only against the stale base 26294e82; will fail on merge until blocker 1 is fixed.
  • §5 Evidence: Revised head e48f8f15693f has no hardware test rows. After rebasing and fixing blockers 1–2, please provide default-cmdline rows on:
    • J775c (fw 27): cold boot with HDMI attached, modeset, 10× replugs, cold boot without HDMI -> hotplug;
    • J473 M2 Mac mini (fw 13.5, #527 machine) and one 14.x or T6040 fixed-HDMI Mac: same matrix proving no regression (failed to assert AP HPD absent, display lit every time);
    • Full regression counts (0 AVC denials, 0 failed units, 0 new kernel errors).

Nits (non-blocking)

  • Logging -ENOLINK from a low HPD GPIO at dev_err (dcp.c:2460) treats a normal unplug race during connect as a driver error; consider dev_dbg/dev_info for -ENOLINK.
  • The comment in dcp_assert_hpd_before_link_wait() cites "as the working loader does after request_display" — citing the Aura reference or trace would make that concrete.

Assisted-by: LLM (Gemini 4 Neon)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants