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:mainfrom
LiamRay11:j804/dart-gen3
Open

LiamRay11 wants to merge 3 commits into
aurora-silicon:mainfrom
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

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.

@RyanTheTide

Copy link
Copy Markdown

Blockers: 4.

The aperture path itself looks right: the command is built from the route read at probe, commands are serialised across all Gen3 DARTs by one raw lock taken inside dart->lock, commands_gated is honoured as on the T8110 path, and nodes without apple,tlbi-aperture (all current J873 nodes) keep apple_dart_t8110_hw_invalidate_tlb() unchanged. Checked against drivers/iommu/apple-dart.c at 0ffca47.

  1. drivers/iommu/apple-dart.c:2808-2812: the ranged sync still goes to apple_dart_fw_invalidate() (fw_mirror/fw_handoff) or apple_dart_t8110_hw_tlb_command_range() (locked) before hw->invalidate_tlb. dart->locked comes from the hardware (apple_dart_is_locked(), :5960), not from the DT, so a Gen3 DART the loader left locked, with an aperture, takes the TLB_CMD path that this PR says Gen3 ignores, and unmaps are not seen by the device. The same holds for the locked-range loop at :2042. Fail closed: at probe, if gen3_tlbi is set and the DART is locked or has a firmware handoff, refuse the aperture with an error (or refuse the probe) until a ranged Gen3 command exists, rather than relying on "no Gen3 DART takes them yet".
  2. drivers/iommu/apple-dart.c:5828-5834: an apple,gen3-ias outside 32..PARAMS3 width, or a malformed property, is silently ignored, and the DART then builds tables for the PARAMS3 width, which the commit message says do not match the stream's walk. Return dev_err_probe(-EINVAL) when the property is present but unusable. Also, the walk the loader configured is visible in the stream's TCR four-level bit, which the locked path already reads (:3408-3425); if Gen3 reports it there, deriving the width from TCR would avoid the DT property altogether.
  3. GitHub reports conflicts with the current integration/aurora (cc14570); the body's "still merges without conflicts" was against 677be39. Please rebase and rerun the host DART tests.
  4. All three commits carry a Co-Authored-By: Claude Opus 5.5 trailer; drop it and keep the Signed-off-by. The PR body ends with "Generated with Claude Code"; make the last line Assisted-by: LLM (Claude:Opus 5.5) instead.

HW row: J804 on the rebased head with the aperture on the PCIe port 0 and USB0 DARTs: the 20x256 KiB bulk stale-data test (0 stale), the 200 MB Wi-Fi SHA-256 push, the SEP with apple,gen3-ias = <36> (Touch ID enrol/verify), 0 DART faults, plus a regression line (0 AVC, 0 failed units, 0 new kernel errors). The J873g run on the same head showing the no-aperture path unchanged.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown

@LiamRay11, a tidy-up pass over the open PRs here. These of yours need something:

If any of these are no longer needed, closing them helps; otherwise a merge or rebase onto integration/aurora is usually all they need. Thanks!

@github-actions github-actions Bot added area:platform Area from CODEOWNERS (bot) merge-conflict Conflicts with the base branch (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) needs-template PR body lacks Tested or Risk (bot) labels Nov 24, 2026

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: HOLD at 0ffca47

Blockers:

  • drivers/iommu/apple-dart.c & Documentation/devicetree/bindings/iommu/apple,dart.yaml — PR is CONFLICTING/DIRTY against live main (a9cd131e8207), which already landed T8152 Gen3 DART support in #1800 and #2139 (2ac0620b4639, 762549f5a30a, 01d47a3ae576, 90d575a1a46e, 36b6071305bb, aa6db0c74edd) via apple,t8152-dart-gen3/apple,t8152-avd-dart, reg-names = "dart", "tlbi", and apple_dart_hw_gen3. Rebase onto main and unify with that binding and hw->gen3 path rather than introducing a second, divergent Gen3 interface (apple,tlbi-aperture on apple,t8152-dart + apple_dart_hw_t8152).
  • drivers/iommu/apple-dart.c:5622-5645 & Documentation/devicetree/bindings/iommu/apple,dart.yaml:415 — apple_dart_probe() reads dart->regs + DART_GEN3_TLBI_ROUTE_REG (0x4604) while only validating resource_size(res) < 0x4000 (and the binding example itself uses a 0x4000-byte reg), causing an out-of-bounds MMIO read past the ioremapped region, and reads the register before clk_bulk_prepare_enable() (:5727). Check resource_size(res) >= DART_GEN3_TLBI_ROUTE_REG + 4, fix the binding example size, and move the route read after clocks are enabled.
  • drivers/iommu/apple-dart.c:2807-2814 & :2229-2245 — apple_dart_domain_flush_tlb_range() dispatches fw_mirror/fw_handoff and dart->locked && version >= 0x0202 to TLB_CMD before calling hw->invalidate_tlb(), and apple_dart_t8110_v2_unlock() unconditionally writes DART_T8110_TLB_CMD_OP_FLUSH_UNLOCK. Because dart->locked is probed from hardware (:5960), a locked Gen3 DART would silently issue TLB_CMD. Route Gen3 before the ranged TLB_CMD branches (or fail closed at probe) and guard apple_dart_t8110_v2_unlock() on Gen3, matching main.
  • drivers/iommu/apple-dart.c:5820-5835 — A malformed or out-of-range apple,gen3-ias (< 32 or > dart->ias) is silently ignored, leaving the DART on the 4-level PARAMS3 walk width that mismatches the stream. Fail probe closed with dev_err_probe(dev, -EINVAL, ...) when the property is present but invalid, and confirm whether the walk width can be read from hardware TCR instead of a DT override (§1).
  • §4 (Attribution hygiene) — Commits 6cf161e5fa3a, 94afe8291283, and 0ffca47a6103 carry a non-human co-author trailer, and the PR body ends with a tool-generated footer. Strip all non-human trailers and footers completely (keep only the human author and human Signed-off-by:; do not add any replacement attribution line).
  • §5 (PR structure & exact-head evidence) — PR body is missing the required top-level What:, Tested:, Risk:, and Not yet: lines and lacks an exact-head hardware test row on the rebased head exercising both Gen3 TLBI invalidation and walk-width handling with the regression line (0 SELinux denials, 0 failed units, 0 new kernel errors), plus a non-regression row on another DART Mac (e.g., J873g).

Checked: Diff against main (a9cd131e8207), pre-PR checklist §1–§6, commit trailers, CI runs (dt-checks and host-tests, green only on stale base 677be395b), and J804/J873g test reports.

Evidence
  • §1 (No model gating): apple,tlbi-aperture and apple,gen3-ias are restricted to apple,t8152-dart in the binding and probe, with non-T8152 DARTs (t8103, t6000, t6020, t8112, t8122, t603x, t8132, t604x, t6050) staying on their existing ops tables. On main, Gen3 DARTs already use apple,t8152-dart-gen3 / apple,t8152-avd-dart with reg-names = "dart", "tlbi". For apple,gen3-ias, check whether hardware TCR already exposes 3-level vs 4-level configuration before adding a new DT override.
  • §2 (Production-ready, no hacks): No new kernel cmdline or module parameters, no magic sleeps/retries. However, apple_dart_probe() performs an unchecked out-of-bounds pre-clock read of 0x4604, silently ignores invalid apple,gen3-ias, and leaves locked/ranged/unlock TLB_CMD paths unguarded.
  • §3 (Safety): Failing to invalidate a locked Gen3 stream or silently falling back to a mismatched 4-level table risks stale DMA / fault corruption; fail closed on invalid configuration and unsupported modes.
  • §4 (IP & attribution): No copyrighted Apple material found. Hard-rule failure on non-human co-author trailers in all 3 commits (6cf161e5fa3a, 94afe8291283, 0ffca47a6103) and the footer in the PR body.
  • §5 (Evidence & PR structure): PR body lacks What:, Tested:, Risk:, Not yet:. J804 test data was collected on an older integration base (bf423bf0e with 9 merged PRs and unsubmitted DT nodes; apple,gen3-ias only on f5fa539), with no regression check line; sithglan's J873g report at 0ffca47 confirmed the opt-in Gen3 paths were not exercised.
  • §6 (Naming): Pass — uses aura properly; tools/asahi/ references existing repository paths.
  • Commits & CI: 3 commits (6cf161e5fa3a, 94afe8291283, 0ffca47a6103) on stale base 677be395b. dt-checks and host-tests passed on 2026-11-17 against 677be395b, not against live main (a9cd131e8207, CONFLICTING/DIRTY).
  • Non-blocking notes for unification with main:
    • Several details in this PR are worth folding into main's apple_dart_gen3_hw_invalidate_tlb(): the shared raw_spinlock_t serializing access to the SoC-wide TLBI aperture across Gen3 DART instances, the dart->commands_gated -EHOSTDOWN check, ioremap_np() for the aperture slot, and the #ifdef CONFIG_ARM64 compile-test guard.
    • Reconcile VHE HCR_EL2.TGE clearing around TLBI VALE1OS with main (762549f5a30a) when unifying the invalidation helper.
    • dma_wmb() inside the for_each_set_bit() loop (:1865) only needs to execute once before the loop.

@github-actions github-actions Bot added changes-requested A reviewer requested changes (bot) merge-conflict Conflicts with the base branch (bot) and removed merge-conflict Conflicts with the base branch (bot) labels Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:platform Area from CODEOWNERS (bot) changes-requested A reviewer requested changes (bot) merge-conflict Conflicts with the base branch (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) needs-template PR body lacks Tested or Risk (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants