Repository navigation
accel/ane: load H14 firmware from iBoot reservations - #2973
RyanTheTide wants to merge 9 commits into
Conversation
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
left a comment
There was a problem hiding this comment.
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.
|
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. |
|
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
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
ane_fw_channels_parse(). Otherwise keep the 13.5 path unchanged. There is no chip, board or firmware-version check.Testing
J473, fleet85 kernel, default command line, guarded aura-try one-shots, production restored and verified byte-identical after each row:
/dev/accel/accel0registered. 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.
Host at fbd0818 (integration/aurora merged in): KUnit (arm64 QEMU, all ANE suites) 314 run, 313 pass, 1 skip (needs
CONFIG_UCLAMP_TASK). W=1 module build 0 new warnings;checkpatch --strict0 errors on every new commit.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
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 without a BAR slot table, 8-word task header, zero stream prologue, H14 register map, no__KERN_0. Slots follow the compiler's fixed rule (3 scratch, 4 first input, 5 output, 6+ other inputs). 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.
Assisted-by: LLM (Codex), LLM (Claude:Opus 5.5)