Skip to content

accel/ane: load H14 firmware from iBoot reservations - #2973

Closed
RyanTheTide wants to merge 15 commits into
mainfrom
ane/h14-iboot-preload
Closed

RyanTheTide wants to merge 15 commits into
mainfrom
ane/h14-iboot-preload

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Problem

On an M2 mini (T8112) with a macOS 27.2 stub, the disk image from 13.5 releases the ANE CPU but the engine never reaches READY. iBoot already preloads the native 27.2 H14 firmware. That firmware uses the 27.x channel contract shared with H16/H17 (a channel table published by the firmware, a 0xc441-byte IPC surface, SHAREDMALLOC requests), not the static 13.5 layout.

Change

  • Read the boot loader's optional TEXT and DATA reservations (kboot: describe the optional H14 ANE preload aura#482) and boot the native image from them. The disk loader stays for the original layout. The native layout (sizes, physical and device addresses) is taken whole from the handoff; nothing pins one firmware build's sizes.
  • Choose the channel contract per device from what the booted firmware asks for. If its IPC request cannot hold the 13.5 layout, parse the table it published with ane_fw_channels_parse(). Otherwise keep the 13.5 path unchanged. There is no chip, board or firmware-version check.
  • For a firmware-published table, run the startup on the shared 27.x transport used by the H16/H17 cold boots (ACK, startup commands 0x4/0x0/0x3/0x22, SHAREDMALLOC/FREE, TERMINAL drain).
  • Then run programs through the same shared program session the H16/H17 backend uses (LOAD/CREATE/EXECUTE), behind the ABI 3 node, instead of the ABI 2 node. The HWX validator accepts the H14 container, keyed on the object's own subtype. A refused LOAD or CREATE now logs the firmware's reply and log records. 13.5 firmware keeps ABI 2 unchanged.
  • H14 BAR slots come from the program descriptor's slot table, as on H16 (slot s at +0x10 * (s + 1)): text_const in slot 1, scratch in slot 3, then the first input, the output and the other inputs. The validator pins every qword of that table. A slot naming __TEXT/__const binds the kernel resource 1007 when the program has no __KERN_0 (LOAD slot 1 already carries those constants). Before this, the validator refused slot 1, so any convolution program (its kernel-DMA records name slot 1 and slot 3) would have been refused.
  • A preload gets the same owned, zeroed runtime RAM after DATA that the disk loader gives the firmware after its image (fw_extra_ram). The 27.2 H14 firmware keeps per-process state there, at its sharedMemoryBase (TEXT + DATA).
  • The t6021 session holds power gating off for 2 ms after the last EXECUTE, like H16/H17 and macOS (one shared ANE_H16_GATE_HOLD_NS), instead of toggling 0x2d around every request.
  • System sleep cold-restarts 27.x firmware instead of parking it until reboot, the way the shared H16/H17 cold sleep path does. On suspend, the session drains and the ASC is proven STOPPED. On resume, the deferred work boots from the kernel's pristine copy of the preload DATA: fresh 27.x transport, ACK, startup, then every open program replayed behind its handle. That cold boot also ends a session quarantine, as on H16.

Testing

J473, fleet85 kernel, default command line, guarded aura-try one-shots, production restored and verified byte-identical after each row:

  • 13dea16 alone: firmware alive (booted=1 fw_alive=1), then refused by the 13.5 table check (IPC 0xc441 < 0x10440).
  • c5b76da: the firmware's table was validated (8 channels) and the boot ACK taken. The firmware then asked for a 64 KiB LOG allocation, which this commit refuses.
  • e0cc355: firmware fully up. It made 5 allocations (393,216 bytes), every startup command returned 0, and /dev/accel/accel0 registered. No ANE DART fault, 0 AVC.

J413 (13.5 firmware, ABI 2), e0cc355 module against stock fleet85 in the same session: depthwise and MobileNetV1 200/200 each with identical output digests, 0 DART faults, 0 Oops.

J473 at d599f9d + the kit fixes (stage 4 kit, 15:40 and 16:51, guarded aura-try one-shots with the aura#482 Stage 2, production restored byte-identical both times):

  • First 27.2 H14 program execution on Linux: add (our compiler's HWX) loaded and created, and run 0 was 512/512 exact, max 0 ulp (host p50 227 µs over 4 runs).
  • Row 1: CREATE faulted 7 times in the ANE DART at 0x8006fc040..0x8006ffec0, just past DATA (ends 0x8006ec000). The 5th EXECUTE then found an all-zero command and the firmware asserted. Fixed by 787407e (preload tail): row 2 had 0 DART faults.
  • Row 2: the firmware took an exception on the gate close right after the 3rd request's completion report. ef1c930 (gate hold) addresses this; not yet run on hardware.

Host at 9123cf6: KUnit (arm64 QEMU, all ANE suites) 315 run, 314 pass, 1 skip (needs CONFIG_UCLAMP_TASK); the H14 add case now checks the descriptor slot table and refuses an empty output slot. W=1 module build against fleet85: 0 warnings. checkpatch --strict is clean on every new commit. A second H14 fixture (a 2-layer linked convolution from mil-hwx-compiler#47) loads through the slot table: coefficients on slot 1 bound to resource 1007, scratch on slot 3.

J413 (13.5 firmware, ABI 2) at fbd0818 on fleet86: depthwise and MobileNetV1 200/200 each, output digests identical to stock, 0 DART faults.

macOS reference on the same J473 (27.2 26B123), Core ML MobileNetV1 synchronous predict, 50 warmups + 200 runs, three runs: p50 390-399 µs, p90 402-413 µs, output = float64 CPU reference (relative L2 0.001522, top 5 match).

Still to run

  • J473 at this head (kit staged, waiting for a J473 slot; the gate-hold commit is the open hardware question): add/mul/relu through LOAD/CREATE/EXECUTE on the 27.2 firmware, exact against CPU oracles. MobileNetV1 224 from H14: emit formula-built convolutions as HWX mil-hwx-compiler#47 (28-task linked ring), bit-exact against the J413 run of the same program (13.5 firmware; same task stream and constants as ANEC), plus timing against the macOS row. Then the same handle across 2 x 15 s RTC s2idle: same output after each wake.
Validation detail

Native preload: a handoff whose sizes match the disk-loaded image uses the existing disk loader, as does a tree without the handoff. Any other layout is taken from the handoff: both sizes non-zero and 16K aligned, TEXT 16K aligned with DATA directly after it in device address space, no physical overlap, entry valid for RVBAR, and raw boot ownership (/chosen/apple,ane-cold-boot). The J473 27.2 ADT hands over 0xd8000 bytes of TEXT and 0x614000 bytes of DATA.

Channel table published by the J473 firmware (IPC +0x0): TERMINAL 512 slots at +0x800, IO 16 at +0x8800, DEBUG 8 at +0x8c00, BUF_H2T 64 at +0x8e00, BUF_T2H 64 at +0x9e00, SHAREDMALLOC 8 at +0xae00, IO_T2H 64 at +0xb000, DATA_CHAIN_H2T 16 at +0xc000. The startup allocations requested were 64 KiB, 16 KiB, 96 KiB, 48 KiB and 160 KiB.

H14 HWX (from mil-hwx-compiler --target H14 --format hwx): 0x890-byte program descriptor carrying the H16-style BAR slot table, 8-word task header, zero stream prologue, H14 register map, no __KERN_0. Slots come from the descriptor's slot table (mil-hwx-compiler#47 writes it as the decoded programs carry it). H14 programs send no custom BAR record. Program memory is coherent DMA memory outside the firmware's alias range; the command pool is 256 KiB as on H16/H17.

The new KUnit cases cover: a 27.x table accepted at a 0xc441-byte IPC surface; the 13.5 layout kept at 0x10440 bytes or more; malformed tables rejected; a replay of the J473 LOG allocation request; H14 HWX acceptance and refusals; the shared session's H14 load and execute against the fake firmware.

Allow the loader to supply ordered TEXT and DATA reservations and their
device addresses for the H14 ANE. Require the complete handoff whenever
any preload property is present. Keep the disk-loaded devicetree valid.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
An H14 boot can provide a native preload whose layout differs from the
disk image. Select the boot ABI using the loader layout and verify cold
ownership and the live RVBAR before releasing the CPU. Keep the disk
path for the original layout.

Map the reserved TEXT read-only and put personalized DATA in a coherent
working copy at the reported device address. Keep the pristine DATA
for cold restart. Unmap the owned pages before freeing their backing.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>

@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 13dea16. The native path checks the iBoot reservation layout and live RVBAR before use. TEXT is read-only and fixed IOVAs sit outside the DMA allocator range. DATA uses a separate coherent allocation and keeps a pristine copy for cold restart. The unwind tracks how much of each range became mapped.

Please document the fixed native layout sizes as the supported firmware ABI, including the behavior for a different but well-formed layout. Keep the paired aura deployment and J473 no-extra-options boot, restart and short resume results as prerequisites. The J413 control should show that a missing optional handoff uses the ordinary disk loader, with the same output and no new DART faults.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Matched MobileNetV1 preparation passed on the build host. The serialized Core ML package preserved all 56 fp16 weight and bias tensors, all 28 convolution group, stride and padding settings, and the 150,528 input values in the Linux CPU-reference row.

The Linux runner now measures EXECUTE plus output readback over 200 calls after 50 warmups on that input. The host fixture exercised all 250 calls and readbacks, accepted the saved CPU result, and rejected an all-zero output. The Core ML harness uses the same counts and checks the compute plan for all 28 convolutions before timing.

The Linux and native macOS timing rows still need J473. The previous Core ML sample used different weights.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

J413 stock fleet85 passed the matched-input MobileNetV1 control on the default Linux boot. The archived fp16 input, program, and CPU reference match the J473 trial kit.

After 50 warmups, 200/200 EXECUTE plus readback calls completed at 1403.4 µs p50 and 1529.0 µs p90. The 50,176-value output had relative L2 error 0.001522 and all five pooled classes matched the CPU reference.

Verified the same running and saved fleet85 boot afterward, with an empty next entry, SELinux Enforcing and zero failed units. The candidate J413 and J473 rows remain pending.

…table

The iBoot-preloaded macOS 27.2 H14 firmware boots with the existing H14
sequence, but it asks for a smaller IPC surface than the 13.5 static
channel layout needs and returns the DVA of its own descriptor table at
DONE, as the H16 and H17 27.x firmware does. The driver then refused the
table and the probe failed.

Decide the channel contract per device from the booted firmware: when
its IPC request cannot hold the 13.5 layout, parse the table it
published inside the IPC surface with ane_fw_channels_parse() and keep
the snapshot check. A request that holds the 13.5 layout keeps the
static layout and the 13.5 commands unchanged. SoCs of the shared
firmware platform keep the 27.x contract.

Route the protocol choices of the rtclient through that property: the
command header, the reply check, the ring and allocation handling, and
the program command refusals. The doorbell, power gating and sleep
dispatch stay with the SoC description.

For the published table, give the host slots back before the ACK, wait
for the firmware to take the ACK, and send the 27.x startup exchange on
the IO ring in place of the 13.5 CONFIG_GET, logging every reply once.
The 13.5 program commands, the performance property and the firmware
restart stay refused for it, and system sleep parks the engine until
reboot.

Fix the 27.x exchange returning success when its deadline passed after
the command header was prepared.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
On the M2 mini the native 27.2 H14 firmware posts a 64 KiB SHAREDMALLOC
request for its log right after the boot ACK, while the first startup
command waits. The rtclient had no 27.x allocation provider, refused it,
and the startup failed.

When the firmware published its own channel table, attach the shared
27.x transport that the H16 and H17 cold boots use: it parses the table
again, arms the host slots before the ACK, publishes the startup
commands from a private command pool, and while it waits answers
SHAREDMALLOC and FREE requests with the same size bounds, reply form and
reuse rules, and drains the TERMINAL ring. Allocations come from the
rtclient's firmware allocation table. The transport rings the mailbox
registers the 13.5 rings already use.

Log each allocation, refusal and startup reply once per boot. Program
load stays refused on this firmware with a message: the 27.x LOAD takes
the original HWX through ABI 3, and its HWX validation accepts no H14
program.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
The native-layout check pinned the H14 TEXT/DATA sizes to the values
one macOS 27.2 ADT reported ({0xd8000, 0x614000}). Another firmware
build with a different layout would be refused for no reason, and the
pin repeats what the loader already hands over.

A handoff whose sizes match the disk-loaded image is still the legacy
layout. Any other layout is the loader's own and is taken whole from
the handoff: the sizes must be non-zero and 16K aligned, TEXT must be
16K aligned and DATA must follow it in device address space, the
physical ranges must not overlap, and the entry must fit RVBAR. The
cold-ownership check (apple,ane-cold-boot) is unchanged.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
The 27.x firmware takes the original HWX object and the host-built LOAD
sections, as on H16 and H17. The M2 engines run H14 programs, whose HWX
the validator refused by its CPU subtype (5).

H14 objects share the container form and differ in what the object
itself says it is (its Mach-O subtype):

- a 0x890-byte program descriptor with no BAR slot table: the text and
  text-constant bases, the base of the program's memory at +0x50, the
  task extent, two compiler hints bounded like the H16 work hint, and a
  fixed trailer;
- an eight-word task header, a zeroed stream prologue and the H14
  register image (blocks below 0x4000);
- constants in __TEXT/__const (no __KERN_0) and __TEXT flags left zero.

Without a slot table, an H14 task record names fixed BAR slots: slot 3
is the __DATA scratch, and from slot 4 come the first input, the output,
then the other inputs, in segment order. ane_h16_hwx_slot_base() returns
a slot's base for every target; the validator refuses an H14 stream
whose BAR records name a slot no region binds, and the operation-section
check binds H14 slots by that rule.

The H14 descriptor also carries a tuple at the place of the H16 mcache
prefetch tuple. What it means to the 27.x firmware is not known, so H14
programs send no custom BAR record and the firmware keeps its default
DSID, as on H17.

h16-sections.py builds the LOAD sections for H14 objects too, and
ane-run.py takes an H14 node.

KUnit: the H14 add program (our mil-hwx-compiler, --target H14 --format
hwx) and its sections load and run on an H14 session; it is refused on
an H16 session, with a wrong slot binding, with a BAR record that names
an unbound slot, with a foreign memory base or trailer, and as an H16
object.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
A LOAD or CREATE the firmware refused logged only the errno. For a new
engine or firmware build that says nothing about why: whether the
firmware set a status, kept the request ID, or changed a slot.

Log the reply header (status in its top 16 bits) and the ID words, the
first reply qword that differs from the request with its offset, then
the firmware's own log, as after a failed EXECUTE. The session is
quarantined after such a refusal, so this runs once.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
With a firmware-published channel table (the 27.x firmware) the
rtclient ran the startup on the shared H16/H17 firmware transport, then
registered the ABI 2 node, which refused every program: the 27.x LOAD
takes the original HWX and host-built sections, not the ABI 2 sections.

On that firmware, create the shared program session on the same
transport after the startup and register its ABI 3 node in place of the
ABI 2 one. LOAD, CREATE, EXECUTE, UNLOAD and the firmware's
SHAREDMALLOC traffic then follow the H16/H17 program path. The session
maps program memory as coherent DMA memory in the engine's domain, out
of the firmware alias range, like the rtclient's other firmware-visible
buffers, and gives it back once the firmware no longer uses it. The
engine is H14, so the session takes H14 HWX objects only.

The command arena grows from 16 KiB to 256 KiB, as on the H16/H17 cold
boots: it holds the session's LOAD and CREATE records and EXECUTE
batches besides the startup commands.

System sleep still parks a 27.x engine until reboot; the session now
fails every later request instead of waiting on the stopped CPU. The
13.5 firmware keeps the ABI 2 node and its path unchanged.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
…n/linux into m2mini-ane/h14-handoff

# Conflicts:
#	drivers/accel/ane/ane_h16_hwx.c
An H14 program descriptor carries the same BAR slot table as H16: slot s
takes its base from the qword at +0x10 * (s + 1). The decoded H14 corpus
(research/oracles/h14* in mil-hwx-compiler) shows text_const at +0x20
(slot 1), the __DATA scratch at +0x40 (slot 3) and from +0x50 the first
input, the output and the other inputs. The validator assumed the
descriptor had no slot table, kept a fixed slot rule beside it and refused
slot 1, so a linked convolution program, whose kernel-DMA records name
slot 1 for the coefficients and slot 3 for the scratch, could not load.

Read H14 slot bases from the descriptor like H16 (one
ane_h16_hwx_slot_base()), pin every qword of the H14 table to the
segments in the validator, and bind a slot whose base is __TEXT/__const
to the kernel resource (1007) when the program has no __KERN_0: LOAD slot
1 already carries those constants. h16-sections.py builds the same
binding. The H14 add fixture is regenerated from the compiler's output
with the slot table, and the test refuses a descriptor whose output slot
is empty.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
System sleep parked a 27.x engine until reboot: every later request of
the program session failed with -ESHUTDOWN. Restart it instead, the way
the shared H16/H17 cold sleep path does (ane_fw_cold.c), on the lifetime
transaction the 13.5 firmware already restarts through:

- suspend: admission to the program session closes and every request
  drains (ane_h16_session_sleep()); with nothing in flight on the
  transport, RUN is cleared and the ASC must read STOPPED before system
  PM removes power. The 27.x firmware has no shutdown command, so the
  engine goes off under it, as on H16/H17.
- resume: as for 13.5, the boot runs in the freezable sleep work, after
  a verified power cycle if the CPU domain stayed on. The firmware boots
  again from the kernel's pristine copy of the preload DATA
  (ane_t6021_fwload_reload()), publishes its channel table again, gets a
  fresh shared transport, the boot ACK and the startup exchange as at
  probe, and every open program is loaded again behind its handle
  (ane_h16_session_restart(), ane_h16_session_replay()). Requests that
  arrive meanwhile wait for the session to reopen.

Without a restart source (no pristine preload) the engine is parked
until reboot as before; a failed stop, boot or replay parks the session
so its waiters fail at once.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
Add a two-layer H14 linked convolution from mil-hwx-compiler (1x1 dense
then 3x3 depthwise, fp16 [1, 16, 8, 8]) as a KUnit fixture with the four
LOAD sections h16-sections.py builds for it. Its kernel-DMA records name
slot 1 (the __TEXT/__const coefficients) and its layers meet in the
__DATA scratch (slot 3). The test checks that the validator accepts it,
that slots 1, 3, 4 and 5 resolve to the coefficients, the scratch, the
input and the output, and that it loads (slot 1 bound to the kernel
resource), executes and closes on an H14 session.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
The disk loader gives the firmware fw_extra_ram bytes of owned RAM after
its 5 MiB allocation. A preload got nothing after DATA, but the 27.2 H14
firmware keeps per-process state right there, at its sharedMemoryBase
(TEXT + DATA, the size the host publishes): on the J473, CREATE faulted
in the ANE DART seven times at 0x8006fc040..0x8006ffec0 (DATA ends at
0x8006ec000), the first four EXECUTEs of an add were exact and the fifth
found an all-zero command in the engine's command loop, which asserted.

Give a preload the same fw_extra_ram tail as the disk path: owned
coherent RAM, zeroed, mapped device-writable right after DATA, zeroed
again with DATA on a cold restart and freed with the rest.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
The H16 and H17 backends keep dynamic power gating off for 2 ms after
the last EXECUTE, as macOS does (two 0x002d per run of requests, not per
request). The t6021 27.x session left the hold at zero, so it opened and
closed the gate around every EXECUTE. On the J473 (27.2 H14 firmware) an
add ran exact twice, then the firmware took an exception on the gate
close that followed the third request's completion report, and in an
earlier row the fifth request found an empty command.

Make the 2 ms hold one session constant (ANE_H16_GATE_HOLD_NS, replacing
the H16 and H17 copies) and use it for the t6021 session too.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
A 27.x cold restart across system sleep boots a new firmware on a CPU
whose domains went off (verified by the CPU power-off count, or by the
runtime power cycle the resume work runs otherwise), so nothing reads
the old firmware's memory any more. End a quarantine of the program
session there, as the H16 backend does (ane_h16_session_recovered()),
before the open programs are replayed: a system sleep brings back an
engine whose firmware failed, instead of leaving it out until reboot.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide

RyanTheTide commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor Author

J413 control at head 9123cf6 (M2 Air, same H14 block, macOS 13.5 firmware, no iBoot preload), fleet86 with the six head modules from updates/:

  • The missing optional handoff takes the ordinary disk loader: fwload, boot handshake, channel table validated, ABI 2 node.
  • Depthwise 3x3/s2 and MobileNetV1 (28-task linked ring), 200/200 each. Output digests are identical to stock fleet86 on the same boot pair (d4cf4adf / 8086029f). p50 165 / 547 us (stock 164 / 542).
  • 0 ANE DART faults, 0 Oops/WARN. Production restored (same release, saved entry, empty next entry, Enforcing, 0 failed units, no updates/).

Separately, stock J413 ran the H14 MobileNetV1 ANEC from aurora-silicon/mil-hwx-compiler#47 200 times: one output digest, relative L2 4.6e-3 against a float64 TensorFlow reference, top-5 classes match. That output is the bit-exact expectation for the J473 27.2 MobileNet row, which is queued for the next J473 turn on fleet87.

@RyanTheTide

RyanTheTide commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor Author

J473 rows at head 9123cf6 on fleet87 (this PR's modules for fleet87; trial Stage 2 = fleet87's aura main 8b1cb8ce with aurora-silicon/aura#482 merged on top; default cmdline). Every row was a guarded one-shot, and production was restored and verified afterwards.

  • The preload handoff, 27.2 startup and H14 ABI 3 node all come up cleanly. With the preload tail RAM there are 0 ANE DART faults in all five boots.
  • Add: run 0 exact (512/512, max 0 ulp). Then 17 back-to-back EXECUTEs completed (p50 165 µs), up from 2 before the 2 ms gate hold.
  • Still open, so this stays draft: after a few back-to-back EXECUTEs the 27.2 H14 firmware crashes in its execution loop (exception, or Unexpected CMD = 0x0000 in ExeLoop command channel). Three diagnostic boots narrowed it:
    • Queuing every EXECUTE makes it happen sooner, so the direct path is not the cause.
    • The 0xca8 command layout is right: the firmware refuses a shorter one with a size assert.
    • Giving every command its own arena address did not stop it.
  • MobileNetV1's first 27.2 EXECUTE was acknowledged but never reported (3 s timeout, no fault), so the 27.x sleep restart row had nothing to run on.

The disk-loader control on the J413 (13.5 firmware) passes at this head; see the earlier comment.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Superseded by #3916 (M2 27.2 ANE on the shared H16 backend, the way macOS 27.2 drives it; J473 rows: /dev/accel, add/mul/relu exact, idle re-wake, 2x s2idle) and #3917 (H14 programs on ABI 3 with a LOAD-time DMA bound). The execution-loop crash here came from gating the engine around each request, which macOS never does. Closing this draft.

@RyanTheTide RyanTheTide closed this Dec 2, 2026
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.

1 participant