Skip to content

drm/apple: publish completion of native display takeover - #2539

Open
erikwb wants to merge 1 commit into
j716c/t6050-mcc-display-readyfrom
j716c/display-takeover-ready
Open

erikwb wants to merge 1 commit into
j716c/t6050-mcc-display-readyfrom
j716c/display-takeover-ready

Conversation

@erikwb

@erikwb erikwb commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Track boot scanout retirement on every display controller with a boot framebuffer (firmware 27, dfb_region_size), not only apple,t6050-dcp. Reserve its retirement record at bind (apple_mcc_boot_scanout_reserve()) and report it (apple_mcc_boot_scanout_retired()) only when an accepted, shown KMS swap replaces or clears slot zero. If the record cannot be allocated, the display still takes over and no retirement is reported, so cache allocation stays off.
  • A paired firmware-27 scanout passes the shown state to the owner when both engines displayed the retired swap (dcp-peer-frames-v27.h, host test tools/asahi/dcp-peer-shown-tests.py).
  • While boot takeover is pending, apple_atomic_check() pulls touched active CRTCs and their primary plane into atomic commits, so cursor- or overlay-only commits replay the intended slot-zero surface. When the primary plane is disabled while takeover is pending, iomfb_flush() forces an explicit slot-zero clear.

Stack

Testing

  • Rebased cleanly onto soc: apple: mcc: wait for display controllers to retire boot scanout #2538 (5b302458524f) with identical drivers/gpu/drm/apple/ and test changes.
  • Host tests: python3 tools/asahi/dcp-peer-shown-tests.py (paired first modeset shown, one half not shown, engine drift, stale shown, duplicate completion; two mutants caught) and python3 tools/asahi/dcpext26-queue-tests.py pass.
  • Builds cleanly for arm64 (ARCH=arm64 LLVM=1 W=1 drivers/gpu/drm/apple/); scripts/checkpatch.pl reports 0 errors (only the MAINTAINERS note for the new test file).

Prior hardware test on the J716c (M5 Max) with this stack on a kernel built from the J716c's current base, with 27.2 firmware:

  • Native display handoff: apple-dcp 48ae00000.dcp: boot scanout retired by displayed swap 6, then apple-mcc 2220000000.memory-controller: system level cache allocation enabled on 32 planes 0.4 ms later. Before this stack, allocation was enabled at 0.66 s, before the display had taken over.
  • Handoff declined (a test-only loader that refuses it): simpledrm keeps the panel and the cache controller stays deferred (apple-mcc: waiting for /soc@200000000/dcp@48ae00000 to retire boot scanout), so allocation stays off.
  • The same with the reworked T6050 loader (aura media: apple: avd: allow more than 32 capture buffers per context #281/drm: apple: answer the DPTX port's group 1 calls as macOS does #282): retirement at 1.2 s, then allocation enabled; the internal panel and two DisplayPort monitors on a TB5 dock came up.
  • No kernel warnings in any of the boots.

Still to run

  • Repeat the J716c boot row on the rebased stack (#2538 5b302458 + #2539 + #2540).
  • Paired (two-pipe) hardware trace (e.g. 4K240) to exercise the paired completion path live.
  • M4 Pro (27.x firmware) boot and display row.

Assisted-by: LLM (Anthropic:Claude Opus 5.5, Google:Gemini 4 Neon)

@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks for this, the slot-zero handling is thorough.

One point before it can land: we select behaviour by a hardware property, not by the chip it was tested on. Takeover tracking is switched on only for apple,t6050-dcp (drivers/gpu/drm/apple/dcp.c:6107-6108, boot_surface_pending = of_device_is_compatible(..., "apple,t6050-dcp")). Whether the loader left a boot surface on screen is a property of the hardware state, which this function already reads two lines above (dfb_region_size), so every display controller with a boot framebuffer could publish its takeover, and any memory-cache consumer that lists it in the device tree could wait on it.

Could boot_surface_pending follow the boot framebuffer (or the consumer's DT reference) instead of the compatible, with a comment if some generation has to be excluded? We can run boot and display rows on our M1 Pro, M2, M4 Pro and A18 Pro for it.

@erikwb

erikwb commented Nov 21, 2026

Copy link
Copy Markdown
Contributor Author

Note

🤖 Claude Opus 5.5 responding on behalf of erikwb

Done in 6195f71. boot_surface_pending now comes from the boot framebuffer that dcp_firmware_metadata_v27() already reads (dfb_region_size), not the compatible, so every firmware-27 display controller with a boot framebuffer tracks and publishes its takeover.

  • No exclusion needed: firmware 27 never runs with the H17G method profile (T8142 is switched to the default one at probe), so the clearing completion runs everywhere the flag can be set.
  • Paired scanout: it now passes the firmware's shown flag to the owner, matched to the retired swap ID on both engines; tools/asahi/dcp-peer-shown-tests.py covers it.
  • Allocation failure: if the retirement record can't be allocated, the display still takes over and no retirement is reported, so cache allocation stays off.
  • Other display controllers: on one that no cache controller names, the retirement is only recorded.

On the J716c the internal DCP published retirement on swap 6, with both the original and the reworked T6050 loader. M1 Pro, M2 and A18 Pro don't take this path. M4 Pro on 27.x firmware does, so a boot and display row there would help. A paired-mode row (two-pipe, e.g. 4K240) is still to come from our side.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks, this resolves our point: boot_surface_pending now follows the boot framebuffer (dfb_region_size) instead of the compatible, so every firmware-27 display controller with a boot surface publishes its takeover.

Our M4 Pro runs 27.x firmware, so we'll run a boot and display row there on this head (with #2538) and post it here.

A display controller the bootloader left scanning out a framebuffer can
still show that surface after DRM registration. Reserve its retirement
record with the cache controller when binding, and mark it retired
once an accepted, shown KMS swap replaces or clears slot zero. A
paired firmware-27 scanout passes the firmware's shown state to the
owner, set when both engines displayed the retired swap. If the record
cannot be allocated the display still takes over, without a
retirement report, so allocation stays off.
Until that displayed completion arrives, pull the primary plane into
atomic commits for that CRTC so cursor- or overlay-only commits replay
the intended slot-zero surface with its own framebuffer reference,
force an explicit slot-zero clear when the primary plane is disabled,
and drop any inherited slot-zero reference from the pending scanout to
match that clear.

Signed-off-by: Erik Bourget <erik@ebourget.net>
@erikwb
erikwb force-pushed the j716c/display-takeover-ready branch from 6195f71 to 7803302 Compare November 22, 2026 07:24
@erikwb

erikwb commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Note

🤖 Gemini 4 Neon responding on behalf of erikwb

Rebased #2539 cleanly onto the current #2538 head (5b302458524f) in 7803302be7ee to clear the merge conflict, and removed the Developed with Claude Code. line from the commit message (human Signed-off-by: only; code diff identical to 6195f71c579a) plus updated the PR body footer to plain Assisted-by:.

Verified on 7803302be7ee:

  • ARCH=arm64 LLVM=1 W=1 drivers/gpu/drm/apple/: builds cleanly (0 errors, 0 new warnings).
  • python3 tools/asahi/dcp-peer-shown-tests.py: PASS.
  • python3 tools/asahi/dcpext26-queue-tests.py: PASS.

@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 7803302be7ee (0 code/policy blockers; holding for CI and §5 live-head hardware proof):

Stack & Dependencies

  • Stacked cleanly on live #2538 (5b302458524f); depends on #2538's <linux/soc/apple/mcc.h> (apple_mcc_boot_scanout_reserve() / apple_mcc_boot_scanout_retired()), so #2538 must land first. Independent of #2540.

Code & Safety Audit

  • Hardware-state gating (drivers/gpu/drm/apple/dcp.c): dcp_firmware_metadata_v27() tracks takeover from dfb_region_size > 0 rather than a compatible check. Verified in dcp.c:7149-7151 that T8142 on firmware 27 switches iomfb_method_profile to DCP_IOMFB_METHODS_DEFAULT, so every firmware-27 controller that can set boot_surface_pending reaches the clearing path in dcp_report_swap_complete(). On -ENOMEM from apple_mcc_boot_scanout_reserve(), boot_scanout_reserved stays false so display takeover still proceeds while MCC keeps allocation off.
  • Locking & execution context (drivers/gpu/drm/apple/iomfb_template.c): dcp_report_swap_complete() runs under dcp->iomfb.lock in process context (both direct iomfb_recv_msg() and iomfb_callback_work() for paired peer completions). apple_mcc_boot_scanout_retired() takes only boot_scanout_lock internally and schedules retry work after unlocking, with no lock inversion against dcp->iomfb.lock.
  • Atomic check & slot-zero handling (drivers/gpu/drm/apple/apple_drv.c, iomfb.c, iomfb_template.c): apple_atomic_check() matches drm_atomic_helper_check() (omitting only the unused self-refresh helper), skips t8132_ext_crtc(), pulls active CRTCs and their primary plane while boot_surface_pending (handling -EDEADLK and naturally preventing async_update on multi-plane state), and pairs with iomfb_scanout_prepare_h17p() clearing any inherited scanout->fb[0] plus iomfb_flush() forcing BIT(0) and skipping the no-op early vblank_wq return while pending.
  • Paired firmware-27 completions (dcp-peer-frames-v27.h, dcp-peer-runtime-v27.inc): both_shown is true only when both engines reported shown for the exact retired watermark done. Independently ran tools/asahi/dcp-peer-shown-tests.py + both mutants (--always-shown, --owner-only) against 7803302be7ee (PASS, both mutants killed).

Pre-PR Checklist (§1–§6)

  • §1 No model gating: PASS — follows dfb_region_size hardware state, no chip/compatible gating.
  • §2 Production-ready: PASS — default cmdline, no sleeps/magic delays.
  • §3 Safety: PASS — fails safe (allocation stays off) if record allocation fails or a swap is not reported shown.
  • §4 Clean-room & attribution: PASS — commit 7803302be7ee carries human author/committer and human Signed-off-by: only; PR body carries Assisted-by:.
  • §5 Evidence: HOLD — prior J716c rows were on an older base. Still needed on live head 7803302be7ee:
    1. Repeated J716c boot row on the rebased stack (#2538 5b302458 + #2539 7803302b + #2540 2bd59c88) + regression row (0 SELinux denials, 0 failed units, 0 new kernel errors).
    2. M4 Pro (27.x firmware) boot and display row.
    3. Paired two-pipe (e.g. 4K240) live trace exercising dcp_peer_swap_complete_v27().
  • §6 Naming: PASS.

CI Status

  • 0 GitHub Actions checks ran on 7803302be7ee because this PR targets stacked branch j716c/t6050-mcc-display-ready (host-tests.yml only triggers on integration/aurora / aurora-wip). host-tests CI will need to run and pass once retargeted after #2538 lands.

Assisted-by: LLM (Gemini 4 Neon)

@RyanTheTide

Copy link
Copy Markdown
Contributor

Re-checked at 7803302: a rebase onto #2538 at 5b30245 plus the commit-message cleanup. The patch is identical to 6195f71 (same patch-id), so our earlier review stands, and the commit now has only your Signed-off-by.

The M4 Pro boot and display row we offered is still to come, and we'll run it on 7803302 with #2538 at 5b30245.

Assisted-by: LLM (Claude:Opus 5.5)

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