Repository navigation
accel/ane: run the M2 (T8112) 27.2 preload on the shared H16 backend - #3916
Conversation
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>
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
satchlj
left a comment
There was a problem hiding this comment.
Verdict: FINISH, then merge
Blockers:
- Merge conflicts with
main:arch/arm64/boot/dts/apple/t8112-j473-fw27.dtswas folded intot8112-j473.dtsonmain(71df6ab72961, #3912); mergemainand move the#include "t8112-ane-fw27.dtsi"intot8112-j473.dts. - CI at head (
b56c77331d8f) still hasapple-build,dt-checks,host-tests, andKUnit planqueued.
Checked:
- Code audit of
b56c77331d8fis clean — ready to flip toAPPROVEoncemainis 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*: statict8112.dtsicleanly carriesapple,ane-type(0x80) and 4 DAPF records without triggering the preload-handoffif/thenrequirement, while any preload property requires the complete hand-off set;dma-coherentis 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,pwgatePRE_ON/OFFnotifier kept active throughane_h16_release()pm_runtime_put_sync(),dart_reattachafter coldpower_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 onarch/arm64/boot/dts/apple/t8112-j473-fw27.dtsvsmain71df6ab72961). - CI at head:
pr-textpassed;apple-build,dt-checks,host-tests, andKUnit planqueued. - 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.
|
Exact-head J413 (
|
…-backend # Conflicts: # arch/arm64/boot/dts/apple/t8112-j473-fw27.dts
satchlj
left a comment
There was a problem hiding this comment.
Verdict: FINISH, then merge
Blockers:
- CI at
cd23c9931d2fis not complete yet:pr-textpassed, whiledt-checksandhost-testsare stillIN_PROGRESSandapple-build/KUnit planare stillQUEUED(with no local CI receipt posted yet). Ready to flip toAPPROVEas soon as CI (hosted or local) finishes green.
Checked:
- Forward merge
cd23c9931d2f(origin/main105e3fbc6adcintob56c77331d8f) resolved the#3912t8112-j473-fw27.dtsconflict cleanly:t8112-j473-fw27.dtsnow includest8112-j473.dts, andt8112-j473.dtsincludest8112-ane-fw27.dtsi(MERGEABLE, zero conflicts). - Verified diff parity between
b56c77331d8fandcd23c9931d2f: zero changes to anydrivers/accel/ane/*file,Documentation/devicetree/bindings/npu/apple,ane.yaml, ort8112-j413-fw27.dts. - Hardware rows PASS on both J473 and J413 (including full-kernel J413 trial at
b56c77331d8fwith identical ANE driver, binding, and J413 DT code).
Evidence
- Compared
b56c77331d8f...cd23c9931d2fvia GitHub compare API; onlyt8112-j473-fw27.dts,t8112-j473.dts, andt8112-peripherals.dtsichanged among ANE/T8112 paths (all from the#3912main merge). - Checked
statusCheckRollupatcd23c9931d2f:pr-textSUCCESS;dt-checks,host-testsIN_PROGRESS;apple-build,KUnit plan,readinessQUEUED.
DjDeveloperr
left a comment
There was a problem hiding this comment.
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 withW=1. The diagnostic comparison found no new warnings. The hosted DT check passed. python3 -I tools/asahi/run-host-tests.py --jobs 8passed 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.
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_platformis 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.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.apple,ane-type+ the four DAPF records on the T8112 ANE node;dma-coherentonly on the 27.2 (-fw27) boards viat8112-ane-fw27.dtsi. AUTO_ENABLE stays on (macOS 27.2 sets it on ANE_SYS and ANE_CPU).Tested: J473 (M2 mini, T8112, macOS 27.2 stub) at
66174575(= this PRcd23c993+ #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 atcd23c993(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; KUnitboot.kunitconfig331/331 ate185c8f4.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)
J473 rows (2026-12-02, each restored to the saved fleet94 boot, Enforcing, 0 failed units)
NO TTBR FOR IOVAon DART1 (fixed: DART re-attach after power-up).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.