Repository navigation
iommu: apple-dart: keep live T8140 firmware translations out of TLB invalidates - #221
Merged
Merged
Conversation
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]>
This was referenced Oct 9, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
iommu: apple-dart: keep live T8140 firmware translations out of TLB invalidates
Two commits on
aurora-wip:streams now use the DVA the device issues, not the table-masked IOVA.
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:
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'stranslations.
Findings (test-only instrumented kernels on the Neo)
apple,dma-range) sit in aboot-loader carveout outside Linux's memory. They are unchanged at domain allocation, at attach and at the time of
the fault. Nothing corrupts them.
read PTE invalid). The faulting leaf entry readback at that moment is valid and maps the expected framebuffer page.
[1 TiB, 1 TiB + 64 GiB)faults at once(
STT mismatch). Any invalidate of live translations can break the scanout.axi_rd_errandpanic(app), and apple-dcp cannot boot RTKit.[0, 64 GiB), the IOVA masked tothe 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()passesIOVA + DART offsetto the range command, matchingthe 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_mirrorDARTs (lockedapple,t8140-dart/apple,t8142-dart, revision ≥ 2.2), every invalidate now does a DVA-range invalidate of only theparts of the stream's window that go through other root slots. This covers:
flush_iotlb_all;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
invalidate_tlb()issued 2000 real range commands with 0 faults.dcp-qualbrightness and 5 DPMS cycles passed.dcp-qualpassedevery check: boot, brightness, and 5 DPMS off/on cycles, which exercise real range invalidates on map/unmap.
There was no WARN/Oops.
boots and a 2000-invalidate stress also passed. Measured across the journal, the unpatched kernel faults on about
6 % of boots.
fw_mirroris set only for the t8140/t8142 compatibles. In the M1/M2 build ofapple-dart.ko,apple_dart_t8110_hw_invalidate_tlb()tests the flag and makes exactly the previous whole-stream call. M2 (MacBookAir 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.
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 referencerun 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.
revision ≥ 2.2, commit 1 makes their unmap range invalidates take effect where they were no-ops before.
checkpatch.pl --strict: clean except the expectedAssisted-byformat warning. Applies toaurora-edgeunchanged, since
apple-dart.cis identical there.🤖 Generated with Claude Code