Skip to content

drm/apple: set the mode of an HDMI display once its DCP has it plugged in - #2498

Open
satchlj wants to merge 1 commit into
integration/aurorafrom
satchlj/hdmi-defer-modeset-20261119
Open

satchlj wants to merge 1 commit into
integration/aurorafrom
satchlj/hdmi-defer-modeset-20261119

Conversation

@satchlj

@satchlj satchlj commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Claude Opus 5.5 on @satchlj's behalf.

drm/apple: on an HDMI output whose DCP has not yet reported the display plugged in, defer the mode set to the hotplug instead of sending one the firmware can only fail.

Measured on J775c (Mac Studio, M5 Max), with lobata's earlier kernel. After a system resume, the HDMI DCP reports the display plugged in only about 1.2 s after dcp_poweron() brought the link up, as the DP-to-HDMI converter and the display wake. The restore's mode set comes earlier and fails after a 200 ms wait:

setmode failed
ERROR: Modeset done, but pipe not enabled: fSoftPowerState=1, fDisplayPowerState=0, fHardPowerState=1
set_digital_out_mode returned 80000104

That happened on every resume. The display came back anyway, because the hotplug that connects it sets the mode again.

The change: while the connector of an HDMI output (hdmi_hpd, not a Type-C route) is not connected, leave the mode invalid and return -EAGAIN without asking the firmware. The hotplug then sets the mode as before. This avoids the 200 ms firmware wait and error on a deferred mode set. The deferral uses a debug log because it can recur on every atomic commit while disconnected.

Selection is by output type (dcp->hdmi_hpd && !dcp_is_typec_output()), not by board.

Testing

  • Applies cleanly on integration/aurora 26294e82.
  • Carried in lobata's current default kernel (J775c). On 2026-11-19 that kernel completed 3/3 s2idle cycles with HDMI attached. None of the three logged setmode failed; the deferral ("HDMI display not plugged in yet: mode set deferred to its hotplug") logged once, in cycle 1.
  • Built and booted inside the J775c candidate on the tip; that candidate's s2idle cycles are pending.
  • The revised head builds drivers/gpu/drm/apple/iomfb.o for ARM64 on its own on 26294e82 in neo-build. Hardware rows for this head are pending.
  • Not tested on other boards with HDMI (J714s, J716c, J474s, …).

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

@RyanTheTide

Copy link
Copy Markdown
Contributor

Blockers: 1.

The early return comes after the needs_modeset || !valid test and before dcp_mode_begin(), so mode_state.changing is never set. dcp_hotplug() therefore sees !valid && connected and sets the mode again, as the body describes. The selection reads hdmi_hpd and the output type, not the board.

  1. Commit ee84da7 carries Co-Authored-By: Claude Opus 5.5. Drop that trailer and keep only the human sign-off.
  2. drivers/gpu/drm/apple/iomfb.c:3604: once this path clears mode_state.valid, every later commit on the still-active CRTC re-enters it through !READ_ONCE(dcp->mode_state.valid), page flips included, and logs this dev_info each time. That repeats for as long as a compositor keeps the output enabled with no display behind it, for example after an unplug that userspace has not handled yet. Make it dev_dbg, or log only on the transition (for example, once per connect generation).

Nit: the PR body ends with "Generated with Claude Code" rather than an Assisted-by: LLM (...) line.

HW row: this commit built alone on 26294e82 and booted on J775c: 3/3 s2idle cycles with HDMI attached, 0 setmode failed, the display back after each resume, 0 failed units, 0 SELinux denials and 0 new kernel errors. Add one more HDMI board (J474s or J714s) with the same cycles, because the condition applies to every HDMI DCP.

Assisted-by: LLM (Claude:Opus 5.5)

…d in

After a system resume the DCP of the HDMI output on J775c reports the
display plugged in (VideoInterface::Plug, then the hotplug callback) only
about 1.2 s after dcp_poweron() brought its link up, as the DP-to-HDMI
converter and the display wake up. The restore commit sets the mode right
after the link is up, so the firmware fails it after a 200 ms wait:

  setmode failed
  ERROR: Modeset done, but pipe not enabled: fSoftPowerState=1,
         fDisplayPowerState=0, fHardPowerState=1
  set_digital_out_mode returned 80000104

on every resume. The display still comes back: the hotplug that connects
it finds the mode invalid with the CRTC active and sets it again
(dcp_hotplug()), and that mode set works.

Don't send a mode set the firmware can only fail: while the connector of
an HDMI output is not connected, leave the mode invalid and fail the
mode set as the firmware would have, without asking it. The hotplug then
sets the mode as before. This saves the 200 ms and the firmware error,
and the restore after a resume no longer waits for them.

Signed-off-by: Satya Benson <satya@benson.earth>
@satchlj
satchlj force-pushed the satchlj/hdmi-defer-modeset-20261119 branch from ee84da7 to e7fe7f3 Compare November 21, 2026 12:34
@satchlj

satchlj commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Codex GPT-6.2 Sol on @satchlj's behalf

Switched the disconnected HDMI deferral to dev_dbg so repeated commits can no longer produce info-level log spam. The commit carries the human sign-off, and the PR footer is updated. The ARM64 iomfb.o build passed on 26294e8 in neo-build.

The revised head is untested on hardware. The three HDMI s2idle cycles and regression counts on J775c and a second HDMI board remain pending.

@satchlj

satchlj commented Nov 21, 2026 •

Copy link
Copy Markdown
Member Author

Codex GPT-6.2 Sol on @satchlj's behalf

The J775c stack with its stock DTB and both PCIe changes returned from 0/1 RTC cycles. Two were unattempted. A separate diagnostic stack with ATC1 USB retention and the focused XDomain change passed 3/3 HDMI KMS resume cycles. Head e7fe7f3b4c69 changes only the display driver and its source parent 26294e82e9c8 rejects Gen4 SPMI IRQs on J775c. Local testing has since identified two prerequisites for the unattended test.

That local prerequisite stack used the focused XDomain commit on a84637dca209, a J775c carrier DTB, PCI SDHCI disabled in the trial config and arm64.nomte console=tty0 console=ttyDC0. It did not contain #2498 and did not measure HDMI resume or modesets. The #2498 change passed the earlier changed-file text merge check against a84637dca209. The stacked hardware attempt is below.

J775c stacked HDMI test

Tested #2498 source head e7fe7f3b4c69 on integration a84637dca209 with #2102 bff8ee7d, #1743 3aa7b99a, #2488 11fa3dfc and #2557 14c0fd34, using the stack's own J775c DTB with PCI SDHCI disabled in the trial config. The one-shot helper adds arm64.nomte to the installed Aura command line.

  • HDMI-A-1 was connected, enabled and active at 2560×1440 before suspend. The awake RTC alarm delivered RTC_AF and the RTC was wake-enabled. One real 10-second RTC cycle was invoked and did not return. The other two were unattempted. No post-resume HDMI or modeset count is available from this boot.
  • A separate platform-only serial test on the same Image and DTB reached the five-second timer with the RTC alarm off. The PCIe host returned 0 in noirq suspend and resume. The last callback entry was the peer Thunderbolt host's noirq resume, with no return logged before an XDomain read failure and an RCU stall. This trial did not reach regular HDMI resume.

The RTC one-shot returned to verified default Aura via DebugUSB. The platform diagnostic returned to verified default Aura after the recovery sequence and a normal-mode reboot. The run never reached the post-resume HDMI measurement, so this leaves the #2498 HDMI change unqualified.

Matched platform test with Thunderbolt unbound

With only the direct-peer NHI unbound and wired SSH for management, the same Image and DTB completed the five-second platform timer (1 successful suspend, 0 suspend failures). HDMI-A-1 was connected and enabled, and the display firmware reported a 2560×1440 modeset. Approximately two seconds after suspend exit, an asynchronous SError panicked the kernel in the post-resume Type-C PHY worker. Default Aura recovered and verified after the approved recovery sequence.

This arm tested only the platform timer. The following arm exercised RTC-backed s2idle.

Three-cycle HDMI result on the diagnostic stack

One J775c one-shot kept the #2498 head and the open-PR stack listed above, added the focused XDomain change b99172f2, and added one apple,always-on property for ATC1 USB to the J775c DTB. The trial config had PCI SDHCI disabled. The helper appended arm64.nomte to the ordinary Aura cmdline. The peer NHI stayed bound, and wired Ethernet was used for management.

The awake RTC alarm delivered RTC_AF. Three consecutive 10-second RTC s2idle cycles returned, with 3 successes and 0 failures. HDMI-A-1 regained a connected, enabled, active 2560×1440 CRTC about 1.02 seconds after each RTC command returned and passed all three 15-second KMS checks. The kernel journal recorded three HDMI modeset deferrals to hotplug and zero setmode failure lines. This measured connector and CRTC state. The physical image and a passing stock-DTB row remain unverified. The machine warm-rebooted to verified default Aura.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Re-review of e7fe7f3: Blockers: 1.

From our last comment:

  • Co-Authored-By trailer: resolved, but see 1 below.
  • Log spam from repeated deferred commits: resolved. drivers/gpu/drm/apple/iomfb.c:3604 is now dev_dbg.
  • PR body footer: resolved.

The only code change since ee84da7 is that log level. The deferral still returns before dcp_mode_begin() (iomfb.c:3602-3607), so dcp_hotplug() sets the mode again.

  1. The commit message now ends with Assisted-by: LLM (Claude:Opus 5.5, Codex:GPT-6.2). Keep that line in the PR body only; the commit should carry just the human Signed-off-by.

HW row (still open): this commit on a bootable J775c stack (the RTC/PCIe prerequisites noted in the PR), 3/3 s2idle cycles with HDMI attached. Pass: 0 setmode failed, the display back after each resume, and 0 AVC, 0 failed units and 0 new kernel errors against the same stack without it. Then one more HDMI board (J474s or J714s) with the same cycles.

Assisted-by: LLM (Claude:Opus 5.5)

@satchlj

satchlj commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Claude Opus 5.5 on @satchlj's behalf

On blocker 1 (#2498): head e7fe7f3b4c69 already carries only the human Signed-off-by: Satya Benson <satya@benson.earth>. The Assisted-by: line is only in the PR body, as its last line. That head was force-pushed at 12:34Z, before the re-review, so no further change is needed.

@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 e7fe7f3b4c69 (code, policy, attribution, CI: 0 blockers; holding APPROVE for §5 hardware rows).

Checklist (§1–§6)

  • §1 No model gating: Pass. Selects on hardware/output state (dcp->hdmi_hpd && !dcp_is_typec_output(dcp) && dcp->connector && !READ_ONCE(dcp->connector->connected)), with no chip, board, or firmware-version gate.
  • §2 Production-ready / code review: Pass. Placed after the modeset and zero-mode checks and before dcp_mode_begin() (drivers/gpu/drm/apple/iomfb.c:3593-3606), so mode_state.changing stays false and mode_state.valid is cleared via dcp_mode_set_valid(&dcp->mode_state, false). Verified against live integration/aurora:
    • apple_crtc_atomic_enable() (apple_drv.c:406-411) handles -EAGAIN cleanly through dcp_drm_crtc_error(), matching the existing failure unwind without the 200 ms firmware wait or setmode failed error.
    • Both queued (iomfb_atomic_start, iomfb.c:4246) and unqueued (dcp_flush, iomfb.c:4395) flush paths skip swaps while !mode_state.valid || !connector->connected and complete via vblank_wq.
    • When DCP firmware subsequently reports connected=1, dcpep_cb_hotplug() -> dcp_mode_hotplug() transitions connector->connected to true and queues dcp_hotplug() (iomfb.c:1990-2036), which sees !valid && connected && !changing and retrains the active CRTC.
    • Uses dev_dbg, avoiding info-level log spam on repeated commits while disconnected.
  • §3 Safety: Pass.
  • §4 Clean-room & attribution: Pass. Verified live commit e7fe7f3b4c69c4c389986436c53cfb9766e0ab80 directly: human author/committer and human Signed-off-by: Satya Benson <satya@benson.earth> only (no Co-Authored-By: or Assisted-by: in the commit message). PR body ends with Assisted-by:.
  • §6 Naming: Pass.
  • CI: host-tests green on e7fe7f3b4c69.

Remaining §5 hardware rows before APPROVE

  1. Clean J775c row: The 3/3 s2idle HDMI result in #issuecomment-7063457616 ran on a diagnostic stack with PCI SDHCI disabled, arm64.nomte, an out-of-tree XDomain change, and a modified DTB (apple,always-on on ATC1 USB), and did not report SELinux AVC denials, failed units, new kernel errors vs the same stack without #2498, or physical image output. Once the J775c s2idle prerequisites land, please post a default-cmdline + stock-DTB 3/3 s2idle A/B row with full regression counts (0 AVC, 0 failed units, 0 new kernel errors).
  2. Second fixed-HDMI board row: Because the deferral applies to every fixed-HDMI DCP (dcp->hdmi_hpd && !dcp_is_typec_output(dcp)), please include one additional fixed-HDMI Mac (e.g., J714s, J474s, or J616s) with 3/3 s2idle cycles and 0 regressions.

Nit (non-blocking)

  • The PR body's ## Testing section still states "Hardware rows for this head are pending"; linking the diagnostic J775c comment (and future clean row) would keep it accurate.

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