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

Problem

A display controller that the bootloader left scanning out a boot framebuffer can still display that surface after DRM registration. Without tracking boot scanout retirement and keeping slot zero synchronized during early atomic commits, a memory cache controller waiting on boot DMA retirement cannot know when the native driver has taken over the display, and cursor- or overlay-only commits before the first primary-plane swap can leave or drop slot-zero state inconsistently.

Change

  • Track boot scanout retirement on every firmware-27 display controller that has a boot framebuffer (dcp->dfb_region_size > 0 in dcp_firmware_metadata_v27() in drivers/gpu/drm/apple/dcp.c), without chip or compatible gating. Reserve the retirement record at bind (apple_mcc_boot_scanout_reserve()) and report retirement (apple_mcc_boot_scanout_retired()) in dcp_report_swap_complete() (drivers/gpu/drm/apple/iomfb_template.c) only once an accepted, displayed KMS swap replaces or clears slot zero. If the record cannot be allocated (-ENOMEM), display takeover still proceeds and no retirement is reported, so cache allocation stays off.
  • Propagate the firmware's displayed (shown) state through paired firmware-27 completions (dcp-peer-frames-v27.h, dcp-peer-runtime-v27.inc) so both_shown is true only when both engines reported the retired watermark swap as displayed.
  • While boot_surface_pending is set, apple_atomic_check() (drivers/gpu/drm/apple/apple_drv.c) pulls touched active CRTCs and their primary plane into atomic commits so cursor- or overlay-only commits replay the intended slot-zero surface with its own framebuffer reference. When the primary plane is disabled while takeover is pending, iomfb_scanout_prepare_h17p() (drivers/gpu/drm/apple/iomfb.c) drops any inherited scanout->fb[0] reference and iomfb_flush() forces an explicit slot-zero update (BIT(0)).

Stack:

Testing

Verified at 7803302be7ee (stacked cleanly on #2538 5b302458524f with human-only Signed-off-by:):

  • Host tests: python3 tools/asahi/run-host-tests.py --only dcp-peer-shown (3/3 passed: baseline + --always-shown and --owner-only mutants killed) and python3 tools/asahi/run-host-tests.py --only dcpext26-queue (2/2 passed: baseline + --drop-v27-close mutant killed).
  • Arm64 build (make ARCH=arm64 LLVM=1 W=1 drivers/gpu/drm/apple/ with CONFIG_DRM_APPLE=m): 0 errors, 0 new warnings in modified files (appledrm.o linked cleanly; 2 pre-existing kernel-doc warnings remain at dcp.c:776).
  • ./scripts/checkpatch.pl --strict --git 5b302458524f..7803302be7ee: 0 errors (1 pre-submission MAINTAINERS note for the new test file).

Prior hardware tests on J716c (M5 Max, 27.2 firmware) at 6195f71c (#2539), paired with bddfd572 (#2538) and f3a64c0ed945 (the earlier #2540 board-local 32-plane t6050-j716c.dts commit carrying the mcc node and framebuffer@0 display = <&dcp> phandle):

  • 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 (vs enabling at 0.66 s, before display takeover, prior to this stack).
  • Handoff declined (test loader keeping simpledrm): simpledrm kept the panel and apple-mcc stayed deferred (apple-mcc: waiting for /soc@200000000/dcp@48ae00000 to retire boot scanout), keeping allocation off.
  • 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; internal panel and two DisplayPort monitors on a TB5 dock came up; 0 kernel warnings.

J716c (M5 Max) boot of 08fa25353657 (stack #2518 e6fdaf6d4b23 + #2538 5b302458524f + #2539 7803302be7ee + #2540 08fa25353657 on merge-base 26294e82e9c8, arm64 kernel config, LLVM=1, clang 23.1.4, default kernel command line, current Aura loader):

  • Internal panel up on the native DCP path (/sys/class/drm/card2-eDP-1 connected and enabled at 3456x2234; apple-dcp 48ae00000.dcp: boot scanout retired by displayed swap 6) and desktop started, confirming DCP retired boot scanout on swap 6. /proc/device-tree/soc@2220000000/memory-controller@2220000000/status reads disabled with no apple-mcc device bound because #2540 08fa25353657 leaves mcc status = "disabled" until the companion loader populates reg, so the MCC wait and enable path remains untested on this head.
  • 0 SError / synchronous external abort / oops / BUG / call-trace / unhandled-fault / panic lines in dmesg, 0 MMIO fault lines, 0 AVC denials (Arch ARM without SELinux), 0 takeover/mcc/boot-dma errors, and 0 kernel errors attributable to the stack (1 pre-existing failed unit aurora-peripherals.service, and the 28 err..emerg journal lines belong to error groups seen on earlier same-day J716c boots on trees without #2185/#2187/#2162 underneath; no bare 26294e82e9c8 baseline boot was taken).

Still to run

  • Retarget onto integration/aurora and confirm green live CI (host-tests, apple-drm-kunit) once soc: apple: mcc: let the T6050 system level cache allocate #2518 and soc: apple: mcc: wait for display controllers to retire boot scanout #2538 land.
  • Companion-loader-enabled J716c boot row on #2538 (5b302458524f) + #2539 (7803302be7ee) + #2540 (08fa25353657) with mcc enabled (reg populated from /arm-io/mcc amcc-enable-mask and status = "okay") on default kernel command line with regression counts (0 SELinux/AVC denials, 0 failed units, 0 new kernel errors); the current-loader mcc-disabled boot at 08fa25353657 is already verified above.
  • Paired two-pipe (e.g. 4K240) live trace exercising dcp_peer_swap_complete_v27().
  • M4 Pro (27.x firmware) boot and display row.

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

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

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

Formal §1–§6 pre-PR re-review at live head 7803302be7ee: requesting changes on stack/CI/§5 blockers (0 code, locking, safety, or attribution defects found).

Verification Summary

  • Code, locking & safety (§1–§3): Clean. boot_surface_pending follows hardware state (dfb_region_size > 0) rather than chip/compatible gating, fails safe on -ENOMEM from apple_mcc_boot_scanout_reserve(), serializes DCP_FW_SWAP(dcp) and dcp_report_swap_complete() under dcp->iomfb.lock with no lock inversion against apple_mcc_boot_scanout_retired(), and handles slot-zero replay/clear cleanly across apple_atomic_check(), iomfb_scanout_prepare_h17p(), and iomfb_flush(). Independently verified tools/asahi/dcp-peer-shown-tests.py (PASS + --always-shown and --owner-only mutants killed) and tools/asahi/dcpext26-queue-tests.py (PASS + --drop-v27-close mutant killed) on 7803302be7ee.
  • Attribution & naming (§4, §6 naming): Clean — commit 7803302be7ee carries human author/committer + human Signed-off-by: only; PR body carries Assisted-by:.

Blockers

  1. Unmerged stack dependency & base branch: Targets stacked branch j716c/t6050-mcc-display-ready (#2538 @ 5b302458524f, still open and stacked on open #2518 @ e6fdaf6d4b23). #2518 and #2538 must land first and this PR must be retargeted onto integration/aurora.
  2. Live CI (§6): 0 GitHub Actions checks ran on 7803302be7ee because the PR targets a stacked branch (host-tests and apple-drm-kunit only trigger on integration/aurora / aurora-wip). Green live CI is required once retargeted.
  3. Live-head hardware & regression proof (§5): Prior J716c rows were on an older base; still required on the exact live head 7803302be7ee (matching Still to run):
    • Repeated J716c boot row on the rebased stack (#2538 + #2539 + #2540) plus full regression row (0 SELinux denials, 0 failed units, 0 new kernel errors).
    • M4 Pro (27.x firmware) boot and display row.
    • Paired two-pipe (e.g. 4K240) live trace exercising dcp_peer_swap_complete_v27().

Assisted-by: LLM (Gemini 4 Neon)

@erikwb

erikwb commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

Note

🤖 Gemini 4 Hydrogen responding on behalf of erikwb

Confirmed 7803302be7ee sits cleanly on #2538 (5b302458524f) with human-only attribution (Signed-off-by: Erik Bourget <erik@ebourget.net>) and re-verified local checks at the live head:

  • python3 tools/asahi/run-host-tests.py --only dcp-peer-shown: 3/3 passed (baseline + --always-shown and --owner-only mutants killed).
  • python3 tools/asahi/run-host-tests.py --only dcpext26-queue: 2/2 passed (baseline + --drop-v27-close mutant killed).
  • make ARCH=arm64 LLVM=1 W=1 drivers/gpu/drm/apple/ (CONFIG_DRM_APPLE=m): 0 errors and 0 new warnings in changed files (2 pre-existing kernel-doc warnings remain at dcp.c:776).
  • ./scripts/checkpatch.pl --strict --git 5b302458524f..7803302be7ee: 0 errors.

Updated the PR description to standard Problem/Change/Testing/Still-to-run sections and folded in the J716c (M5 Max) boot of the stacked 08fa25353657 head (#2518 e6fdaf6d4b23 + #2538 5b302458524f + #2539 7803302be7ee + #2540 08fa25353657 on 26294e82e9c8, default command line, current Aura loader): the internal panel comes up on native DCP (3456x2234, boot scanout retired by displayed swap 6 — confirming DCP retired boot scanout on swap 6) and desktop starts, while apple-mcc remains disabled with no device bound (as #2540 keeps mcc disabled until the companion loader populates reg, so the MCC wait and enable path remains untested on this head), with 0 SError/abort/oops/MMIO fault lines, 0 AVC denials, and 0 stack-caused errors (the observed journal error groups were seen on earlier same-day J716c boots; no bare 26294e82e9c8 baseline boot was taken).

Retargeting to integration/aurora and triggering live CI (host-tests, apple-drm-kunit) waits on #2518 and #2538 landing. Under Still to run: the companion-loader-enabled J716c boot (mcc status = "okay" with reg populated from /arm-io/mcc amcc-enable-mask) on #2538 (5b302458524f) + #2539 (7803302be7ee) + #2540 (08fa25353657), paired two-pipe trace, and external M4 Pro (27.x firmware) row.

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