Skip to content

iommu: apple-dart: adopt the M4 (T8132) external display DARTs - #952

Merged
RyanTheTide merged 3 commits into
aurora-silicon:integration/aurorafrom
erikwb:j713/extdisp-dart
Nov 5, 2026
Merged

RyanTheTide merged 3 commits into
aurora-silicon:integration/aurorafrom
erikwb:j713/extdisp-dart

Conversation

@erikwb

@erikwb erikwb commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

On the M4 MacBook Air the two external display coprocessors (dcpext0/1) were never touched by Linux: their DARTs were left alone, so nothing could drive an external display through them.

The boot loader can now hand both external DCPs over, already running, with their DARTs set up and locked as the internal display's. This adopts those DARTs the way the internal display's are adopted: the boot loader's tables are imported and kept, nothing is written at admission, and later only free root slots are claimed.

  • Firmware DARTs (SID23). Admitted like the internal DCP's, with the external DCP's four-segment firmware layout, once the boot loader has marked the DCP handed over (apple,t8132-dcpext-firmware-ready). Without the handover nothing changes.
  • Display DARTs (SID0 scanout, SID16 PIODMA). Adopted from the boot loader's tables, with an API for the DCP driver: SID23-only firmware buffers, mappings of firmware buffers in SID0/SID16 at DVAs of their own (D201), a host-written SID0 surface, stream and register checks, and a state check after the firmware powers the DART up again.
  • Power. The display DART is powered by its firmware, which switches it off with the display. Its registers are only touched inside a use of a per-DART PM gate: across system sleep the DART is unconfirmed, every operation returns -EAGAIN and nothing is retired, until the firmware has powered it up again and the state check passed.
  • Failures. A hardware failure (registers not as adopted, a pending fault, a failed mapping or flush) retires the whole display DART, and every mapping and publication on it refuses once either of its streams is retired. Every retirement of a borrowed DCP stream, on the internal display too, now logs its reason once.
  • Windows. Remappable SID0 windows (one 32 MiB arena slice each) for direct scanout of client framebuffers: map, flush and read back; unmap, flush and read back as invalid.

This is the first of six PRs for external displays on the J713; see #957 for the whole picture. It doesn't depend on the other five. At runtime it needs the boot-loader handover (aurora-silicon/aura#74 and aurora-silicon/u-boot#31); without it the external DARTs stay untouched as before.

Tested on a J713 (M4 MacBook Air) with a CalDigit TS5 dock and two 4K monitors, with the six PRs together:

  • both monitors at 3840x2160@60 through the dock, scanned out directly from the GPU's buffers
  • unplug and replug of the dock and of each monitor
  • s2idle with the dock attached and both monitors lit, and without the dock; the displays come back after resume
  • the internal panel is unaffected

Known gaps (follow-ups): apple_dart_resume()'s handling of the other borrowed DARTs is unchanged by this PR.

This was developed and tested by Claude (Anthropic), working with me on the J713.

The J713's two external display coprocessors (DCPs) run the same firmware
as the internal one. The boot loader starts them and leaves them quiesced,
with their firmware DARTs (SID23) set up the same way. Admit those DARTs as
the internal one is: read the ADT nodes of the matching coprocessor and its
four-segment firmware layout instead of the internal DCP's seven, and
validate the owner against apple,t8132-dcpext.

Touch one only once the boot loader has marked its DCP handed over
(apple,t8132-dcpext-firmware-ready), which it does only with the block
powered. Its fault interrupt is shared with the external display DART, so
request none.

Signed-off-by: Erik Bourget <[email protected]>
An external DCP drives its display through a display DART of its own: SID0
for scanout, SID16 for the buffers its firmware maps for PIODMA. The boot
loader leaves both streams set up and locked, as on the internal display.

Adopt them by the internal frontend's rules: the boot loader's roots and
tables are imported and kept, nothing is written at admission, and later
only free root slots are claimed. The DCP side gets:

- apple_dart_dcp_shared_alloc_link(): a firmware buffer on the DCP's own
  DART (SID23) alone, never mapped in SID16 afterwards;
- apple_dart_dcp_dispext_map(): an existing backing in SID0 or SID16 at a
  DVA of its own, filling a claimed slice before claiming the next;
- apple_dart_dcp_dispext_scanout_alloc(): a host-written SID0 surface;
- apple_dart_dcp_dispext_stream_ok() and apple_dart_dcp_dispext_qualify():
  whether a stream may be used, and, for a caller that knows the DART is
  powered, a check of both streams' registers and of pending faults;
- apple_dart_dcp_dispext_state(): after the firmware powered the DART up
  again, whether it kept its state (the TTBR/TCR lock, and the streams' TCR
  and TTBR). A lost state is not rebuilt.

The display DART's power belongs to its firmware, which switches it off
with the display. Its registers are only touched inside a use of a per-DART
PM gate: system sleep marks the DART unconfirmed and waits for every use in
flight, and from then on every operation returns -EAGAIN, retiring nothing,
until the firmware has powered the DART up again and the state check has
passed. The TLB commands also wait for a second busy flag (0x604 bit 0) on
these DARTs, and the SID16 flush checks for a pending fault first, since no
fault interrupt is attached.

A hardware failure (a fault pending, registers not as adopted, a failed
mapping or flush) retires the whole DART, both streams, and every
mapping and publication on it refuses once either stream is retired.
Every place that retires a borrowed DCP stream, on the internal display
too, now says why, once per stream.

Signed-off-by: Erik Bourget <[email protected]>
…ay DARTs

Direct scanout of client framebuffers needs SID0 mappings the host can take
down again. A window is one whole free 32 MiB slice of the SID0 arena,
claimed by the host until reboot; nothing else maps into it.

- apple_dart_dcp_dispext_window_claim() claims one, or returns -ENOSPC;
- apple_dart_dcp_dispext_window_map() maps caller-owned 16 KiB pages at
  the start of an empty window, flushes SID0 and reads every PTE back;
- apple_dart_dcp_dispext_window_unmap() checks every PTE against what was
  written, clears them all, flushes, and reads them back as invalid.

An external display DART's arena now takes up to ten free slices at
admission; it still needs only the four its retained surfaces use. Any
failure retires the whole DART, and the caller then keeps the pages until
reboot.

Signed-off-by: Erik Bourget <[email protected]>

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

Reviewed and tested here with the whole series on top of integration/aurora, thanks Erik.

  • Fedora-base universal config build is clean, W=1 adds no warnings, dtbs_check adds none and only the t8132 DTBs change
  • KUnit passes (atc 49/49, apple-dpin 94 + 1 skip, drm/apple 112 + 1 skip, the arm64 gate set 74 + 1 skip)
  • one-shot boots on the M4 Pro (J616s, dock and external display attached) and the M2, both with zero err lines, no new warnings, 0 AVCs with SELinux enforcing, a freezer pm_test pass and the external display still up on the J616s
  • the host selftests needed fixture updates for the renamed and new helpers, those come in with the #957 merge, all groups pass with them

Merging.

@RyanTheTide
RyanTheTide merged commit bf6624f into aurora-silicon:integration/aurora Nov 5, 2026
erikwb pushed a commit to erikwb/linux that referenced this pull request Nov 5, 2026
The J713 external display series (aurora-silicon#952, aurora-silicon#953 and aurora-silicon#957)
renamed or added production helpers that the host fixtures extract or call,
so host test groups stopped compiling:

- apple-dart-fw: the borrowed-DART unmap path calls
  apple_dart_dcp_invalidate_tlb_gated() now; stub that name.
- t6030-clock: apple_atc_tunnel_is_t6030() became
  apple_atc_tunnel_t8122_clock(), and the PCLK gates moved to
  apple_dp_tunnel_pclks() in dp-tunnel.h. Extract them, the T8132 rate
  check and dcp_fabric_clock_refused(), and stub the T8132 dcpext leaves
  as never taken on T6030.
- tiled-split: extract dcp_typec_route_no_dp_alt() and add two T8132
  dcpext cases (DP IN 1 alone, and with a tile hint) plus a mutation that
  makes a dcpext tileable.
- tunnel-route: extract dcp_route_tunnel_clock_blocked() and check that a
  dcpext is a tunnel clock source only as crossbar source 2 or 4.
- apple-dcp quiesce (six groups): the modelled DCP gains tb_clock_refused,
  and dcp_typec_route_no_dp_alt() is false, since no route there is a
  T8132 dcpext.
- apple-dcp publication-hpd, fast-replug-bounce, readiness and the
  service-rebind control: stub dcp_is_t8132_ext() as false, the T8132-only
  leaves (t8132_ext_drm_hotplug(), afk_compact_orphans_pending(),
  dcp_t8132_wait_teardown_answers()) as never reached, t8132_ext_drm_init()
  as 0 (what it returns on anything but J713), and give the modelled DCP
  the dptxep, t8132_release_late and afk_alloc members the series reads.

Fixtures only: no production code changes, and no existing case is
weakened.

Signed-off-by: Ryan Murray <[email protected]>
Assisted-by: LLM
(cherry picked from commit 4f0a21107e9a71eacd4faf36f1ff0ae9a2071aae)
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.

2 participants