Skip to content

accel/ane: run the M2 (T8112) 27.2 preload on the shared H16 backend - #3916

Merged
DjDeveloperr merged 5 commits into
mainfrom
ane/t8112-272-preload-backend
Dec 2, 2026
Merged

DjDeveloperr merged 5 commits into
mainfrom
ane/t8112-272-preload-backend

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

What

Run the M2 (T8112, H14) Neural Engine on a macOS 27.2 stub. iBoot preloads the native 27.2 H14 firmware (TEXT 0xd8000 at 0x800000000, DATA 0x614000 after it); boot it on the shared AP-direct H16 backend the M3 (T8122) uses, the way macOS 27.2 drives it, instead of the legacy H14 disk loader that cannot start 27.2 firmware.

  • ane_t8112_platform is selected only when the boot loader hands the preload over (aura#651: firmware-text/firmware-data regions, apple,firmware-iovas, apple,firmware-preloaded, /chosen/apple,ane-cold-boot). Without the hand-off (13.5 stubs) the T8112 takes the legacy path unchanged.
  • Backend additions are opt-in platform fields (H15/H16/H17 unchanged): seven power domains under ANE_SYS, the set+0x8b8 power gate driven only at full power-up/down, the mailbox-owned interrupt, re-attaching the ANE DART domain after every power-up, the H14 init-block words.
  • Preload pin "H14 T8112 27.2 26B123 J473": patchbay cells + normalized digest, measured identical on two J473 cold boots.
  • DT: apple,ane-type + the four DAPF records on the T8112 ANE node; dma-coherent only on the 27.2 (-fw27) boards via t8112-ane-fw27.dtsi. AUTO_ENABLE stays on (macOS 27.2 sets it on ANE_SYS and ANE_CPU).
  • Supersedes accel/ane: load H14 firmware from iBoot reservations #2973 (H14 27.2 on the legacy rtclient path, which kept crashing the firmware's execution loop).

Tested: J473 (M2 mini, T8112, macOS 27.2 stub) at 66174575 (= this PR cd23c993 + #3917 with its EXECUTE declared-size fix): pass — add/mul/relu 200x exact, MobileNetV1 224 200/200 bit-exact vs the J413 13.5 reference (50176/50176, 0 ulp), idle re-wake, 2x 15 s s2idle with MobileNet replayed, 0 DART faults.
Tested: J413 (M2 Air, T8112, macOS 27.2 stub) at 533f2e30: pass — same rows as below incl. 2x s2idle with replay, preload matched the same pin, output digest identical to the J473's.
Tested: J473 (M2 mini, T8112, macOS 27.2 stub) at 533f2e30 (= this PR at cd23c993 (b56c773 + a merge of main; #3912 made t8112-j473.dts the 27.2 tree, so the ANE fw27 include moved there) + the stacked #3917, ANE/T8112/binding code identical; modules built for the saved 7.3.0-aurora-fleet94, aura b18 + aura#651 Stage 2 one-shot): pass — /dev/accel/accel0 H14 ABI 3, add/mul/relu 200 runs each exact, idle park + re-wake, 2x 15 s s2idle with the program replayed (identical output), 0 DART faults; KUnit boot.kunitconfig 331/331 at e185c8f4.
Risk: two-way door (plain revert). Only T8112 boards whose boot loader hands over a preload (macOS 27.2 stubs with aura#651); 13.5-stub M2s and every other SoC keep their current path.

Not yet

How it was found (macOS 27.2 traced under our hypervisor)

An MMIO trace of macOS 27.2 driving the J473 ANE (our HV, Core ML MobileNetV1 3x200 at p50 461 us) showed: macOS powers the whole ANE off ~5.9 s after the last request and cold-starts the firmware on every power-up; the power gate is only touched at full power-up/down (never per request — #2973 gated around requests and crashed the firmware's execution loop); AUTO_ENABLE is set on ANE_SYS and ANE_CPU; per EXECUTE only doorbell + IRQ status/ack; the start handshake (READY, channel/IPC request, heap request, host ACK of READY in SCRATCH3) is the H16 backend's. Raw traces stay private.

J413 row (2026-12-02 21:42, restored to the saved fleet94 boot)
  • Trial Stage 2 = the installer's 72-DTB image with only the two J413 DTBs given the three ANE properties and aura b18 + aura#651; TEXT sha identical to the J473's, DATA normalized digest = the J473 pin (identity accepted).
  • add/mul/relu 200 runs each exact; idle park + re-wake; 2x 15 s RTC s2idle with add loaded: resume ok + 1 program replayed each, output identical before/after (sha 5574906c…, same as the J473).
J473 rows (2026-12-02, each restored to the saved fleet94 boot, Enforcing, 0 failed units)
  • Row 1 (20:02): preload accepted, power/DART/DAPF ok, refused before RUN — the T8112 ANE node lacked dma-coherent (fixed: fw27 boards only).
  • Row 2 (20:30): firmware READY + channel table, then handshake timeout — host ACK of READY in SCRATCH3 missing (fixed, matches the macOS trace).
  • Row 3 (20:41): add/mul/relu 200 each exact; runtime re-wake after the idle park hit NO TTBR FOR IOVA on DART1 (fixed: DART re-attach after power-up).
  • Row 4 (21:04, 533f2e30): add/mul/relu 200 each exact (host p50 102-111 us); idle park + re-wake cold boot from the preload in 14 ms, add exact; 2x 15 s RTC s2idle with add loaded: "resume ok", "1 programs replayed, 0 restarts" each, ANE domains off 16.8 s, output byte-identical before/after both sleeps and equal to the CPU oracle (16384/16384); 0 DART faults.

On a T8112 with a macOS 27.2 stub, iBoot preloads the native H14
firmware. The boot loader may hand it over: it then adds the TEXT and
DATA reservations, memory-region-names, apple,firmware-iovas and
apple,firmware-preloaded to the ANE node, and the driver starts that
firmware cold instead of staging the disk image. Without the hand-off
the node stays as it was.

Allow those properties on apple,t8112-ane, all of them together, with
apple,ane-type (0x80) and four apple,dapf-ranges records, and the T8112
27.2 device addresses (TEXT 0x800000000, DATA 0x8000d8000). Other
legacy-engine compatibles keep refusing them. Document dma-coherent,
which the shared backend needs for its private firmware surfaces.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
Add the J473 27.2 ADT's ane-type (0x80) and dart-ane dapf-instance-0
records (inclusive CPU addresses, in record order) to the T8112 ANE
node. The shared backend needs them when the boot loader hands the
preloaded firmware over; the legacy disk loader does not read them.

The shared backend also maps its private firmware surfaces cacheable and
requires a coherent client. Mark the ANE dma-coherent in a
t8112-ane-fw27.dtsi that only the 27.2 board variants (j413/j415/j473/
j493 -fw27) include, so 13.5 stub boards keep the legacy path's
description.

The ANE power domains keep their automatic power management: macOS 27.2
on the J473 sets AUTO_ENABLE on ane_sys and ane_cpu when it powers the
engine up, unlike the T8122 case that needed apple,no-auto-pm.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
On an M2 with a macOS 27.2 stub, iBoot preloads the native H14 firmware
(TEXT 0xd8000 at 0x800000000, DATA 0x614000 after it). Boot it on the
AP-direct H16 backend the T8122 uses, instead of the legacy H14 path.

ane_t8112_soc gains a handoff_platform, ane_t8112_platform. It is used
only when the DT carries the boot loader's hand-off: both
firmware-text/firmware-data regions, apple,firmware-iovas,
apple,firmware-preloaded and the /chosen/apple,ane-cold-boot evidence
(ane_fw_preload_handoff()). Probe, remove, sleep, sysfs and module init
decide from the DT alone. Without the hand-off the T8112 takes the legacy
path unchanged.

The backend takes the T8112 differences as data:
- domain_count: seven ANE domains (power-domains[0] is the CPU domain).
  sys_parent: the isolated ANE_SYS power cycle is on its parent, and the
  restart checks domain 0 for an OFF too.
- pwgate_window/pwgate_offset: the "set" + 0x8b8 power gate, opened
  before the CPU domain turns on and closed after it turns off, the same
  two values the legacy path writes, from the genpd notifier of
  power-domains[0], registered before its first power-on.
- dart_reattach: the ANE DARTs lose SID0's TTBR/TCR with the engine
  domains, after their own runtime resume has run, so the backend
  attaches its domain again after every power-up (idle wake, sleep
  resume, restart), as the H17 cold path does. Without it the first
  request after an idle power cycle faulted NO TTBR in DART1.
- ANE_FW_IRQ_MAILBOX: the line is the ASC mailbox's, which its node's
  driver owns. The backend polls and does not request it.

The build (ane_h14_build_t8112_26b123) uses the H16 init block with the
words the legacy H14 init and the first 27.2 H14 boot (linux#2973) used:
TEXT DVA at +0x00, a config span of TEXT + DATA, a 16 KiB heap floor and
the nap-prevention bit. It adds the 12 legacy engine writes before RUN,
a 2 MiB writable tail after DATA (tail_end), and FREE replies of DVA|1
(dva_free). The boot ACK is the H16 one: the host writes READY to SCRATCH3
after the table is published and the firmware clears it, the order macOS
27.2 uses on the J473. Pool, IPC and heap follow the tail at the H16
spacing.
SHAREDMALLOC and programs start at 0x802000000.

The profile pins the J473 preload as the T8122 one is pinned: the TEXT
and DATA sizes, the five DATA patchbay cells (GKTS, ECAP and ARcM
rewritten by the boot loader), and the normalized SHA-256. Two J473 boots
had identical TEXT and DATA that differed only in GKTS and ECAP, and the
same digest.

The T8112 ANE DARTs are revision 1.1 (PARAMS3 0x24240101 on a J473), with
the T8122 register and DAPF record layout.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
ane_t8112_platform_test: windows, seven domains under ANE_SYS, the DART
re-attach after power-up, the power gate, four DAPF records, the
mailbox-owned interrupt, the J473 preload profile, and that a node
without a hand-off keeps the legacy path.

On the simulated engine:
- ane_h16_t8112_boot_test: the 12 engine writes before the first scratch
  write, the H14 init block words, pool/IPC/heap DVAs for the J473
  requests,
  READY written to SCRATCH3 only after the table is published (the macOS
  27.2 order), DVA|1 FREE, and four DAPF records.
- ane_h16_t8112_no_heap_test: no heap surface and no heap floor without a
  request.
- ane_h16_t8112_ack_timeout_test: a firmware that never clears the READY
  in SCRATCH3 times out with no startup command sent.
- ane_h16_t8112_heap_floor_test: a heap request below 16 KiB gets the
  floor.
- ane_h16_t8112_revision_test: a DART revision outside the table is
  refused before any tunable, DAPF or RUN write.
- ane_h16_t8112_preload_rule_test: the J473 cells frame a preload of the
  J473 shape, GKTS and ECAP normalize, and a fixed cell or a moved tag
  changes or refuses the digest.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide
RyanTheTide requested review from a team as code owners December 2, 2026 10:23
@github-actions github-actions Bot added area:media Area from CODEOWNERS (bot) area:platform Area from CODEOWNERS (bot) blast:m2 Macs affected, from Merge risk (bot) ci-failing A check failed at the PR head (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Dec 2, 2026
@github-actions

github-actions Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Merge readiness at cd23c993: not ready yet

Check Detail
CI at head no failing: pr-text / pr-text
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head ok in the PR body at cd23c993
Conflicts ok none
PR text ok Risk: two-way · (plain revert). Only T8112 boards whose boot loader hands over a preload (macOS 27.2 stubs with aura#651); 13.5-stub M2s and every other SoC keep their current path.

Areas: area:media, 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 added merge-conflict Conflicts with the base branch (bot) and removed ci-failing A check failed at the PR head (bot) labels Dec 2, 2026

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

Verdict: FINISH, then merge

Blockers:

  • Merge conflicts with main: arch/arm64/boot/dts/apple/t8112-j473-fw27.dts was folded into t8112-j473.dts on main (71df6ab72961, #3912); merge main and move the #include "t8112-ane-fw27.dtsi" into t8112-j473.dts.
  • CI at head (b56c77331d8f) still has apple-build, dt-checks, host-tests, and KUnit plan queued.

Checked:

  • Code audit of b56c77331d8f is clean — ready to flip to APPROVE once main is merged cleanly, CI completes green, and the head hardware row is updated.
  • Documentation/devicetree/bindings/npu/apple,ane.yaml & arch/arm64/boot/dts/apple/t8112*.dts*: static t8112.dtsi cleanly carries apple,ane-type (0x80) and 4 DAPF records without triggering the preload-handoff if/then requirement, while any preload property requires the complete hand-off set; dma-coherent is scoped to the 27.2 trees.
  • drivers/accel/ane/ane_fw_platform.c & ane_t6021_rtclient_main.c: ane_fw_preload_handoff() is DT-only (so init, probe, sleep, remove, and sysfs agree) and leak-free (__free(device_node)); 13.5-stub T8112 machines without the preload hand-off keep the legacy path unchanged.
  • drivers/accel/ane/ane_h16_backend.c & ane_h16_boot*.h: all T8112 additions (domain_count = 7, sys_parent, pwgate PRE_ON/OFF notifier kept active through ane_h16_release() pm_runtime_put_sync(), dart_reattach after cold power_up, ANE_FW_IRQ_MAILBOX, tail_end, heap_floor, init_text_dva, dva_free) are opt-in platform fields leaving H15/H16/H17 untouched.
  • ane_fw_platform_test.c & ane_h16_boot_test.c: solid KUnit coverage for T8112 platform metadata, init-block layout, heap floor, SCRATCH3 ACK timeout, DART revision check, and J473 preload digest normalization.
Evidence
  • Head audited: b56c77331d8f (mergeable=false, conflicts on arch/arm64/boot/dts/apple/t8112-j473-fw27.dts vs main 71df6ab72961).
  • CI at head: pr-text passed; apple-build, dt-checks, host-tests, and KUnit plan queued.
  • Hardware evidence in PR body: J413 and J473 (27.2 stub) PASS at 533f2e30 (identical ANE/T8112/binding code) with 200x elementwise runs, idle park/re-wake, and 2x 15 s s2idle with program replay and 0 DART faults.

@satchlj

satchlj commented Dec 2, 2026

Copy link
Copy Markdown
Member

Exact-head J413 (T8112, macOS 27.2 26B123 stub) full-kernel hardware row at b56c77331d8f5f68f8e5192fde9a25483f3c1c0a paired with aurora-silicon/aura#651 (38fbe9e0d609, aura 1.0.0b18-g38fbe9e0) Stage 2 and this PR's compiled t8112-j413-fw27.dtb (default kernel command line, boot_id=3d5a9b5e-3c5b-437a-8947-10e57572cb7c): PASS.

  • DT hand-off: /chosen/apple,ane-cold-boot = raw-no-xnu-ane-untouched-v1; /soc/ane@26a000000 carries dma-coherent, apple,ane-type = <0x80>, apple,firmware-preloaded, memory-region-names (firmware-text, firmware-data), and apple,firmware-iovas (0x800000000, 0x8000d8000); reserved regions ane-firmware-text@80093c000 (0xd8000) and ane-firmware-data@801610000 (0x614000, no-map, non-reusable).
  • Preload & bring-up: H16 preload identity H14 T8112 27.2 26B123 J473 accepted; ANE DARTs 0/1/2 PARAMS3 = 0x24240101; 4/4 DAPF records written and read back; 12 engine tunables applied; READY 8042006; 8 channels / IPC 0xc440 / heap 0xf00000; scratch 3 cleared; 5 startup SHAREDMALLOC allocations (LOG/CCMD/RPC/MISC/DPTD); [drm] Initialized ane 3.2.0 for 26a000000.ane on minor 0 (H14 accel node ready (ABI 3, one loaded program at a time)).
  • Node, ioctls & idle park: /dev/accel/accel0 DRM_IOCTL_VERSION 3.2.0 (ane), DRM_IOCTL_ANE_GET_CAPS (abi_version=3, chip_family=14, section_size=16, exec_io_size=16), wedged=0, ane_stats (busy_ns 0, jobs 0); engine powered down and parked cleanly (H16 ANE: powered down, runtime_status=suspended).
  • Sleep & regressions: 2x 15 s RTC s2idle clean; Borealis GPU render pass pre-sleep and after both wakeups; 0 DART faults; 3/3 Apple MTP HID inputs active; 0 failed systemd units.

…-backend

# Conflicts:
#	arch/arm64/boot/dts/apple/t8112-j473-fw27.dts
@github-actions github-actions Bot added ci-failing A check failed at the PR head (bot) and removed merge-conflict Conflicts with the base branch (bot) labels Dec 2, 2026

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

Verdict: FINISH, then merge

Blockers:

  • CI at cd23c9931d2f is not complete yet: pr-text passed, while dt-checks and host-tests are still IN_PROGRESS and apple-build / KUnit plan are still QUEUED (with no local CI receipt posted yet). Ready to flip to APPROVE as soon as CI (hosted or local) finishes green.

Checked:

  • Forward merge cd23c9931d2f (origin/main 105e3fbc6adc into b56c77331d8f) resolved the #3912 t8112-j473-fw27.dts conflict cleanly: t8112-j473-fw27.dts now includes t8112-j473.dts, and t8112-j473.dts includes t8112-ane-fw27.dtsi (MERGEABLE, zero conflicts).
  • Verified diff parity between b56c77331d8f and cd23c9931d2f: zero changes to any drivers/accel/ane/* file, Documentation/devicetree/bindings/npu/apple,ane.yaml, or t8112-j413-fw27.dts.
  • Hardware rows PASS on both J473 and J413 (including full-kernel J413 trial at b56c77331d8f with identical ANE driver, binding, and J413 DT code).
Evidence
  • Compared b56c77331d8f...cd23c9931d2f via GitHub compare API; only t8112-j473-fw27.dts, t8112-j473.dts, and t8112-peripherals.dtsi changed among ANE/T8112 paths (all from the #3912 main merge).
  • Checked statusCheckRollup at cd23c9931d2f: pr-text SUCCESS; dt-checks, host-tests IN_PROGRESS; apple-build, KUnit plan, readiness QUEUED.

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

The ANE driver and binding patches are byte-identical to b56c77331d8f. The forward merge moves the firmware-27 ANE include from the J473 wrapper into its new 27.2 base DTS; those two compiled J473 DTBs match byte for byte. The J413 ANE, power and DART sources are unchanged, so the J413 preload, idle and suspend result carries over.

On main 105e3fbc6adc8 and the merge result at cd23c9931d2f:

  • Warm Arm64 modules_prepare, drivers/accel/ane/ and the J413/J473 DTBs built with W=1. The diagnostic comparison found no new warnings. The hosted DT check passed.
  • python3 -I tools/asahi/run-host-tests.py --jobs 8 passed 952/952 on both.
  • Native UML KUnit with the ANE boot and PM configs passed 302 cases on main and 308 at this head. Both runs skipped the same 35 HWX/accel cases because their user-copy fixtures panic on unchanged main under UML. The affected ANE boot and PM coverage passed with KASAN and UBSAN enabled.

The T8112 path selects the new backend only on a preload hand-off. The existing backend defaults and legacy T8112 selection are preserved. Approved at this head.

@DjDeveloperr
DjDeveloperr merged commit 9177b2d into main Dec 2, 2026
14 of 18 checks passed
@DjDeveloperr
DjDeveloperr deleted the ane/t8112-272-preload-backend branch December 2, 2026 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:media Area from CODEOWNERS (bot) area:platform Area from CODEOWNERS (bot) blast:m2 Macs affected, from Merge risk (bot) ci-failing A check failed at the PR head (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants