Skip to content

soc: apple: mcc: wait for display controllers to retire boot scanout - #2538

Open
erikwb wants to merge 1 commit into
satchlj/mcc-t6050-slc-allocate-20261120from
j716c/t6050-mcc-display-ready
Open

erikwb wants to merge 1 commit into
satchlj/mcc-t6050-slc-allocate-20261120from
j716c/t6050-mcc-display-ready

Conversation

@erikwb

@erikwb erikwb commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • For an apple,boot-dma-devices supplier that an enabled simple-framebuffer names as its display, keep system level cache allocation off until the display driver reports that a displayed swap of its own retired the boot scanout (apple_mcc_boot_scanout_retired(), drivers/soc/apple/mcc-boot-dma.c). This holds whether or not the supplier's node is enabled, so a boot where the bootloader keeps the boot framebuffer also keeps allocation off. All listed suppliers still must bind (matching soc: apple: mcc: let the T6050 system level cache allocate #2518).
  • The display driver reserves the retirement record (apple_mcc_boot_scanout_reserve()) before its first present, so publication cannot fail. Retirement survives either driver's unbind and reprobe.
  • An unresolved supplier phandle, or a detached consumer or supplier node, leaves allocation off. If a boot DMA node is detached after allocation is enabled, the OF detach notifier turns allocation off again (and cancels a pending re-enable on resume), unless that node is a supplier whose boot scanout already retired. Suspend, resume and shutdown take the same lock as the notifier.
  • No chip or board is named: the DT describes which supplier scans out the boot framebuffer.

Stack

Testing

  • Host test tools/asahi/run-host-tests.py --only mcc-boot-dma (6/6 passed: baseline + 5 mutants killed) compiles the supplier walk, the detach notifier and the PM callbacks against mock device-tree nodes: the disabled-but-scanning DCP, bound-until-retired DCP, unbound supplier deferral, unresolved phandles, detach between walks, detach after enable, suspend -> detach -> resume, with mutants for each guard.
  • Builds for arm64 (LLVM=1 W=1) with 0 warnings for CONFIG_APPLE_MCC=y (with CONFIG_APPLE_MCC_KUNIT_TEST=y and CONFIG_OF_DYNAMIC=y) and CONFIG_APPLE_MCC=m; checkpatch 0 errors (only the binding-in-same-patch and MAINTAINERS notes).

Prior hardware test on the J716c (M5 Max) with this stack at bddfd572 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

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

@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks for this, and for the SLC numbers on the J716c.

One point before it can land: we select behaviour by a hardware property, not by the chip it was tested on. The wait for boot scanout to retire is taken only when both nodes are T6050 (drivers/soc/apple/mcc.c:150-151, of_device_is_compatible(dev->of_node, "apple,t6050-mcc") && of_device_is_compatible(it.node, "apple,t6050-dcp")). The reason in the comment, that a bound or unclaimed display controller can still be scanning the boot surface, is true of any display controller the loader left running, and the device tree already lists those suppliers in apple,boot-dma-devices.

Could the wait apply to every boot-DMA supplier that is a display controller (or follow the apple,boot-display-panel property the description mentions, which the code and #2540 do not use yet), with a comment if some generation really must be excluded? We can run boot rows on our M1 Pro, M2, M4 Pro and A18 Pro.

@erikwb
erikwb force-pushed the j716c/t6050-mcc-display-ready branch from e72cc8b to bddfd57 Compare November 21, 2026 02:39
@erikwb erikwb changed the title soc: apple: mcc: wait for native display takeover on T6050 soc: apple: mcc: wait for display controllers to retire boot scanout Nov 21, 2026
@erikwb

erikwb commented Nov 21, 2026

Copy link
Copy Markdown
Contributor Author

Note

🤖 Claude Opus 5.5 responding on behalf of erikwb

The T6050 test is gone (bddfd57). Whether a supplier is scanning out a boot framebuffer now comes from the DT: an enabled simple-framebuffer whose standard display property names the supplier (apple_mcc_scans_boot_framebuffer() in mcc.c). For such a supplier, allocation waits until its driver reports that a displayed swap of its own retired the boot surface (apple_mcc_boot_scanout_retired()).

  • Order of checks: this runs before the availability check, because the bootloader keeps the boot framebuffer and leaves the display controller disabled when it doesn't hand the display over. Allocation then stays off.
  • No generation excluded: the current DTs name no display for their boot framebuffer, so their display-subsystem and PMP suppliers still only need to be bound. The J716c DT (arm64: dts: apple: t6050: describe the single-die system cache controller #2540) adds display = <&dcp> to its framebuffer node.
  • Lifetimes: the display driver reserves the record when it starts tracking the boot surface, so publishing the retirement can't fail, and retirement survives unbind and reprobe. A supplier phandle that doesn't resolve, or a detached node, leaves allocation off. A detach after enable turns allocation off again through the OF notifier, and suspend, resume and shutdown take the same lock.
  • apple,boot-display-panel from the old description never existed in the binding; the description is corrected.

On the J716c: with native handoff, allocation is enabled 0.4 ms after "boot scanout retired by displayed swap 6". With the handoff declined, MCC stays deferred and allocation stays off. Boot rows on M1 Pro, M2, M4 Pro and A18 Pro would confirm allocation still enables there as before.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks, this resolves our point. The wait now follows the device tree: an enabled simple-framebuffer whose display names the supplier, with no chip check, and suppliers that scan out no boot framebuffer only need to be bound as before. Allocation stays off when the reference doesn't resolve, which is the safe direction.

We'll run boot rows on our M1 Pro, M2, M4 Pro and A18 Pro on this head (MCC allocation enabled as before, no new deferral) and post them here.

A display controller can keep scanning out the framebuffer the
bootloader left on screen after it binds, and also while its node stays
disabled because the bootloader kept the boot framebuffer as the
display. For a boot DMA supplier that an enabled simple-framebuffer
names as its display, enable cache allocation only once the display
driver reports that a displayed swap of its own has retired that
scanout. Other suppliers still only need to be bound. A supplier
phandle that does not resolve, or a detached consumer or supplier
node, leaves allocation off.

The display driver reserves the record before it can retire the
scanout, so the one-shot retirement cannot be lost to an allocation
failure. Retirement survives either driver's unbind and reprobe;
records and waiters are dropped when a node they name is detached, and
none is added or retried for a detached node.

OF flags a node detached before it calls the reconfig notifiers, so
probe cannot hold a detach off, but the notifier always runs after the
flag is set. Probe therefore checks its nodes and enables allocation
under the lock the detach notifier takes, and registers the enabled
controller there. Either probe sees the flag and fails, or the notifier
finds the controller and turns allocation off, unless the detached node
is a supplier whose boot scanout already retired, and cancels the
enable a wake from deep sleep would do. Suspend, resume and shutdown
take the same lock. A failed enable's write-back (up to 100 ms per
plane) is done under that lock and delays a detach by as much. A
deferred controller is retried outside the display driver's receive
path.

Signed-off-by: Erik Bourget <erik@ebourget.net>
@erikwb
erikwb force-pushed the j716c/t6050-mcc-display-ready branch from bddfd57 to 5b30245 Compare November 22, 2026 00:33
@RyanTheTide

Copy link
Copy Markdown
Contributor

Re-checked at 5b30245.

  • The earlier point stays fixed: the scanout wait follows the framebuffer's display phandle (drivers/soc/apple/mcc.c:141-156), with no compatible check.
  • The one change since bddfd57, dropping the availability skip so a disabled supplier waits to bind (mcc.c:206-215), matches what soc: apple: mcc: let the T6050 system level cache allocate #2518 does and errs toward leaving allocation off. The host test covers the new cases (tools/asahi/mcc-boot-dma-tests.py:164-179).

One correction to "Still to run": M1 Pro and M2 have no MCC match (mcc.c:540-546), and the M4 Pro (J616s) and A18 Pro (J700) MCC nodes stay disabled (t604x.dtsi, t8140.dtsi:805-806), so boots there don't reach this code. The board in tree that reaches the bound-only path is T8132 (t8132-jxxx.dtsi:168-170, supplier &pmp); a J713 boot on this head showing allocation enabled as before covers it. For T6050, the J716c handoff and handoff-declined rows in the description were taken on bddfd57; please repeat them on 5b30245 once #2539/#2540 are rebased onto it.

LGTM otherwise.

Assisted-by: LLM (Claude:Opus 5.5)

@erikwb

erikwb commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Note

🤖 Gemini 4 Neon responding on behalf of erikwb

Updated "Still to run" in the PR body to name T8132 (t8132-jxxx.dtsi, J713, supplier &pmp) as the in-tree board exercising the bound-only path (since M1 Pro and M2 have no MCC match and M4 Pro / A18 Pro MCC nodes stay disabled) and to note repeating the J716c handoff and handoff-declined rows on 5b302458 once #2539/#2540 are updated on top of it. No code change needed on #2538 (5b302458).

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

Stack & Dependencies

  • Targets open base PR #2518 (satchlj/mcc-t6050-slc-allocate-20261120 @ e6fdaf6d4b23). Stands cleanly on its own on top of #2518 with no dependency on #2539 or #2540 (CONFIG_APPLE_MCC_BOOT_DMA is built-in bool when CONFIG_APPLE_MCC is enabled and provides inline stubs otherwise).

Code & Safety Audit

  • Locking & lifetimes (drivers/soc/apple/mcc-boot-dma.c, drivers/soc/apple/mcc.c): Single boot_scanout_lock mutex serializes scanout retirement, OF detach handling, probe enable/registration, remove unregistration, shutdown, and suspend_noirq/resume_noirq (sleepable process context). apple_mcc_retry() drops boot_scanout_lock before device_initial_probe(), apple_mcc_boot_scanout_retired() drops it before schedule_work(), and apple_mcc_remove() unregisters before disabling and tearing down devm state (no UAF or lock inversion).
  • OF detach ordering: Verified against drivers/of/dynamic.c (__of_detach_node() flags OF_DETACHED before of_reconfig_notify(OF_RECONFIG_DETACH_NODE)), so the locked apple_mcc_boot_dma_detached() check + enable + registration closes the probe/detach race, and apple_mcc_boot_dma_lost() clears mcc->sleep_disabled so resume does not re-enable.
  • Fail-safe walk & refcounts: apple_mcc_scans_boot_framebuffer() and apple_mcc_wait_boot_dma() balance of_node_put() on all paths; unresolved non-zero phandles return -EINVAL, detached nodes return -ENODEV, disabled/unbound suppliers defer, and display-named boot-framebuffer suppliers wait for retirement whether enabled or disabled.
  • Host tests: Independently ran tools/asahi/mcc-boot-dma-tests.py + all 5 mutation controls against 5b302458524f (6/6 pass: baseline passes, all 5 mutants killed).

Pre-PR Checklist (§1–§6)

  • §1 No model gating: PASS — driven purely by DT apple,boot-dma-devices and enabled simple-framebuffer display phandle (no chip/SoC/board checks).
  • §2 Production-ready: PASS — default cmdline, no sleeps/magic delays.
  • §3 Safety: PASS — fails safe (allocation stays off) on every unconfirmed or detached state.
  • §4 Clean-room & attribution: PASS — commit 5b302458524f carries human author/committer and human Signed-off-by: only; PR body carries Assisted-by:.
  • §5 Evidence: HOLD — prior J716c rows were on bddfd572. Still needed on live head 5b302458524f:
    1. T8132 (J713, t8132-jxxx.dtsi, bound-only &pmp path) boot confirming cache allocation enables as before + regression row (0 SELinux denials, 0 failed units, 0 new kernel errors).
    2. Repeated J716c native handoff and handoff-declined rows on 5b302458524f (with rebased #2539/#2540) + regression row (0 SELinux denials, 0 failed units, 0 new kernel errors).
  • §6 Naming: PASS.

CI Status

  • sep-source.yml: 6/6 SUCCESS on 5b302458524f (source, rust-build, kunit, and all 3 DWC3/ATC compile matrix jobs).
  • dt-checks.yml and host-tests.yml have not run on GitHub Actions yet because this PR targets #2518's branch rather than integration/aurora; they will need to pass once #2518 merges and this PR is retargeted.

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