Skip to content

iommu: apple-dart: confine the T8132 radio's always-on SID16 bypass to the one page it needs - #2502

Merged
RyanTheTide merged 3 commits into
aurora-silicon:integration/aurorafrom
erikwb:j713/radio-sid16-page
Nov 23, 2026
Merged

RyanTheTide merged 3 commits into
aurora-silicon:integration/aurorafrom
erikwb:j713/radio-sid16-page

Conversation

@erikwb

@erikwb erikwb commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Problem

On T8132, stream 16 of the radio's PCIe DART stays in bypass for the whole uptime. A bypassed stream can reach all of physical memory, and the RID-to-SID admission check can't tell which requester might be routed to it, so this is a standing hole in the radio's DMA isolation.

The bypass can't simply be turned off, because the radio does use the stream at runtime. Blocking it on a J713 made a write to 0x381204000 fault within seconds, after which Wi-Fi failed. That one 16 KiB page is all the stream needs.

Change

This series names that page in the DT (apple,sid16-page). When the property is present, the DART driver translates SID16 through a 3-level table that maps only that page, identity, instead of leaving it in bypass:

  • The narrowing happens at probe, after managed admission and before any radio DMA is set up, and validates dart->hw->type == DART_T8110, dart->num_streams > 16, dart->pgsize == SZ_16K, dart->oas >= 36 / dart->sid16_page < BIT_ULL(dart->oas), and restorable entry state (tcr_disabled without a valid root, or static bypass with bypass support) before allocating the table.
  • Before writing TTBR0 or TCR, apple_dart_managed_narrow_sid16() snapshots the inherited SID16 TCR, TTBR0, and ENABLE[16] state; it writes and verifies TTBR0 readback before switching TCR to TRANSLATE_ENABLE, verifies TCR readback, issues a SID16 TLB invalidation so no stale entry survives, and sets and verifies ENABLE[16].
  • On any probe error path after narrowing, apple_dart_managed_unnarrow_sid16() restores SID16 to its exact entry state: when ENABLE[16] started clear, it writes BIT(16) to DART_T8110_DISABLE_STREAMS and verifies ENABLE[16] cleared before restoring TCR (never leaving bypass enabled), then restores TCR (issuing dart->hw->tcr_bypass including the BYPASS_DAPF request bit for static bypass, or tcr_disabled) and checks exact TCR readback against sid16_init_tcr before restoring TTBR0 to its inherited value, verifies TTBR0 and ENABLE[16], flushes the SID16 TLB, and frees dart->sid16_ops only when every step succeeds (keeping the table unfreed if teardown fails). When teardown succeeds, a subsequent rebind admits cleanly instead of hitting -EBUSY.
  • After narrowing, apple_dart_managed_sid16_narrowed() (used by admission and the cold-link idle check) requires TCR, TTBR0, and ENABLE[16], so a stream that lost ENABLE[16] or went back to bypass is refused.
  • The TCR is plain TRANSLATE_ENABLE, so the existing deep-sleep snapshot/restore and the s2idle check replay and compare it exactly.
  • Without the property, behavior is unchanged.

The binding, driver (+ host selftest update), and DTS changes are separate commits, rebased onto integration/aurora (f5fae3cbb047). The property sits in t8132-jxxx.dtsi next to apple,managed-sids, so it covers every T8132 board with the radio port (J604, J623/J624, J713/J715, J773g). 0x381204000 sits 0x38000 bytes past aic's core window (0x381000000 + 0x1cc000) and below DRAM; no DT node claims it, so its owning SoC block is not identified in the DT yet. If another T8132 board's radio used a different SID16 target, the first access would fault and quarantine the radio DART, taking down Wi-Fi and BT for that boot.

Testing

  • J713 (MacBook Air 13-inch, M4, T8132 — current head 4744d692f905, base f5fae3cbb047):
    • Kernel 7.3.0-sid16-4744+ built from J713's running config with apple/t8132-j713.dtb, booted via one-shot Stage 2 (aura-try), confirming /proc/device-tree/soc/iommu@490000000/apple,sid16-page = 00000003 81204000.
    • Cold boot + s2idle (default command line root=UUID=... user4k=on loglevel=4 console=tty0): PASS:
      • dmesg logged apple-dart 490000000.iommu: SID16 bypass narrowed to page 0x381204000.
      • Wi-Fi (wlan0, BCM4388/6) associated, iw dev wlan0 scan succeeded, and gateway ping passed 3/3 (0% loss, 3.55–4.49 ms).
      • Bluetooth (hci0, hci_bcm4377) bluetoothctl --timeout 10 scan on discovered active LE devices.
      • rtcwake -d rtc1 -m freeze -s 10 (s2idle) exited 0 (PM: suspend entry (s2idle) -> PM: suspend exit); post-resume gateway ping passed 3/3 and iw dev wlan0 scan succeeded.
      • systemctl --failed: 0 failed units; SELinux: N/A (Arch ARM without SELinux); 0 DART translation faults, 0 TLB errors, 0 brcmf crashes, 0 new kernel errors.
      • Note: on current integration/aurora (f5fae3cbb047), deep sleep (mem) on the default command line is refused by apple-sleep because J713 internal DCP (30ae00000.dcp) and aurora-g16 do not bind without apple_dart.j713_dcp=1 apple_dart.j713_display=1 (pending iommu: apple-dart: adopt T8132 internal display DARTs by default on 26.6.2 firmware #2189).
    • Deep sleep (suspend-to-RAM) with J713 display flags (apple_dart.j713_dcp=1 apple_dart.j713_display=1): PASS:
      • dmesg logged apple-dart 490000000.iommu: SID16 bypass narrowed to page 0x381204000; internal DCP (30ae00000.dcp) and aurora-g16 bound (/dev/dri/renderD128 active).
      • rtcwake -d rtc1 -m mem -s 15 (deep sleep) exited 0: pcie-apple 1cb0000000.pcie: native radio DMA fenced, DART off, apple-sleep 380700000.sleep-controller: back from sleep, boot object resumes 0 -> 1 (PMU RTC alarm), pcie-apple 1cb0000000.pcie: native radio power-loss recovery complete, pcie-apple 1cb0000000.pcie: native radio transaction complete.
      • Post-deep-sleep: gateway ping over wlan0 passed 5/5 (0% loss, 2.72–4.35 ms), iw dev wlan0 scan succeeded, and bluetoothctl --timeout 10 scan on discovered active LE devices.
      • /sys/devices/platform/soc/490000000.iommu/j713_radio_fault_state: version=0x202 managed=0x6 failed=0, error_mask=0x0 error=0x0, error_streams[0]=0x0 exceptions[0]=0x0.
      • systemctl --failed: 0 failed units; 0 DART translation faults, 0 new kernel errors.
  • J713 (MacBook Air 13-inch, M4, tested by @RyanTheTide — evidence for prior head 6ffeda54, before the integration/aurora rebase and rollback fixes):
    • Kernel 7.3.0-aurora-fleet81 (integration/aurora eb6d9ec1 + open heads including PR iommu: apple-dart: confine the T8132 radio's always-on SID16 bypass to the one page it needs #2502 at 6ffeda54), booted on the default command line with the J713's configured DTB.
    • Result: PASS: fdtget confirmed /soc/iommu@490000000 carries apple,sid16-page = <0x3 0x81204000>; dmesg logged apple-dart 490000000.iommu: SID16 bypass narrowed to page 0x381204000 at 0.60 s; 0 DART faults across all 17 apple-dart fault handler interrupts; brcmfmac associated (VHT 2x2, 400 Mbit/s), gateway ping 5/5; Bluetooth powered and scanned 30 devices; rtcwake -d rtc1 -m freeze s2idle 1/1 pass with SID16 still narrowed and 0 DART faults; SELinux Enforcing, 0 AVC denials, 0 failed units, only the 2 pre-existing dwc3-apple ... genpd_prepare returns -11 error lines.
    • Earlier release/7.3.0-40 (9125b314) + test DT boot also carried 417 MB in / 419 MB out over Wi-Fi with 0 DART exceptions and confirmed SID16 TCR=0x1 with SID1/SID2 unchanged.
  • J715 (MacBook Air 15-inch, M4, Mac16,13, tested by @kazuhidet — evidence for prior head 6ffeda54, before the integration/aurora rebase and rollback fixes):
    • Kernel integration/aurora 0abc2f385 + apple-dart.c from 6ffeda54 and J715 DTB supplying apple,sid16-page = <0x3 0x81204000> on /soc/iommu@490000000.
    • Result: PASS (one boot, four records): apple-dart 490000000.iommu: SID16 bypass narrowed to page 0x381204000, 0 DART faults, no quarantine or readback failure; wlan0 only interface up, gateway ping 5/5 in every record, 0 brcmfmac errors; Bluetooth controller powered and paired device connects; failed units and kernel errors unchanged vs baseline (not covered: s2idle/resume, BT audio, throughput).
  • Static checks & host tests (at 4744d692f905, base f5fae3cbb047):
    • make -j32 ARCH=arm64 LLVM=1 W=1 O=.tmp-build defconfig && make -j32 ARCH=arm64 LLVM=1 W=1 O=.tmp-build drivers/iommu/apple-dart.o: 0 errors, 0 warnings.
    • ./scripts/checkpatch.pl --strict --git origin/integration/aurora..HEAD: 0 errors, 0 warnings, 0 checks across all three commits.
    • python3 tools/asahi/run-host-tests.py --only apple-dart: 10/10 passed.
    • python3 tools/asahi/run-host-tests.py --only bcm4377-radio-sids: 1/1 passed (models write-one-to-clear DISABLE_STREAMS and T8132 non-retained BYPASS_DAPF request bit, verifies tcr_bypass restore command and exact TCR/TTBR0/ENABLE[16] readback across disabled and static-bypass 0x2/0x6 entry states, rejects unrestorable entry states before narrowing, verifies dropped TTBR0 write fails before enabling translation, verifies dropped ENABLE[16] write fails probe and rolls back, verifies cleared ENABLE[16] fails admission and cold-link idle check with -EBUSY, and verifies mismatched TCR readback or failed DISABLE_STREAMS/TCR/TTBR0/TLB-flush teardown keeps sid16_ops unfreed).
    • python3 tools/asahi/run-host-tests.py --only pciec-policy: 1/1 passed.
    • python3 scripts/dtc/apple-dart-pd-check-test.py: 13/13 passed.
  • DT schema & DTB checks (unchanged binding and DTS commits cherry-picked cleanly from 971399886047 and a3cf6c4ebeef):
    • make dt_binding_check DT_SCHEMA_FILES=Documentation/devicetree/bindings/iommu/apple,dart.yaml and make CHECK_DTBS=y on the six T8132 DTBs (t8132-j604, t8132-j623, t8132-j624, t8132-j713, t8132-j715, t8132-j773g) passed on the identical binding and DTS commits (971399886047 and a3cf6c4ebeef).

Tested-by: @kazuhidet
Tested-by: @RyanTheTide

Still to run

  • Default-command-line deep-sleep (suspend-to-RAM) cycle on J713 once iommu: apple-dart: adopt T8132 internal display DARTs by default on 26.6.2 firmware #2189 lands so internal DCP and GPU bind on the default command line (above, s2idle ran on the default command line and deep sleep ran with J713's apple_dart.j713_dcp=1 apple_dart.j713_display=1 display flags).
  • J715 re-verification on current head 4744d692f905 (the J715 row above is for prior head 6ffeda54), plus additional T8132 boards (J604, J623/J624, J773g) if available.

Assisted-by: LLM (Anthropic:Claude Opus 5.5, Google:Gemini 4 Neon, Google:Gemini 4 Hydrogen)

@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks, closing the SID16 bypass is a real isolation win, and the register-dump evidence is great.

One placement question. Isolation policies like this are something we apply on every machine that has the hardware, never only where it was tested. apple,managed-sids on dart_apcie0 lives in t8132-jxxx.dtsi, which J604, J623/J624, J713/J715 and J773g all include, so they all keep SID16 in bypass, but the page is named only in t8132-j713.dts:280.

0x381204000 is below DRAM and is mapped IOMMU_MMIO, so it looks like an SoC address rather than a board one. If so, could the property move to t8132-jxxx.dtsi next to apple,managed-sids? If the page really differs per board or radio module, a comment saying why, plus the value on each board, would do it.

We don't have a T8132 in our lab, so a Wi-Fi/BT row from a J715 or J773g owner would close it.

@erikwb
erikwb force-pushed the j713/radio-sid16-page branch from 86026df to 6ffeda5 Compare November 20, 2026 04:23
@erikwb erikwb changed the title iommu: apple-dart: confine the J713 radio's always-on SID16 bypass to the one page it needs iommu: apple-dart: confine the T8132 radio's always-on SID16 bypass to the one page it needs Nov 20, 2026
@erikwb

erikwb commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

Note

🤖 Claude Opus 5.5 responding on behalf of erikwb

Moved. apple,sid16-page now sits in t8132-jxxx.dtsi next to apple,managed-sids (6ffeda5), so all six T8132 boards get it. The commit messages and title now say T8132.

  • Agreed that it's an SoC address: 0x381204000 is below DRAM, next to the AIC range. Nothing in the radio path picks a per-board target, so I expect the same page on every board.
  • That is still inferred. It's verified only on the J713. If another board's radio used a different SID16 target, the first access would fault and quarantine the radio DART, so Wi-Fi and BT would fail for that boot. The PR description now says this.
  • All six DTBs pass CHECK_DTBS against apple,dart.yaml and carry the property. The J713 DTB decompiles identically to the one tested on hardware, so the J713 results still apply.

Agreed on a J715 or J773g Wi-Fi/BT row before merge.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks for moving apple,sid16-page into t8132-jxxx.dtsi next to apple,managed-sids (6ffeda5), and for writing down in the description what happens if another board's radio uses a different page. That covers the placement question. What's left is the CI run that is still going and a Wi-Fi/BT row from a J715 or J773g owner.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Merge-train adversarial review (MERGETRAIN-LINUX2) at 6ffeda5: NO BLOCKERS.

Code read only, nothing built here. Before the merge it still needs Dj's verdict at this head; the missing rows are listed below.

Full review

#2502 iommu: apple-dart: confine the T8132 radio's always-on SID16 bypass to the one page it needs @6ffeda54

VERDICT: NO BLOCKERS in the code. Do not merge it before the J715/J604/J773g rows below are run.

Checked and found OK:

  • The table is never freed. dart is retained, so apple_dart_release() skips the kfree.
  • The TTBR is encoded the same way as apple_dart_hw_set_ttbr().
  • The deep-sleep power restore replays every SID's TCR and TTBR0 and flushes (apple-dart-sleep.c:498-507). The s2idle verify compares them exactly. The narrowed values never change, so both paths hold.
  • Quarantine only touches SID1/2 (apple-dart.c:2609). The narrowed SID16 is never reset.
  • The PTE gets NO_CACHE because IOMMU_CACHE is not passed (io-pgtable-dart.c:219), which is correct for an MMIO page.
  • 36-bit IAS with 16K pages gives 3 levels, matching the n_levels check.

Nits / risks:

  1. apple-dart.c:2534 + 6082: once SID16 is narrowed, a later probe failure leaves its TCR at TRANSLATE_ENABLE. Example: request_irq or sysfs fails, goto err_clk_disable, then a rebind. The new struct apple_dart has sid16_ops == NULL, so apple_dart_managed_admit() falls into the static-bypass branch, sees neither bypass nor disabled, and returns -EBUSY. The radio DART cannot probe again until reboot. Before this PR a rebind after quarantine was admitted. This is error path only, but worth either accepting a TCR==TRANSLATE_ENABLE whose TTBR matches a valid root, or documenting it.
  2. t8132-jxxx.dtsi:450: the address is an observation from J713 faults written into the shared T8132 include. It is not read from the ADT or the loader.
    • 0x381204000 sits just past the AIC node's "core" reg (0x381000000 + 0x1cc000), i.e. in the interrupt controller's address block.
    • The binding/comment should say what the page is, so a reviewer can judge giving a device RW on it.
    • Better: a phandle/offset into the owning node, or a loader-filled value from the ADT, instead of a raw u64 copied to all six boards.
    • The rule (safety limits come from the machine) is met only in letter: the value is in DT, but nobody derived it from this machine.
  3. The binding name apple,sid16-page hardcodes the stream number. That is acceptable only because the driver already hardcodes SID16 as the static role.
  4. PR body: ends with "Created with Claude Opus 5.5 in Claude Code" plus the Claude Code footer, not the house line "Assisted-by: LLM (Claude:Opus 5.5)". That is a body-only hygiene issue; the commits are clean.
  5. The driver was proven on pin 9125b31 with a test-only DT commit, not at this head on the integration tip (453 commits behind base). The installed Stage 2 DTB predates the property, so on lab Macs with a stale Stage 2 the feature is silently inactive (bypass kept). Check the live fdt before you count a row as proof.

Missing rows:

  • J715, J604, J773g, J623/J624 Wi-Fi + BT traffic with the property in the live DT. A different SID16 target on any of them means a SID16 fault, managed quarantine, and Wi-Fi/BT dead for that boot. That is a regression from today, on every board covered by jxxx.dtsi.
  • J713 at this head on the integration tip, with the property coming from the real Stage 2 DT (not a test commit).
  • Deep sleep (s2r) + resume with SID16 narrowed, on any T8132 machine. Not run.
  • s2idle snapshot verify with the narrowed stream.

@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 at 6ffeda54eaa0.

Summary: 0 code, CI, attribution, or policy blockers. CI (dt-checks, host-tests) is green, all 3 commits carry human identity and Signed-off-by: only, and moving apple,sid16-page to t8132-jxxx.dtsi applies the narrowing uniformly across all T8132 boards with the radio port.

Checked

  • apple_dart_managed_narrow_sid16() maps a single 16 KiB IOMMU_READ | IOMMU_WRITE | IOMMU_MMIO (non-cacheable) page in a 3-level 36-bit APPLE_DART2 table, verifies iova_to_phys, writes TTBR before TCR = DART_T8110_TCR_TRANSLATE_ENABLE, and verifies readback.
  • Table lifetime is safe (apple_dart_retain_radio() sets dart->retained = true before narrowing, so apple_dart_release() never frees dart or the table), managed quarantine touches only SID1/SID2, and apple-dart-sleep.c snapshots/restores SID16 TCR and TTBR0 verbatim.
  • When apple,sid16-page is absent (older DTBs), behavior is unchanged; when present, a disabled SID16 is narrowed directly without ever entering bypass.

Non-blocking observations

  • Probe failure rebind edge case (drivers/iommu/apple-dart.c:2534, 6081): If probe fails after apple_dart_managed_narrow_sid16() succeeds (e.g., request_irq() or sysfs registration fails), hardware SID16 remains in TRANSLATE_ENABLE, while a subsequent rebind allocates a fresh struct apple_dart with sid16_ops == NULL and fails apple_dart_managed_admit() with -EBUSY until reboot.
  • Topology validation: apple,sid16-page is checked against SZ_16K and BIT_ULL(36) before DART_PARAMS are read; checking dart->pgsize == SZ_16K and dart->sid16_page < BIT_ULL(dart->oas) inside apple_dart_managed_narrow_sid16() would avoid assumptions if reused elsewhere.
  • Defensive TLB flush: Issuing a SID16 TLB invalidation after switching TCR from bypass/disabled to translate would remove the assumption that boot firmware never populated a SID16 TLB entry.
  • Page provenance (t8132-jxxx.dtsi:450): Documenting which SoC MMIO block owns 0x381204000 (just above AIC's 0x381000000+0x1cc000 window) would make the RW grant easier to audit.

Hardware/runtime evidence still owed (§5)

  • J713 on this head (6ffeda54eaa0) on integration/aurora with the real Stage 2 DTB supplying apple,sid16-page (not a cherry-pick onto 9125b314 with a test-only DT commit), including full regression counts (0 SELinux denials, 0 failed units, 0 new kernel errors).
  • Wi-Fi and Bluetooth traffic verification on at least one other T8132 board (J715, J604, J623/J624, or J773g) with apple,sid16-page active in the live FDT, confirming 0x381204000 matches across the SoC family without faulting/quarantining the radio DART.
  • s2idle snapshot verify and a deep-sleep suspend/resume cycle with narrowed SID16.

Assisted-by: LLM (Gemini 4 Neon)

@kazuhidet

Copy link
Copy Markdown

Wi-Fi/BT row from a J715 (MacBook Air 15-inch, M4, Mac16,13) at 6ffeda54, OS firmware 26.6.2, stage 1 → aura.

Build

Result: pass (one boot, four records)

Check Result
DT apple,sid16-page = <0x3 0x81204000> on /soc/iommu@490000000
DART apple-dart 490000000.iommu: SID16 bypass narrowed to page 0x381204000. No quarantine or readback failure. 0 DART faults
Wi-Fi wlan0 the only interface up (Ethernet unplugged). Gateway ping 5/5 in every record. 0 brcmfmac errors
Bluetooth controller powered, the paired device connects
Failed units, kernel errors same as without this PR (two local services, avd -2, external DCP not handed over)

Not covered: s2idle/resume with the narrowed bypass, BT audio, and throughput.

@erikwb

erikwb commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Note

🤖 Gemini 4 Neon responding on behalf of erikwb

Thanks @kazuhidet for the J715 (Mac16,13, OS 26.6.2) verification row at 6ffeda54 — confirming apple,sid16-page = <0x3 0x81204000> narrows SID16 cleanly on a second T8132 board with Wi-Fi + Bluetooth active and 0 DART faults.

Updated the PR description with your J715 PASS row and credit (and replaced the old footer with a plain Assisted-by: line per @RyanTheTide's hygiene note; no commit changes on 6ffeda54eaa0). Remaining hardware rows are J713 on integration/aurora with the live Stage 2 DTB (plus regression counts), s2idle snapshot verify, and a deep-sleep cycle with narrowed SID16.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks @kazuhidet for the J715 row. It runs this head's driver with apple,sid16-page in the live DT, and it shows the page matches on a second T8132 board with Wi-Fi and Bluetooth up and no DART faults.

Two points from the earlier reviews are still open at 6ffeda54. Both are small:

  • If probe fails after apple_dart_managed_narrow_sid16() (apple-dart.c:6081-6088), SID16 stays in translate mode with the old table. A rebind then starts with sid16_ops == NULL and gets -EBUSY from apple_dart_managed_admit() (:2356) until reboot. Either admit a translating SID16 whose TTBR points at a valid root, or tear the narrowing down on the error path.
  • t8132-jxxx.dtsi:446-449 should say which block owns 0x381204000. It sits just past the AIC core range, and naming the block lets a reader judge the RW grant.

The remaining rows are the ones in "Still to run": J713 at this head with the property coming from the Stage 2 DTB, and an s2idle verify plus a deep-sleep cycle with SID16 narrowed.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor

J713 row at 6ffeda5 (13-inch M4 Air, macOS 27.2 stub), for item 1 of the 11-22 review: the property comes from the J713's real Stage 2 DTB, with regression counts.

The kernel is 7.3.0-aurora-fleet81, the J713's default since 11-23. It is integration/aurora eb6d9ec plus open heads, including this PR at 6ffeda5, built with its DTBs. It booted on the default command line with the J713's configured Stage 2.

  • Live device tree: /soc/iommu@490000000 has apple,sid16-page = <0x3 0x81204000>. Read with fdtget from the booted FDT.
  • dmesg: apple-dart 490000000.iommu: SID16 bypass narrowed to page 0x381204000 at 0.60 s.
  • DART faults: the 17 apple-dart fault handler interrupts on AIC2 54-63 all count 0, read after an s2idle cycle. There are no DART fault lines in dmesg.
  • Wi-Fi: brcmfmac associated (VHT 2x2, 400 Mbit/s), and the gateway answered 5/5 pings.
  • Bluetooth: the controller is powered and its scan found 30 devices.
  • s2idle: rtcwake -d rtc1 -m freeze 1/1, woke on the alarm, suspend_stats fail 0. SID16 stayed narrowed and there were no DART lines afterwards.
  • Counts: SELinux Enforcing, 0 AVC denials, 0 failed units. The 2 kernel error lines are the existing dwc3-apple ... genpd_prepare returns -11 refusals during s2idle; the previous default has them too.

Still to run: one deep-sleep cycle with SID16 narrowed. The two small code points from 11-22 17:12 (the narrowing left in place on a failed probe, and naming the block that owns 0x381204000) are also still open.

Assisted-by: LLM (Claude:Opus 5.5)

The T8132 radio DART's SID16 keeps a static bypass for the whole uptime,
but only needs to reach one page. Let the DT name that page so the OS
can translate the stream through a table that maps only it.

Signed-off-by: Erik Bourget <erik@ebourget.net>
The radio DART's SID16 keeps the static bypass role it gets at boot for
the whole uptime. A bypassed stream reaches all of physical memory, and
the RID-to-SID admission cannot see which requester could be routed to
it. At runtime the stream only writes one page: blocking it outright
makes that write fault and the radio fail.

When the DT names that page in apple,sid16-page, translate SID16 through
a 3-level table that maps only it, identity, after admission and before
any radio DMA is set up. Admission and the cold-link idle check accept
the narrowed stream; the sleep snapshot and restore already carry its
TCR and TTBR. Without the property the bypass is kept as before.

Signed-off-by: Erik Bourget <erik@ebourget.net>
On the J713 the radio DART's static SID16 stream only writes the SoC
page at 0x381204000. Name it in the shared T8132 board include, next to
apple,managed-sids, so the DART driver replaces the stream's bypass
with a one-page table on every board that has the radio port.

Signed-off-by: Erik Bourget <erik@ebourget.net>
@RyanTheTide

RyanTheTide commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Deep-sleep item at 6ffeda5 (J713, 13-inch M4 Air): 3 deep sleeps with SID16 narrowed.

The kernel is 7.3.0-aurora-fleet82: integration/aurora f5fae3c plus open heads, including this PR at 6ffeda5 unchanged. It booted as a one-shot on the default command line with the live Stage 2 DTB. dmesg had SID16 bypass narrowed to page 0x381204000 at boot.

  • 3 × rtcwake -d rtc1 -m mem -s 15, each a PM: suspend entry (deep). suspend_stats +3 successes, 0 failures.
  • After every wake:
    • The apple-dart fault handler interrupts summed over all CPUs stayed at 0.
    • Wi-Fi reassociated and the gateway answered 3/3 pings.
    • Bluetooth scanned 13 to 28 devices.
  • The same boot also ran 12 s2idle cycles and a WoWLAN magic-packet wake, again with no DART fault interrupts.

Assisted-by: LLM (Claude:Opus 5.5)

@erikwb
erikwb force-pushed the j713/radio-sid16-page branch from 6ffeda5 to 4744d69 Compare November 22, 2026 19:23
@erikwb
erikwb marked this pull request as draft November 22, 2026 19:25
@erikwb

erikwb commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Note

🤖 Gemini 4 Hydrogen responding on behalf of erikwb

Updated the PR to 4744d692f905 (rebased onto integration/aurora f5fae3cbb047, driver/selftest commit f8accf4e6b8a) and keeping it in draft until the updated-head hardware run and deep-sleep cycle complete. Note that @RyanTheTide's J713 7.3.0-aurora-fleet81 row (s2idle, Wi-Fi, BT, 0 AVC denials, 0 failed units) and @kazuhidet's J715 run remain evidence for prior head 6ffeda54, not 4744d692f905.

Changes addressing the re-review points:

  • SID16 admission, narrowing, and rollback (drivers/iommu/apple-dart.c):
    • apple_dart_managed_narrow_sid16() now rejects unrestorable entry states before narrowing (dart->hw->type != DART_T8110, dart->num_streams <= 16, already-narrowed sid16_ops, tcr_disabled with a valid root, static bypass without supports_bypass/tcr_bypass, or unexpected TCR modes) and verifies TTBR0 readback before writing TCR to DART_T8110_TCR_TRANSLATE_ENABLE (so a dropped TTBR0 write never enables translation against an inherited root).
    • apple_dart_managed_unnarrow_sid16() issues dart->hw->tcr_bypass (including the DART_T8110_TCR_BYPASS_DAPF request bit, rather than re-writing a 0x2 readback) when restoring static bypass while checking exact TCR readback against sid16_init_tcr, restores TTBR0 to its inherited value, verifies TTBR0 and ENABLE[16], flushes SID16's TLB, and frees dart->sid16_ops only when every check succeeds.
  • bcm4377-radio-sids.py host test (tools/testing/selftests/drivers/apple/bcm4377-radio-sids.py): Models both write-one-to-clear DISABLE_STREAMS and T8132's non-retained DART_T8110_TCR_BYPASS_DAPF request bit on DART_TCR writes, verifies last_sid16_tcr_write == hw->tcr_bypass with exact 0x2/0x6 readback across disabled and static-bypass entry states, tests rejection of unrestorable entry states before narrowing, tests a dropped TTBR0 write during narrowing (verifying TRANSLATE_ENABLE is never written), and verifies mismatched TCR readback or failed DISABLE_STREAMS/TCR/TTBR0/TLB-flush teardown keeps sid16_ops unfreed.
  • 0x381204000 block provenance (arch/arm64/boot/dts/apple/t8132-jxxx.dtsi): Updated the &dart_apcie0 comment to note what is observed: 0x381204000 sits 0x38000 bytes past aic's core window (0x381000000 + 0x1cc000) and below DRAM, and no DT node in t8132.dtsi claims it yet.

Explicit limits and open question:

  • Owner of 0x381204000 remains unknown: the page was identified empirically by blocking SID16 on J713 (which immediately faulted writing 0x381204000) and confirmed on J715 with 0 faults, so the open question of which SoC block owns 0x381204000 remains open for DT attribution once identified.
  • Rebind behavior after failed rollback: if apple_dart_managed_unnarrow_sid16() fails, it leaves sid16_ops unfreed so hardware cannot walk a freed table, and failures that leave TCR in translation (such as failed DISABLE_STREAMS clear or failed TCR restore) or leave a valid TTBR0 with TCR disabled cause a subsequent rebind's apple_dart_managed_admit() to return -EBUSY. If TCR, TTBR0, and ENABLE[16] were all restored (for instance, if only the final TLB flush fails), apple_dart_managed_admit() inspects only live hardware registers and accepts the restored stream (while the prior sid16_ops remains unfreed). Likewise, when TCR is restored to static bypass (0x2 or 0x6), apple_dart_managed_admit() only inspects TTBR0 in the tcr_disabled branch, so it can still accept static bypass even when TTBR0 restoration fails (with the prior sid16_ops remaining unfreed).

Verified at 4744d692f905: checkpatch.pl --strict passes (0 errors, 0 warnings, 0 checks across all 3 commits), make -j32 ARCH=arm64 LLVM=1 W=1 O=.tmp-build defconfig && make -j32 ARCH=arm64 LLVM=1 W=1 O=.tmp-build drivers/iommu/apple-dart.o builds cleanly, run-host-tests.py passes apple-dart (10/10), bcm4377-radio-sids (1/1), and pciec-policy (1/1), and scripts/dtc/apple-dart-pd-check-test.py passes (13/13). Remaining before leaving draft: re-verify J713/J715 on 4744d692f905 and run one deep-sleep (suspend-to-RAM) cycle with SID16 narrowed.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks for the rework. Both points from the earlier review are addressed at 4744d692:

  • Failed probe after narrowing: err_clk_disable now runs apple_dart_managed_unnarrow_sid16() (apple-dart.c:6291). sid16_ops is set before the first SID16 register write (:2440), so every failure from that point is rolled back, and a later probe sees the entry state again. Keeping the table and refusing admission when the teardown itself fails is the right choice, and the retained struct keeps the table reachable.
  • The t8132-jxxx.dtsi comment now says what is known about 0x381204000 and that its owner is not known. That is fine for now. If the ADT's arm-io reg lists show a block covering it, naming that block would be a good follow-up.

I went through the new admission and rollback code and found no gaps:

  • Every refused entry state (wrong DART type or geometry, an already-narrowed stream, disabled with a valid root, bypass without bypass support, any other TCR mode) is rejected before the first register write.
  • TTBR0 is read back before TCR switches to translate.
  • Teardown disables an initially disabled stream before it restores TCR, and checks every register before it frees the table.
  • The fault IRQ is requested only after the narrowing and freed before the rollback, so the handler cannot run between the two.
  • The selftest compiles the driver's own functions against the register model, so it covers the shipped code.

The J713 and J715 rows are all at 6ffeda54. The sleep save/restore path is unchanged and the base is the same as the J713 fleet82 deep-sleep run, so those rows still cover the page, sleep and Wi-Fi/BT through the narrowed stream. The probe path did change: the SID16 TLB flush, the ENABLE[16] set and check, the stricter entry-state checks, and the ENABLE[16] requirement in the cold-link idle check. One J713 boot at this head is enough to close it: the narrowing line, Wi-Fi and Bluetooth up, 0 DART faults, plus one s2idle and one deep-sleep cycle.

Assisted-by: LLM (Claude:Opus 5.5)

@erikwb

erikwb commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Note

🤖 Gemini 4 Neon responding on behalf of erikwb

Live J713 (M4 MacBook Air, T8132) hardware verification at head 4744d692f905 (7.3.0-sid16-4744+, apple/t8132-j713.dtb, /proc/device-tree/soc/iommu@490000000/apple,sid16-page = 00000003 81204000) is complete and recorded in the PR body:

  • Cold boot + s2idle (default cmdline root=UUID=... user4k=on loglevel=4 console=tty0): apple-dart 490000000.iommu: SID16 bypass narrowed to page 0x381204000; wlan0 (BCM4388/6) associated with iw dev wlan0 scan OK and 3/3 gateway pings (0% loss, 3.55–4.49 ms); hci0 (hci_bcm4377) bluetoothctl --timeout 10 scan on discovered active LE devices; rtcwake -d rtc1 -m freeze -s 10 exited 0 with post-resume 3/3 gateway pings and iw dev wlan0 scan OK; 0 failed systemd units, 0 DART translation faults, 0 TLB errors, 0 brcmf crashes, 0 new kernel errors.
  • Deep sleep (rtcwake -d rtc1 -m mem -s 15, booted with J713 display flags apple_dart.j713_dcp=1 apple_dart.j713_display=1 so internal DCP and GPU bind on current integration/aurora pending iommu: apple-dart: adopt T8132 internal display DARTs by default on 26.6.2 firmware #2189): SID16 narrowed, internal DCP (30ae00000.dcp) and aurora-g16 (/dev/dri/renderD128) bound, suspend/resume exited 0 (native radio DMA fenced, DART off, boot object resumes 0 -> 1 via PMU RTC alarm, native radio power-loss recovery complete, native radio transaction complete); post-resume gateway ping over wlan0 5/5 (0% loss, 2.72–4.35 ms), iw dev wlan0 scan OK, bluetoothctl --timeout 10 scan on active LE discoveries; j713_radio_fault_state clean (version=0x202 managed=0x6 failed=0, error_mask=0x0 error=0x0, error_streams[0]=0x0 exceptions[0]=0x0); 0 failed systemd units, 0 DART translation faults, 0 new kernel errors.

Keeping the PR in draft until both default-command-line deep sleep on J713 (after #2189 lands) and a J715 rerun at 4744d692f905 are completed; additional T8132 boards (J604, J623/J624, J773g) remain optional coverage if available.

@erikwb
erikwb marked this pull request as ready for review November 22, 2026 21:23
@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks, that's the J713 row at 4744d69 I asked for. SID16 is narrowed at boot, Wi-Fi and BT work, s2idle and deep sleep resume with Wi-Fi/BT back, the radio fault state is clean, and there are 0 DART faults and 0 new kernel errors. Approved from my side. As you say, the deep-sleep leg used the J713 display flags until #2189 lands, so a default-command-line deep sleep after that is the last check.

Assisted-by: LLM (Claude:Opus 5.5)

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

Formal §1–§6 re-review at 4744d692f905.

All §1–§6 criteria and prior review observations are cleanly satisfied, CI is 2/2 green (host-tests, dt-checks), and the branch is MERGEABLE CLEAN:

  • §1 No model gating: apple,sid16-page is DT-driven (Documentation/devicetree/bindings/iommu/apple,dart.yaml) and placed in shared arch/arm64/boot/dts/apple/t8132-jxxx.dtsi next to apple,managed-sids, covering all six T8132 boards uniformly with zero chip/board gates in drivers/iommu/apple-dart.c and preserving existing bypass behavior when the property is absent.
  • §2 Production-ready: Works on the default kernel command line with no new cmdline/module parameters; t8132-jxxx.dtsi documents what is currently known about 0x381204000.
  • §3 Safety: apple_dart_managed_narrow_sid16() validates DART type/geometry (DART_T8110, num_streams > 16, ttbr_count == 1, SZ_16K, oas >= 36, sid16_page < BIT_ULL(oas)) and rejects unrestorable entry states before allocating the table or touching registers, verifies TTBR0 readback before writing TCR = TRANSLATE_ENABLE, flushes SID16's TLB, and verifies ENABLE[16] in narrowing, admission, and the cold-link idle check. On any post-narrowing probe failure (after apple_dart_free_irq()), apple_dart_managed_unnarrow_sid16() disables ENABLE[16] before restoring TCR when initially disabled, restores tcr_bypass/tcr_disabled and TTBR0 with exact readback and TLB flush checks, and keeps sid16_ops unfreed on any teardown failure.
  • §4 Attribution: All 3 commits (971399886047, f8accf4e6b8a, 4744d692f905) carry human author/committer (Erik Bourget) and human Signed-off-by: only, with zero agent trailers; PR body ends with Assisted-by:.
  • §5 Evidence: Live J713 hardware verification at current head 4744d692f905 on integration/aurora (f5fae3cbb047): default-cmdline cold boot + Wi-Fi + BT + s2idle PASS (0 failed units, 0 DART faults, 0 new kernel errors) and deep sleep (rtcwake -m mem -s 15) PASS with clean j713_radio_fault_state, Wi-Fi/BT recovery, and 0 DART faults — complemented by Ryan's J713 fleet81 (SELinux Enforcing, 0 AVC) / fleet82 (3× default-cmdline deep sleep + 12× s2idle + WoWLAN) and kazuhidet's J715 (Mac16,13) row confirming 0x381204000 on a second T8132 board, plus expanded bcm4377-radio-sids.py, checkpatch --strict (0/0/0), and W=1 LLVM arm64 compile.

Ready for MERGETRAIN-LINUX4. Non-blocking follow-ups: default-cmdline J713 deep-sleep recheck once #2189 lands, J715 rerun on 4744d692f905, and DT block attribution for 0x381204000 once identified.

Assisted-by: LLM (Gemini 4 Neon)

@RyanTheTide
RyanTheTide merged commit 180f1e3 into aurora-silicon:integration/aurora Nov 23, 2026
2 checks passed
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.

4 participants