Skip to content

display: hand a lit external AFKv2 DCP on running (J274 27.2 HDMI) - #564

Merged
RyanTheTide merged 1 commit into
mainfrom
fix/t8103-hdmi-afkv2-handoff
Nov 28, 2026
Merged

RyanTheTide merged 1 commit into
mainfrom
fix/t8103-hdmi-afkv2-handoff

Conversation

@sithglan

@sithglan sithglan commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

What: Hand lit external AFKv2 DCP displays on running via dcp_hand_on() instead of timing out in rtkit_sleep() on macOS 27.2 (fixing J274 HDMI handoff, generalizing #451's dptx-port rule into display_dcp_hands_on()). Companion kernel PR: aurora-silicon/linux#3552.
Tested: J274 (M1 Mac mini, T8103, macOS 27.2.1) at 66355a0fd255: cold boot with HDMI 1920x1200@60 hands DCP on running and Linux adopts dcp-live-v1 cleanly (0 DART faults, 0 failed units); headless boot sleeps DCP cleanly in 0.4 ms — PASS. J473 (M2 Mac mini, T8112, 27.2 stub) regression row at 66355a0fd255 (thanks @RyanTheTide): PASS. Host clang-format, Stage 1/2 builds, pytest tests/python: 1251 passed, 26 skipped.
Risk: two-way · AFKv2 external-display Macs on 27.2 (J274; also M1/M2 Studios, Mac mini with HDMI on disp0). Headless external boots, 13.5/AFKv1 external displays, internal panels, and existing AFKv2 dptx-port controllers keep their previous paths.
Not yet: M1/M2 Mac Studio (disp0 / dispext4) hardware verification on macOS 27.2.

Details

Problem

On M1 Mac mini (J274 / T8103) with macOS 27.2.1 firmware, /arm-io/dcp drives HDMI directly (display_is_external = true, display_is_dptx = false) over an AFKv2 disp0-service iBoot interface. Once HDMI is powered on and modeset, display_shutdown(DCP_SLEEP_IF_EXTERNAL) calls rtkit_sleep() which times out (rtkit(dcp): AP power transition timed out), leaving dcp_running = true so subsequent chainload/Linux handoff fails with Display handoff failed; returning to proxy.

This is the same 27.2 firmware behaviour addressed for AFKv2 dptx-port controllers (M2 Mac mini J473) in #451, except display_dptx_hands_on() only matched display_is_dptx. Headless J274 boots (connected:0, never powered on) still sleep cleanly in ~0.4 ms.

Change

  • Add dcp_ib_is_afkv2() in src/dcp_iboot.{h,c} exposing afk_epic_is_v2(iboot->epic).
  • Track display_external_lit in src/display.c when an external display is powered on in display_configure() (cleared in display_start_dcp() and display_shutdown()).
  • Generalize display_dptx_hands_on() into display_dcp_hands_on() to match both AFKv2 dptx-port controllers and lit external AFKv2 displays, evaluated before dcp_ib_shutdown() frees iboot.
  • Extend tests/python/test_display_dptx_hand_on.py to cover lit external AFKv2 (hands on running), headless external AFKv2 (keeps sleep), AFKv1 external (keeps sleep), and internal AFKv2 (keeps quiesce); update tests/python/test_t8103_iboot_power_status.py harness.

Note: Linux adoption of the live T8103 dcp-live-v1 session also needs the companion 4 KiB alignment fix in dcp_rtkit_live_parse() for T8103's firmware-placed crashlog buffer (ep=1, iova=0x276000, is_mapped=1), submitted in aurora-silicon/linux#3552.

Evidence
  • J274 (M1 Mac mini, T8103, macOS 27.2.1 main OS) at 66355a0fd255:
    • Cold boot with HDMI (1920x1200@60) plugged in via enrolled Stage 1: modeset succeeded (570 ms), display: handing the DCP on running (external AFKv2 display), published dcp-live-v1 (v12, 3 system buffers, epmap 0000051f 00821fff), and Linux apple-dcp adopted the live RTKit session cleanly (card1-HDMI-A-1: connected, enabled, boot scanout retired by displayed swap 3, 0 DART faults, 0 failed units).
    • Headless boot (HDMI unplugged) on patched Stage 2: connected:0, slept DCP cleanly in 0.4 ms (pmgr: resetting device 0.DISP0_CPU0).
  • Host: clang-format clean, Stage 1 builds cleanly (_file_vital_end 0x11cff8 of 0x120000, headroom 12296 B, no __TEXT_BOOT_EXEC), Stage 2 (ESP_STAGE2=1) builds cleanly, full pytest tests/python: 1251 passed, 26 skipped.

On M1 Mac mini (J274, T8103) running macOS 27.2.1 firmware, /arm-io/dcp
drives HDMI directly (display_is_external = true, display_is_dptx = false)
over an AFKv2 disp0-service iBoot interface. Once the display has been
powered on and modeset, rtkit_sleep() times out waiting for the AP power
transition ("rtkit(dcp): AP power transition timed out"), leaving
dcp_running = true so subsequent handoff fails ("Display handoff failed;
returning to proxy") — the same 27.2 firmware behaviour handled for
AFKv2 dptx-port controllers in #451.

Without a connected display (headless, connected:0), display_configure()
returns before powering on the display and rtkit_sleep() still succeeds
in <1 ms, so the headless path keeps sleeping the DCP.

Add dcp_ib_is_afkv2() and generalize display_dptx_hands_on() into
display_dcp_hands_on() so a lit external AFKv2 display is handed on
running via dcp_hand_on() and published to Linux through
apple,rtkit-handoff ("dcp-live-v1"). Evaluate display_dcp_hands_on()
before dcp_ib_shutdown() frees iboot.

Tested:
- J274 (M1 Mac mini, T8103, macOS 27.2.1 main OS):
  - Cold boot with HDMI (1920x1200@60) plugged in via enrolled Stage 1:
    modeset succeeded, "display: handing the DCP on running (external
    AFKv2 display)", published live RTKit session v12 (3 buffers,
    epmap 0000051f 00821fff), Linux 7.3.0 apple-dcp adopted dcp-live-v1
    seamlessly (fb0 appledrmfb, 1920x1200@60, 0 DART faults, 0 failed
    units).
  - Headless boot (HDMI unplugged) on patched Stage 2: connected:0,
    slept DCP cleanly in 0.4 ms ("pmgr: resetting device 0.DISP0_CPU0").
- Host: clang-format clean, Stage 1 builds cleanly (12,296 B headroom,
  no __TEXT_BOOT_EXEC), Stage 2 ESP build links cleanly, full pytest
  tests/python: 1251 passed, 26 skipped.

Risk: low — only applies to external displays on an AFKv2 iBoot
interface after power-on; headless external boots, AFKv1 (13.5) external
displays, internal panels, and existing AFKv2 dptx-port displays keep
their previous behaviour.

Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>

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

Verdict: FINISH, then merge at 66355a0f

Blockers: none in the code. Before merge: CI at head (all queued now), plus one regression row on a second Mac. This is Stage 1/2 display code every Mac runs. We'll run that row on our J473 (M2 Mac mini, AFKv2 dptx-port, the path #451 added) once CI is green, and post it here.

Checked:

  • display_dcp_hands_on() keeps the dptx branch exactly as before. The new branch needs display_is_external && display_external_lit && dcp_ib_is_afkv2(iboot). display_external_lit is set only after dcp_ib_set_power(true) succeeds, and it is cleared in display_start_dcp() and display_shutdown(). hands_on is evaluated before dcp_ib_shutdown() frees iboot, which matters.
  • dcp_ib_is_afkv2() is NULL-safe.
  • Headless external, AFKv1 and internal panels keep their paths, and your tests cover all four cases.

Questions (not blocking):

  1. Scope. The new branch is not limited to the J274: every Mac whose disp0 (or dispext4 on J180d/J475d) is external and speaks AFKv2 on 27.2, such as the M1 Max/Ultra Studios, now hands its DCP on running when a display is lit. Have you or anyone seen a Studio on 27.2 fail to sleep the same way? If not, a fail-safe alternative is to try the sleep first and hand on only when rtkit_sleep() times out. That changes nothing on Macs that sleep fine today. Your call; if you keep the current rule, please add a line under Not yet: naming the Studios.
  2. pr-text wants the door in the Risk line, e.g. **Risk:** two-way · AFKv2 external-display Macs on 27.2 (J274; also M1/M2 Studios, Mac mini with HDMI on disp0).
  3. Merge order with the companion linux PR. Today a lit J274 boot fails the hand-off and returns to the proxy, so landing this first can only help, even before the kernel adopts the session. Please link the linux PR here.

@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) needs-template PR body lacks required sections (bot) labels Nov 28, 2026
@github-actions

github-actions Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Merge readiness at 66355a0f: not ready yet

Check Detail
CI at head no failing: pr-text / pr-text, gcc, fedora, nix
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head ok comment at 66355a0f
Conflicts ok none
PR text no add 'one-way' or 'two-way' in Risk (guide)

Areas: none matched in CODEOWNERS

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

@RyanTheTide

Copy link
Copy Markdown
Contributor

Regression row, J473 (M2 Mac mini, T8112, AFKv2 dptx-port DCP, 27.2 stub), aura-try Stage 2 one-shot of exact head 66355a0f (clang RELEASE=1 CHAINLOADING=1 ESP_STAGE2=1, label 1.0.0b17-g66355a0f, live DTB/U-Boot tail), kernel 7.3.0-aurora-fleet89, DP-2 2560x1440 and HDMI-A-1 1920x1080 connected: PASS. The trial matches the production rows taken before and after:

  • Both DCPs are bound and both monitors enabled.
  • Enforcing, 0 failed units.
  • The same 20 kernel error lines as production, nothing new.

That covers the dptx branch of display_dcp_hands_on(). Afterwards the J473 is back on its production Stage 2 2ec4a480 with no trial files left. Once CI is green and the Risk line is in, I'll approve and merge. Question 1 from my review is still up to you.

@github-actions github-actions Bot added ci-failing A check failed at the PR head (bot) and removed needs-hw-row No hardware row at the PR head (bot) labels Nov 28, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor

CI at 66355a0f: every build, format and Pytest job passes. The three "Stage 1 room" jobs show main's own headroom (gcc 3,664 B vs main 3,696 B; fedora 4,008 B and nix 3,152 B identical), so this PR isn't the cause. The one thing left is pr-text: the Risk line needs the door, for example

**Risk:** two-way · AFKv2 external-display Macs on 27.2 (J274; also M1/M2 Studios, Mac mini with HDMI on disp0)

Editing the description re-runs the check. Once it passes I'll approve and merge.

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

Approved at 66355a0f.

  • Rows at head: your J274 cold boot with HDMI and headless boot, and our J473 regression row on the dptx branch (PASS, matching production).
  • CI: every build, format and Pytest job passes. The gcc/fedora/nix Stage 1 room jobs show main's own headroom.
  • pr-text: its only error was the Risk door, which the edited line now has. The re-run is queued behind the Actions backlog, so I checked the text by hand: Tested/Risk present, Signed-off-by present, no attribution.

Thanks for the Studio scope note in the Risk line.

@RyanTheTide
RyanTheTide merged commit a0504b2 into main Nov 28, 2026
16 of 22 checks passed
@RyanTheTide
RyanTheTide deleted the fix/t8103-hdmi-afkv2-handoff branch November 28, 2026 20:29
RyanTheTide pushed a commit to axboe/linux that referenced this pull request Nov 30, 2026
…buffers

In dcp_rtkit_live_parse(), every apple,rtkit-buffers entry was checked
with PAGE_ALIGNED(iova) && PAGE_ALIGNED(size). On 16 KiB arm64 kernels,
this rejects firmware-placed (is_mapped == 1) buffers whose RTKit
addresses use 4 KiB granularity inside a pre-mapped firmware carveout —
for example T8103 (M1 Mac mini J274, fw 27.2.1) places the crashlog
buffer (ep 1) at iova 0x276000 (size 0x10000) inside dcp_data
(0xbe6510000+0x300000), causing dcp_rtkit_live_parse() to return -EINVAL
and aborting apple-drm probe when adopting a live HDMI session from
aura.

Both dcp_check_iova_contiguous() and dcp_vmap_wc() already handle
sub-page offsets cleanly (offset_in_page(phys) + multi-page vmap).

Split the validation into dcp_rtkit_live_buf_valid():
- Firmware-placed buffers (is_mapped == 1): require 4 KiB alignment
  (IS_ALIGNED(..., SZ_4K)), matching the RTKit buffer request protocol.
- Loader-allocated buffers (is_mapped == 0): keep host PAGE_ALIGNED()
  so their no-map reserved-memory carveouts never alias neighbouring
  pages.

Add a KUnit test case (dcp_handoff_live_rtkit_buf_valid) in
dcp_handoff_test.c covering firmware-placed 4 KiB buffers,
loader-allocated page alignment, endpoint IDs, flags, size limits, and
address wraparound.

Tested:
- J274 (M1 Mac mini, T8103, macOS 27.2.1 main OS, 16 KiB kernel) booted
  with HDMI (1920x1200@60) via aurora-silicon/aura#564 live handoff
  (dcp-live-v1, ep1 iova=0x276000 size=0x10000 is_mapped=1, ep2/ep4
  loader-allocated): 231c00000.dcp adopted the live RTKit session
  cleanly ("DCP booted", "set_digital_out_mode finished:8242", "boot
  scanout retired by displayed swap 3", fb0 appledrmfb, 0 DART faults,
  0 failed units), 271c00000.dcp and USB-C Type-C muxes bound cleanly.
- KUnit (arm64): apple-dcp-handoff 3/3 passed
  (dcp_handoff_external_idle, dcp_handoff_boot_notch,
  dcp_handoff_live_rtkit_buf_valid).
- scripts/checkpatch.pl: 0 errors, 0 warnings.

Risk: low — only relaxes alignment from PAGE_SIZE to SZ_4K for
firmware-placed (is_mapped == 1) live RTKit buffers, which are still
verified to be contiguously DART-mapped inside a no-map DCP carveout
and mapped via dcp_vmap_wc(). Loader-allocated buffers keep full
PAGE_ALIGNED() enforcement.

Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-failing A check failed at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) needs-template PR body lacks required sections (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants