Skip to content

iommu/apple-dart: gate the firmware table handoff on its DT property - #2474

Merged
RyanTheTide merged 4 commits into
mainfrom
sweep/redundant-gates-iommu
Nov 26, 2026
Merged

RyanTheTide merged 4 commits into
mainfrom
sweep/redundant-gates-iommu

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Problem

apple_dart_fw_handoff_enabled() (drivers/iommu/apple-dart.c:1043, e47d06c) took the reserved firmware table handoff only on apple,t8140-dart, even though the boot loader's apple,firmware-root-handoff = <1> property is what says the tables were reserved. Three other probe conditions also checked of_machine_is_compatible("apple,t8132") next to an apple,t8132-dart compatible or a T8132-only board helper.

Change

  • The handoff is now gated on the DT property plus the one hardware condition the table walker depends on: the DART uses the APPLE_DART2 page-table format, which apple_dart_pte_to_paddr() decodes. T8103-format DARTs never take it.
  • The redundant T8132 machine checks are removed (lines 5372, 5380, 5911). This does not change behaviour.

No in-tree DT sets the property; only the boot loader adds it. DARTs without it are unchanged on every SoC.

Testing

  • Host fixture tools/asahi/apple-dart-fw-tests.py: 86/86 pass. The "other SoC" case is replaced with a DART1-format case.

  • Built with the lane release config (arm64, LLVM=1): apple-dart.o with W=1, no new warnings.

  • Hardware (one-shot test kernel 7.3.0-aurora-swl1 or -swl2 = integration 0abc2f3 + this and the other open sweep PRs, 2026-11-20):

    • T8112 J413 (swl2, kernel-only): boot + 3 s2idle cycles rc=0, 0 kernel errors, 0 DART errors, Wi-Fi up, 0 brcmfmac DMA / NVMe timeout lines, 0 AVC.
  • Hardware (one-shot test kernel 7.3.0-aurora-swl1 or -swl2 = integration 0abc2f3 + this and the other open sweep PRs, 2026-11-20):

    • T6000 J316s (swl2, kernel-only): boot + 3 s2idle cycles rc=0, 0 kernel errors, 0 DART errors, Wi-Fi up, 0 brcmfmac DMA / NVMe timeout lines, 0 AVC.

Still to run

  • Neo (T8140 J700), boot under the loader that sets the handoff: the dmesg handoff/mirror lines match a base kernel, internal display up, dmesg | grep -i dart shows no new faults. Hardware rows: pending.
  • J616s, M1 Pro, M2: boot clean, display and NVMe up. Hardware rows: pending.
Credit and reach

Chris Kearney wrote the handoff; Eryk Wieliczko and Diljit Singh wrote the T8132 conditions. SoCs reached that we cannot boot: any SoC whose loader sets the property on a DART2-format DART. Without that property, nothing changes.

apple_dart_fw_handoff_enabled() required the DART to be locked, to carry
apple,firmware-root-handoff = <1>, and to be an apple,t8140-dart. The
property is the boot loader's statement that it reserved the locked
root and leaf table pages; the compatible check added nothing a loader
could not already say, and it would silently drop the handoff on any
other SoC whose loader sets the property.

Gate on the property and on the one hardware condition the table walker
depends on: the DART uses the APPLE_DART2 page-table format, which
apple_dart_pte_to_paddr() decodes. T8103-format DARTs never take the
handoff.

No in-tree DT sets the property; only the boot loader adds it, so DARTs
without it are unchanged. The host fixture replaces its "other SoC"
case with a DART1-format case.

Fixes: e47d06c ("iommu/apple-dart: reserve retained firmware tables and root slots")
Suggested-by: Chris Kearney <[email protected]>
Signed-off-by: Ryan Murray <[email protected]>
Three probe-time conditions tested of_machine_is_compatible("apple,t8132")
next to a check that already implies it:

 - the J713 radio DART and the off-qualified-firmware display DARTs also
   require an apple,t8132-dart node, which only T8132 device trees have;
 - the live MTP bypass retention also requires apple_t8132_live_mtp(),
   which is true only on T8132 boards (J713, J715, J604).

Drop the machine checks. No behaviour change.

Credit to Eryk Wieliczko and Diljit Singh, who wrote the conditions.

Signed-off-by: Ryan Murray <[email protected]>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

J700 (MacBook Neo) row, from one combined test kernel (integration b4cd7b3 plus this PR, #2477, #2370 and #2299), one-shot boot on the production Stage 2, compared against the production kernel:

  • 0 DART faults before and after a 30 s s2idle. Internal display up.
  • The DART lines are the same as the base apart from four apple-ave "DART before/after start" lines, which only appear once the encoder has run; it hadn't on this boot.
  • This Stage 2 sets no firmware-table handoff, so both kernels log no handoff/mirror lines and take the no-handoff branch. The handoff branch itself still needs a row under a loader that sets the property.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Blockers: 1.

  1. drivers/iommu/apple-dart.c:1048: dart->hw->fmt == APPLE_DART2 lets more DARTs through than the T8110 path the handoff code depends on. apple_dart_hw_t6000 (dart.c:6332, .type = DART_T6000, .fmt = APPLE_DART2, .invalidate_tlb = apple_dart_t8020_hw_invalidate_tlb) also matches, and apple_dart_is_locked() can report it locked through DART_T8020_CONFIG_LOCK. On such a DART dart->version stays 0, because only the DART_T8110 case of probe sets it (dart.c:5714). So every guard that sends a handoff DART to apple_dart_fw_invalidate() fails: dart.c:1575, 2078 and 2731 all need version >= 0x0202. The invalidates fall through to a whole-SID hw->invalidate_tlb, and that is the invalidate the comment above apple_dart_fw_invalidate() (dart.c:1890ff) says breaks the firmware's scanout and makes the DCP panic. apple_dart_fw_invalidate() itself writes only T8110 TLB commands (apple_dart_t8110_hw_tlb_command_range). Fix: gate on what those paths need, dart->hw->type == DART_T8110 && dart->version >= 0x0202. version is already set by line 5868. Also add a fixture case with a T8110-format DART below 0x0202 next to handoff-dart1-format. Today no loader sets the property on such a DART, but the commit lets any loader that does take the handoff, and that is the case this gate has to refuse.

The T8132 commit (2561bf8) is a no-op as stated: apple_t8132_managed_radio(), apple_t8132_firmware_path() and apple_t8132_live_mtp() (include/linux/soc/apple/t8132.h) are true only on T8132 machines, and the apple,t8132-dart checks stay. CI host-tests pass and the branch merges cleanly with integration/aurora.

HW row: J700 (T8140) on 2561bf8 + integration, booted by a Stage 2 that sets apple,firmware-root-handoff = <1> on the display DARTs. The handoff/mirror dmesg lines should match the production kernel under the same loader, the internal panel should come up and survive 3 s2idle cycles, and the run should show 0 new DART faults, 0 AVC and 0 failed units. The posted J700 row took the no-handoff branch, so it does not exercise the changed predicate.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Merge-train adversarial review (MERGETRAIN-LINUX2) at 2561bf8: BLOCKERS.

Not merging until the blockers below are fixed or answered; the details give file:line and a failure case.

Full review

#2474 iommu/apple-dart: gate the firmware table handoff on its DT property @2561bf89

VERDICT: BLOCKERS

Blockers

  1. drivers/iommu/apple-dart.c:1048: the new predicate dart->hw->fmt == APPLE_DART2 also admits apple_dart_hw_t6000 (apple-dart.c:6332-6338: .type = DART_T6000, .fmt = APPLE_DART2, .invalidate_tlb = apple_dart_t8020_hw_invalidate_tlb). The apple,t6000-dart match (apple-dart.c:7141) is used by the M1 Pro/Max display DARTs (t600x-die0.dtsi:571 disp0_dart, :581 dcp_dart). iBoot leaves those DARTs locked, and apple_dart_is_locked() (4951) reads that lock through DART_T8020_CONFIG_LOCK. On a T6000 DART dart->version stays 0, because only the DART_T8110 case sets it (5714). So every path that is meant to keep a handoff DART away from firmware-held slots is skipped: retire at 1575-1576, apple_dart_t8110_hw_invalidate_tlb at 2078-2080 and the map/unmap path at 2731-2736 all need version >= 0x0202. Those paths fall through to a whole-SID hw->invalidate_tlb, and that is the invalidate the comment above apple_dart_fw_invalidate() (around 1890) says breaks firmware scanout. Failure: a loader that sets apple,firmware-root-handoff = <1> on the J316s disp0/dcp DART gets fw_handoff = 1, and the first unmap flushes the whole SID under the running DCP. A T8110-format DART with version < 0x0202 fails the same way. The predicate has to require what the handoff paths depend on: dart->hw->type == DART_T8110 && dart->version >= 0x0202. version is already set before line 5868. The existing review comment raised this and the head has not changed since.
  2. tools/asahi/apple-dart-fw/fixture.c:210: the only new negative case is hw.fmt = APPLE_DART. Nothing tests a T6000-type DART or a T8110 DART below v2.2, so the fixture encodes the wrong gate. Add those cases once (1) is fixed.

Nits

  • 2561bf8 is a no-op for in-tree DTs, as its message says: apple,t8132-dart appears only in t8132*.dtsi. Note that the second check it touches is !apple_t8132_firmware_path(), which is true on every non-T8132 machine, so only the node-compatible check keeps it T8132-only. The commit message ought to say that, not that the helper implies T8132.
  • The comment at 5867 ("requires the matched three-level loader") is now the only description of the four-level refusal (1499-1502). Fold it into the comment at 1037-1042.

Missing rows

  • The handoff branch has never been run: the posted J700 row took the no-handoff branch, because its Stage 2 does not set the property. Needed: J700 under a Stage 2 that sets apple,firmware-root-handoff = <1>, with the same handoff/mirror dmesg as production, panel up through 3 s2idle cycles and 0 new DART faults. Once (1) is fixed, a J316s (T6000) boot showing the handoff is refused even if the property is present.
  • I could not run the host fixture locally: the script also needs drivers/iommu/iommu.c and more. I am relying on the CI host-tests result the existing review reported.

apple_dart_fw_handoff_enabled() admitted any locked DART with the
APPLE_DART2 PTE layout. That includes the T6000 DARTs (M1 Pro/Max
display and DCP DARTs), which never set dart->version. The paths that
keep a handed-off table away from firmware-owned slots (retire, the
per-slot invalidate and the locked map/unmap) all require version
0x0202 or later, so on such a DART a loader that set
apple,firmware-root-handoff = <1> would get a whole-SID TLB flush under
the running DCP on the first unmap.

Require dart->version >= 0x0202 as well. Only the T8110 family reports a
version, so this keeps T6000 and pre-2.2 DARTs on the existing
no-handoff path. The host fixture gains two refusing cases: a DART with
no version, and one at 2.1. Both fail on the previous predicate and pass
with this one; all 88 cases pass.

Signed-off-by: Ryan Murray <[email protected]>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Pushed ab6115c for review blocker 1 (one push): apple_dart_fw_handoff_enabled() now also requires dart->version >= 0x0202. Only T8110 DARTs report a version, so the M1 Pro/Max T6000 display and DCP DARTs, and any pre-2.2 DART, stay on the no-handoff path even if a loader sets apple,firmware-root-handoff = <1>. For blocker 2, the host fixture gains handoff-unversioned and handoff-version-0201.

Testing:

  • tools/asahi/apple-dart-fw-tests.py: 88/88 pass at ab6115c.
  • The two new cases fail against the previous predicate (2561bf8: abort on both), and handoff-matched passes on both.
  • drivers/iommu/apple-dart.o builds with W=1 and no warnings on the fleet config.

Still to run: the J700 row under a Stage 2 that sets the property (the handoff branch itself has never run), and an M1 Pro no-change boot. This needs a fresh adversarial pass and Dj's verdict at the new head.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Merge-train re-review (MERGETRAIN-LINUX3, a different reviewer than the fix author) at ab6115c: NO BLOCKERS. Our earlier T6000 blocker is resolved. apple-dart.c:1050-1051 now requires dart->version >= 0x0202, which matches all three guards that route a handoff DART to apple_dart_fw_invalidate() (retire, per-SID and range). An admitted DART can therefore no longer fall through to a whole-SID flush. The new fixture cases cover the format and both version refusals, and host-tests are green.

Nits:

  • Comment :1042, "Only the T8110 family reports a version": the tunneled T8132 PCIe-C path also forces 0x0202. That is harmless, because tunneled DARTs are never locked, but the comment should say "a probed T8110 DART".
  • 76a8a2a and 2561bf8 still carry the T6000 hole on their own. No loader sets the property on a T6000 DART, so there is no runtime hazard.

Still owed by us before merge: a J700 row under a Stage 2 that sets apple,firmware-root-handoff (the handoff branch has never run), plus an M1 Pro no-change boot.

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

Adversarial review against pre-pr-checklist.md (§1–§6) at verified live head ab6115c5c0461fb544b4187ba5c448b6b90dbcab: 0 code blockers, but requesting changes for a §5 hardware evidence blocker before merge.

Blocker (§5 Evidence)

  • Handoff-enabled branch is untested on hardware, and no hardware boot has been run at ab6115c5c046:
    • The core runtime behavior change in drivers/iommu/apple-dart.c alters apple_dart_fw_handoff_enabled() (adding dart->hw->fmt == APPLE_DART2 && dart->version >= 0x0202 in place of apple,t8140-dart). All posted hardware rows (J413, J316s, J700) ran at the earlier head 2561bf89 and took the no-handoff path (the J700 boot used a Stage 2 that did not set apple,firmware-root-handoff).
    • Please post hardware results at ab6115c5c046 covering:
      1. J700 (T8140) under a Stage 2 that sets apple,firmware-root-handoff = <1> (exercising the positive handoff path): handoff/mirror dmesg matching production, internal display up through s2idle, 0 new DART faults, 0 AVC denials, 0 failed units.
      2. M1 Pro (T6000, J316s) regression boot at ab6115c5c046: confirming 0 DART faults, 0 AVC denials, and 0 failed units.

Code & Checklist Summary (§1–§4, §6 — all clear)

  • Code (drivers/iommu/apple-dart.c, tools/asahi/apple-dart-fw/fixture.c, tools/asahi/apple-dart-fw-tests.py):
    • The prior T6000/pre-v2.2 blocker is cleanly resolved at ab6115c5c046. Verified every assignment to dart->version in apple-dart.c (line 5681 tunneled T8132 PCIe-C where dart->locked = false at line 5859, and line 5717 case DART_T8110:). apple_dart_hw_t6000 leaves dart->version == 0 and pre-2.2 T8110 DARTs fail dart->version >= 0x0202, matching all three handoff-aware TLB/retire guards (lines 1579, 2082, 2735).
    • Verified commit 2561bf89 removing three redundant of_machine_is_compatible("apple,t8132") checks is a true no-op (apple,t8132-dart is T8132-only at lines 5379/5386, and apple_t8132_live_mtp() is true only on J713/J715/J604 per include/linux/soc/apple/t8132.h).
    • Host fixture covers handoff-dart1-format, handoff-unversioned, and handoff-version-0201; host-tests green (88/88) and branch clean against integration/aurora.
  • §1–§3, §6: Clean — replaces apple,t8140-dart model gate with hardware format/version + DT handoff property; no hacks or safety regressions.
  • §4 Attribution: Clean — all three commits (76a8a2a1, 2561bf89, ab6115c5) carry human author/committer (Ryan Murray) and human Signed-off-by: with zero AI trailers; PR body ends with Assisted-by:.

Non-blocking Nits

  1. drivers/iommu/apple-dart.c:1042: comment says "Only the T8110 family reports a version"; tunneled T8132 PCIe-C DARTs also set 0x0202 at line 5681 (harmless since tunneled forces dart->locked = false), so "Only probed T8110-family DARTs report a version" would be slightly more exact.
  2. PR body ## Change / ## Testing still describe the pre-ab6115c5 predicate and 86/86 fixture count; worth refreshing to match ab6115c5 (dart->version >= 0x0202, 88/88).

@RyanTheTide RyanTheTide left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Review at ab6115c. The handoff requires the DT opt-in, hardware lock and the supported PTE format plus the probed version. That is narrower than a per-board choice. The existing MTP-specific path remains separate; verify it stays unaffected. Please record both a T8112 legacy probe without the opt-in and a positive locked opt-in row that performs map, unmap and resumed DMA. The host cases cover the admission edges but don't establish that live DMA survives adoption.

@github-actions github-actions Bot added area:gpu Area from CODEOWNERS (bot) 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) labels Nov 24, 2026
@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Merge readiness at ae07b8eb: not ready yet

Check Detail
CI at head no failing: host-tests, pr-text / pr-text
Review ok approved by satchlj
Requested changes ok none
Hardware row at head ok comment at ae07b8eb
Conflicts ok none
PR text adopt when you next edit add a 'Tested:' line; a 'Risk:' line (door and Macs) (guide)

Areas: area:gpu, area:platform

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

@github-actions github-actions Bot removed the merge-conflict Conflicts with the base branch (bot) label Nov 24, 2026
DjDeveloperr
DjDeveloperr previously approved these changes Nov 24, 2026

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

Verdict: FINISH, then merge at ab6115c5c046: the code is ready; it needs only a row at this head.

Blockers: none in the code. Missing row: the change is about the handoff branch, and only the paths without the handoff have run. Needed at the updated head: the J700 under a Stage 2 that sets apple,firmware-root-handoff = <1>, with the handoff and mirror lines in dmesg, the internal display up through s2idle, and no new DART faults. The branch also conflicts with main; update it first.

Checked: no Apple material. This removes a chip gate: the firmware table handoff is now chosen by the DART's apple,firmware-root-handoff DT property, and the host fixture covers a DART1-format case instead of the "other SoC" case (86/86). The J413 (and other) boots without the property show no regression: 3 s2idle cycles, 0 DART errors. CI green before the conflict. This replaces my earlier review.

Evidence

Read ab6115c5 (apple-dart.c, the fixture). Other SoCs come after the merge.

@DjDeveloperr
DjDeveloperr dismissed their stale review November 24, 2026 19:45

Superseded by the review at ab6115c

@github-actions github-actions Bot added merge-conflict Conflicts with the base branch (bot) and removed changes-requested A reviewer requested changes (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 24, 2026
Retain main's live internal-display DART admission check while
forwarding the DT handoff selection and removal of redundant guards
from the radio and retained MTP paths.

Signed-off-by: Ryan Murray <[email protected]>
@RyanTheTide
RyanTheTide requested review from a team as code owners November 25, 2026 00:37
@github-actions github-actions Bot added ci-failing A check failed at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) and removed merge-conflict Conflicts with the base branch (bot) labels Nov 25, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Forwarded the branch to current main at ae07b8eb53e5. The resolution preserves main's newer internal display admission block. The effective patch still selects retained DART tables from the boot loader's property and the probed layout/version, and removes the previously reviewed redundant checks in radio and MTP.

The DART host fixture passed 88/88, and the ARM64 16 KiB DART object built at W=1. CI and the active same-head Neo handoff and display resume result remain due. The prior J413 no-handoff result is recorded for comparison.

@satchlj satchlj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Gemini 4 Neon on @satchlj's behalf

Verdict at ae07b8eb53e5

APPROVE — Clean forward-merge preserving main's internal display admission block while gating firmware DART table handoff on the explicit DT property (apple,firmware-root-handoff == <1>), APPLE_DART2, and dart->version >= 0x0202, with all 4 CI checks green.

Blockers

None. (Note: exact-head hardware boot/IOMMU row at ae07b8eb53e5 remains owed before merge per repo readiness checks.)

Checked

  • Diff audited (3 files, +20/-9): drivers/iommu/apple-dart.c, tools/testing/selftests/apple/apple-dart-fw-tests.py, tools/testing/selftests/apple/fixture.c.
    • Confirmed apple_dart_fw_handoff_enabled() requires dart->locked && dart->hw->fmt == APPLE_DART2 && dart->version >= 0x0202 plus of_property_read_u32(dart->dev->of_node, "apple,firmware-root-handoff", &handoff) == 0 && handoff == 1, preventing false matches on T6000/DART1/unversioned/v0201 nodes.
    • Confirmed redundant of_machine_is_compatible("apple,t8132") guards are removed cleanly from j713_radio and apple_t8132_live_mtp().
    • Confirmed host selftest fixture covers handoff-dart1-format, handoff-unversioned, and handoff-version-0201.
  • CI checks at ae07b8eb53e5: 4/4 successful, 0 failing, 0 pending (Host tests/host-tests 6m25s, pr-text, pr-readiness x2).
  • Untested scope: Static diff review and CI verification only; no kernel build or live Apple Silicon IOMMU/DART hardware boot was performed in this userspace review.
Evidence
head: ae07b8eb53e5 (3 files, +20/-9)
CI: 0 cancelled, 0 failing, 4 successful, 0 skipped, 0 pending
  Host tests/host-tests: PASS (6m25s)
  pr-text, pr-readiness x2: PASS

@github-actions github-actions Bot removed the needs-review No approving review from Core or Omarchy Mac yet (bot) label Nov 25, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

ae07b8e Neo (T8140) + J616s (T6040) + J615 (T8122) (batched 0-diff merge onto main) PASS: all apple-dart IOMMUs probed cleanly, Borealis VK + GL OK on Neo/J616s, external DP-3 + eDP-1 OK, 2/2 rtc s2idle OK on all 3 Macs, Enforcing, 0 failed, 0 AVC on Neo/J616s, 0 DART/IOMMU kernel errors; fleet defaults restored.

@github-actions github-actions Bot removed the needs-hw-row No hardware row at the PR head (bot) label Nov 26, 2026
@RyanTheTide
RyanTheTide merged commit 77d70d6 into main Nov 26, 2026
5 of 8 checks passed
@RyanTheTide
RyanTheTide deleted the sweep/redundant-gates-iommu branch November 27, 2026 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:gpu Area from CODEOWNERS (bot) area:platform Area from CODEOWNERS (bot) ci-failing A check failed at the PR head (bot) needs-template PR body lacks Tested or Risk (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants