Skip to content

iommu/apple-dart: T8152 Gen3 DART TLB invalidation and walk width - #2106

Open
LiamRay11 wants to merge 3 commits into
aurora-silicon:integration/aurorafrom
LiamRay11:j804/dart-gen3
Open

LiamRay11 wants to merge 3 commits into
aurora-silicon:integration/aurorafrom
LiamRay11:j804/dart-gen3

Conversation

@LiamRay11

Copy link
Copy Markdown

Summary

The Gen3 DARTs of T8152 (M6) ignore the T8110 TLB_CMD register, so Linux-owned mappings that change after boot are not seen by the device. This adds the Gen3 invalidation path through the SoC's shared TLBI aperture, and an optional walk width for streams the loader left with a three-level walk. Both are opt-in per DART node and change nothing for existing device trees, including J873's T8152 nodes, which have neither property.

Changes

  • dt-bindings: iommu: apple,dart: apple,tlbi-aperture (u64, the DART's 16-byte command slot) and apple,gen3-ias (u32, 32-42, requires the aperture). Both are allowed only for apple,t8152-dart.
  • iommu/apple-dart: apple,t8152-dart gets its own hardware ops: the T8110 ones, with an invalidate_tlb that goes through the aperture when the node has apple,tlbi-aperture and is the T8110 path otherwise. A Gen3 invalidation is a 16-byte command (bit 60, the route from register 0x4604, the stream) stored with one stp, then dsb(ish), __tlbi(vale1os, 0) and dsb(osh). Commands are serialised by one raw spinlock, because all Gen3 DARTs share the aperture. Like the T8110 command path, an invalidation returns -EHOSTDOWN while the DART's commands are gated for sleep. This is the same sequence the aura loader uses (dart_gen3_tlb_invalidate()).
    • The dispatch sits in the hardware ops, not in apple_dart_t8110_hw_tlb_command_range(), because the host tests (tools/asahi/apple-dart-*-tests.py) compile that function and its callers verbatim against their own model of struct apple_dart.
    • The ranged invalidations of firmware-held and locked DARTs (apple_dart_fw_invalidate(), the locked range path) still use TLB_CMD. No Gen3 DART takes those paths in this PR.
  • iommu/apple-dart: apple,gen3-ias sets the walk width of a Gen3 DART. DVAs are already masked to the walk width before the tables are touched, so a device can keep its high DVA window.

Testing

On hardware: MacBook Pro 14-inch (M6, J804), 2026-11-16, tested by LiamRay11.

  • What ran: kernel 7.3.0 built from integration/aurora bf423bf0e with all nine J804 linux PRs merged (t8152-mailboxes, dart-gen3, dt-board, centauri, g18-fast-retire, cfg80211-stale-scan, smc, cs42l84-jack, and an NVMe PR that is not sent yet), plus retest-only device-tree changes that are not part of these PRs: SSD nodes (ANS mailbox, SART, NVMe), PCIe port 0 with the N1 Wi-Fi, the USB0 gadget console, and a read-only NVRAM partition. Those nodes were needed to reach the root filesystem and SSH.
  • Booted through aura on the installed root filesystem. A systemctl reboot from this kernel (watchdog restart) returned to the installed system.

Results for this PR (the retest-only nodes give the PCIe port 0 and USB0 DARTs apple,tlbi-aperture):

  • 200 MB pushed over Wi-Fi (N1 behind the PCIe port 0 Gen3 DART) arrived with an identical SHA-256.
  • 0 DART fault interrupts.
  • The dwc3 USB0 gadget console (two Gen3 DART instances) worked throughout.

Earlier, with the same changes on an older base (integration/aurora f5fa539):

  • USB device controller, two DART instances, under SMP: without the aperture invalidate, 8 of 20 256 KiB bulk transfers carried stale data; with it, 220 transfers (100 MiB) were byte-exact and the DARTs raised no exceptions. That version dispatched inside the TLB command function, with inline asm for the TLBI.
  • The SEP DART with apple,gen3-ias = <36>: Touch ID enrolment and verification work. apple,gen3-ias was not exercised in this retest (no SEP node in that tree).

Checks on this base:

  • drivers/iommu/apple-dart.o with W=1 builds without warnings (clang, LLVM=1, arm64).
  • Host tests (in a Debian container, as host-tests.yml runs them): every tools/asahi test that reads drivers/iommu/apple-dart*.c passes, at both base and head: apple-dart-range, apple-dart-fw, apple-dart-fw-harness, apple-dart-tlb-stall (with --dtc; the every-handoff mutation is still killed), apple-dart-dapf, dart-sleep-power, dart-sleep-writer, dart-sleep-snapshot, dart-cio-owner, dart-cio-power and j613-mtp-s2idle. The --ref negative controls, which need git history, were not run.
  • scripts/dtc/apple-dt-check.sh (base bf423bf0e, head = this series together with j804/dt-board, j804/t8152-mailboxes and the J804 NVMe change): 137 Apple DTBs built at both, 0 new CHECK_DTBS warnings (8 removed: the J873g apple,t8152-pmgr/-pmgr-pwrstate ones), and dt_binding_check passes for every changed binding.

integration/aurora has since moved to 677be395b; this branch still merges into it without conflicts.

Known limitations

  • apple,tlbi-aperture is a physical address in a vendor property. A named reg entry would be more usual, but the aperture is one SoC block shared by every Gen3 DART, and the existing T8152 DART nodes already use their second reg for a second DART instance. A phandle to a shared aperture node plus an offset is the other option, if reviewers prefer it.

  • Gen3 exception reporting is not handled. The T8110 IRQ path reads registers that are zero on Gen3. That is left for a separate change, once the Gen3 exception registers are documented.

  • Keeping the firmware roots of locked T8152 display DARTs (fw_mirror) is not part of this PR. On the locked real-time display streams a whole-stream TLBI under a running scanout faults the DCP, so that change belongs with the display support.

  • No DT user is added here. The J804 nodes that use these properties come with their consumers.

Dependencies

None.

🤖 Generated with Claude Code

LiamRay11 and others added 3 commits November 16, 2026 08:39
…3-ias

T8152 Gen3 DARTs are invalidated through a command slot in the SoC's
shared TLBI aperture rather than the T8110 TLB command register, and
the loader may leave a stream with a narrower table walk than the VA
width the DART reports. Describe both, for apple,t8152-dart only:

  - apple,tlbi-aperture: physical address of the DART's command slot
  - apple,gen3-ias: the walk width in bits, which requires the aperture

Signed-off-by: LiamRay11 <228416644+LiamRay11@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Gen3 DARTs of T8152 do not act on the T8110 TLB_CMD register: a
stream flush written there completes, but the DART keeps translating
with the old entries. A Gen3 stream is invalidated through the SoC's
shared TLBI aperture instead. A 16-byte command (bit 60, the DART's TLBI
route from register 0x4604, the stream) is stored to the aperture,
followed by a broadcast TLBI that the DART observes; the final DSB
completes only once the broadcast has. This is the sequence the aura
loader uses for its own Gen3 mappings (dart_gen3_tlb_invalidate()).

A DART opts in with "apple,t8152-dart" and the physical address of its
command slot in "apple,tlbi-aperture". "apple,t8152-dart" gets its own
hardware ops, the T8110 ones with an invalidate_tlb that takes the
aperture when there is one; without the property nothing changes, so the
existing T8152 nodes, which have no aperture, keep the T8110 path. The
ranged invalidations of firmware-held and locked DARTs still use
TLB_CMD, as no Gen3 DART takes them yet. Like the T8110 command path, an
invalidation is refused with -EHOSTDOWN while the DART's commands are
gated. The aperture is shared by all Gen3 DARTs, so commands are
serialised by one lock.

Tested with an earlier version of this change on an earlier base
(integration/aurora f5fa539), on a MacBook Pro (M6, J804) with the USB
device controller's two DART instances under SMP: without the aperture
invalidate, 8 of 20 256 KiB bulk transfers carried stale data from
earlier mappings; with it, 220 transfers of 256-512 KiB (100 MiB) were
byte-exact and the DARTs raised no exceptions.

Signed-off-by: LiamRay11 <228416644+LiamRay11@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The T8152 Gen3 DARTs report a 42-bit VA in PARAMS3, so the driver
builds four-level tables for them. The loader (and the firmware it
hands over to) runs these streams with a three-level walk indexed by
the low 36 bits of the DVA, while the device itself issues DVAs in a
high window such as 0x100_0000_4000. The tables Linux builds must
match the walk the DART is configured for.

Add an optional "apple,gen3-ias" property to Gen3 DART nodes (those
with an apple,tlbi-aperture) that sets the walk width. The domain
already masks every DVA with the walk width before it touches the
tables, so the device keeps its high window while the tables use the
low bits. The property is ignored outside 32 bits to PARAMS3's width,
and without it nothing changes.

Tested on an earlier base (integration/aurora f5fa539), on a MacBook Pro
(M6, J804), on the SEP's Gen3 DART, whose stream 0 the loader leaves
with a three-level walk: with apple,gen3-ias = <36> the SEP runs on
Linux's tables (Touch ID enrolment and verification); without it the
four-level tables do not match the stream's walk.

Signed-off-by: LiamRay11 <228416644+LiamRay11@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

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

Test report, 2026-11-17: Apple Mac mini M6 (J873g/T8152, board 0x24). PR revision tested: 0ffca47a6103dbe9f8f87282ddcb9a2c165229e4.

Host validation used the combined #2105–2108/#2110–2112 series (54742c617db4 on 677be395b9d2) with Clang 22. All changed driver objects built with W=1 and no new warnings; two pre-existing DART unused-helper warnings were unchanged.

apple-dart.o built with Clang 22 and W=1 with no new warnings. The 15 DART host regression cases passed, including negative controls; the related MTP/DART check passed 1/1. All 137 Apple DTBs built at base and combined head with no new warning lines, and all ten changed bindings passed.

Hardware coverage is limited: the current mini DT contains neither apple,tlbi-aperture nor apple,gen3-ias. Its custom display DART uses apple,t8152-dart-gen3. The new opt-in invalidation/walk-width path was therefore not exercised on hardware. The patch also did not apply cleanly to the older private M6 DART branch, and no forced backport was used. These results do not qualify the new Gen3 path for deployment.

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