Skip to content

iommu: apple-dart: keep live T8140 firmware translations out of TLB invalidates - #221

Merged
RyanTheTide merged 2 commits into
aurora-wipfrom
j700/display-handoff-race
Oct 9, 2026
Merged

RyanTheTide merged 2 commits into
aurora-wipfrom
j700/display-handoff-race

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

iommu: apple-dart: keep live T8140 firmware translations out of TLB invalidates

Two commits on aurora-wip:

  1. iommu: apple-dart: invalidate T8110 ranges by device DVA. Range invalidates on locked T8110 v2.2+
    streams now use the DVA the device issues, not the table-masked IOVA.
  2. iommu: apple-dart: leave live firmware translations out of invalidates. On DARTs that keep firmware
    roots (T8140/T8142), only the root slots Linux owns are invalidated, by DVA range.

Problem

On some MacBook Neo (J700, T8140) boots the internal display never comes up:

apple-dart 412300000.iommu: translation fault: SID:0 read PTE invalid at 0x10002a20800 (status 0x00003200)
apple-dcp 412e00000.dcp: error -ETIME: Failed to boot RTKit: -62
apple-drm display-subsystem: failed to bind 412e00000.dcp (ops dcp_comp_ops [appledrm]): -62

GNOME then runs on simpledrm with no backlight control. It hit 3 of 52 journaled boots on the test
machine, about 1 in 17. The fault comes at about 0.77 s, when the display subsystem's default domain attaches to
the locked display DART (disp0_dart) while the boot framebuffer is still being scanned out through the firmware's
translations.

Findings (test-only instrumented kernels on the Neo)

  • The firmware page tables for SID 0 (three-level, VA width 42, window at 1 TiB from apple,dma-range) sit in a
    boot-loader carveout outside Linux's memory. They are unchanged at domain allocation, at attach and at the time of
    the fault. Nothing corrupts them.
  • The trigger is the invalidate of translations the hardware is using. During the boot scanout:
    • 500 whole-stream invalidates fault within about 28 ms (read PTE invalid). The faulting leaf entry read
      back at that moment is valid and maps the expected framebuffer page.
    • A single invalidate by DVA range over the scanout's window [1 TiB, 1 TiB + 64 GiB) faults at once
      (STT mismatch). Any invalidate of live translations can break the scanout.
    • The display coprocessor's crash log then shows axi_rd_err and panic(app), and apple-dcp cannot boot RTKit.
  • Range invalidates must use the device DVA. 2500 range invalidates over [0, 64 GiB), the IOVA masked to
    the table width as the driver passed it, had no observable effect. The same range at the device DVA hit the live
    translations at once. So the existing masked range invalidate on map/unmap never matched anything on these
    streams, and unmaps left their translations in the TLB.

Fix

  • Commit 1: apple_dart_domain_flush_tlb_range() passes IOVA + DART offset to the range command, matching
    the map path. Windows below the table width (every M1/M2 DART) are unaffected, because the mask was a no-op there.

  • Commit 2: Linux never changes what a firmware-owned root slot resolves to. It publishes only into vacant slots,
    and a firmware slot is accepted only when Linux's mappings match it. On fw_mirror DARTs (locked
    apple,t8140-dart/apple,t8142-dart, revision ≥ 2.2), every invalidate now does a DVA-range invalidate of only the
    parts of the stream's window that go through other root slots. This covers:

    • the whole-stream invalidate at attach and teardown;
    • flush_iotlb_all;
    • the map/unmap range invalidates.

    Slots Linux retires are invalidated while the root is still known, and the root pointer and firmware snapshot are
    now cleared under the same lock. Four-level streams, older revisions and all other SoCs keep their current
    invalidates.

Testing

  • Neo, fix + stress kernel (test only), boot scanout at attach:
    • 2000 invalidates through the patched invalidate_tlb() issued 2000 real range commands with 0 faults.
    • 2000 range invalidates over Linux-owned slots gave 0 faults.
    • The DCP bound. dcp-qual brightness and 5 DPMS cycles passed.
  • Neo, fix kernel, 5 consecutive one-shot boots: 5/5 with 0 DART faults and the DCP bound. dcp-qual passed
    every check: boot, brightness, and 5 DPMS off/on cycles, which exercise real range invalidates on map/unmap.
    There was no WARN/Oops.
  • Earlier iteration of this fix (range over the masked window, i.e. no invalidate of the live slots): 12/12
    boots and a 2000-invalidate stress also passed. Measured across the journal, the unpatched kernel faults on about
    6 % of boots.
  • M1/M2: fw_mirror is set only for the t8140/t8142 compatibles. In the M1/M2 build of apple-dart.ko,
    apple_dart_t8110_hw_invalidate_tlb() tests the flag and makes exactly the previous whole-stream call. M2 (MacBook
    Air 13-inch) one-shot of this head: the DCP bound, 9/9 swaps, backlight present, 0 DART faults, 0 WARN/Oops; then
    returned to its default with the display off.
  • M1 Pro (MacBook Pro 16-inch, 2021), one-shot of this head: the DCP bound, 5/5 swaps, backlight present, 0
    DART faults. The only WARNs are the two from the pre-existing apple-admac late-IOMMU-probe race
    (iommu.c "late IOMMU probe at driver bind" and __device_links_no_driver), which the stock kernel's reference
    run shows as well. There are no other new warnings against stock. The machine was then returned to its default
    kernel with the display off and the keyboard backlight at 0.
  • Not tested: M2 Pro/Max (t6021) external-display DARTs also use a 1 TiB window. If those streams are locked and
    revision ≥ 2.2, commit 1 makes their unmap range invalidates take effect where they were no-ops before.
  • checkpatch.pl --strict: clean except the expected Assisted-by format warning. Applies to aurora-edge
    unchanged, since apple-dart.c is identical there.

🤖 Generated with Claude Code

The range invalidate for locked T8110 v2.2+ streams passes the IOVA
masked to the page-table input width. The TLB range registers match the
DVA the device actually issues, though. On T8140 the display and DCP
streams sit in a window at 1 TiB (apple,dma-range <0x100 0x0 0x10 0x0>),
so the masked range never matches a cached translation there:

 - a range invalidate over [0, 64 GiB) during the boot scanout does
   nothing observable, even after 2500 repetitions;
 - the same range over [1 TiB, 1 TiB + 64 GiB) hits the scanout's live
   translations at once.

Every unmap on these streams therefore left its translations in the TLB.

Invalidate the DART-visible range, IOVA plus the DART offset, as the map
path already uses it. Windows below the table width are unaffected,
because masking was a no-op there.

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
On T8140 the boot loader locks the display DART, and the display
controller keeps scanning out the boot framebuffer through the firmware
translations while Linux attaches the default domain. The attach ends
with a whole-stream TLB invalidate. Now and then the next table walk
after that invalidate reports an invalid PTE, although the firmware
entry is valid and unchanged:

  apple-dart 412300000.iommu: translation fault: SID:0 read PTE invalid
  at 0x10002a20800 (status 0x00003200)

The display coprocessor then panics on the failed read, apple-dcp cannot
boot RTKit (-ETIME), and the panel stays on simpledrm without backlight
control. This hit about one boot in twenty.

During the boot scanout, 500 whole-stream invalidates reproduce the
fault within 30 ms, with the faulting leaf entry still valid when read
back. One invalidate by DVA range over the scanout's window faults as
well, with "STT mismatch". So any invalidate of translations that the
hardware is using can break the scanout.

Linux never changes what a firmware-owned root slot resolves to: it
publishes only into vacant slots, and accepts a firmware slot only when
its own mappings match it. On DARTs that keep firmware roots (T8140 and
T8142), invalidate by DVA range only the parts of the stream's window
that are reached through other root slots. That covers the whole-stream
invalidate at attach and teardown, and the range invalidates on map and
unmap. Slots that Linux retires are invalidated while the root is still
known. Clear the root pointer and the firmware snapshot under the same
lock, so that an invalidate never sees one without the other.

Four-level streams, older DART revisions and other SoCs keep their
current invalidates.

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
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.

1 participant