Repository navigation
ANE: H14 program lifetime - #737
Conversation
Fence commands and buffer creation, stop only the Linux-owned ASC CPU, and power-cycle every domain through the same runtime-PM transaction. Verify the physical PMGR states and repeat the probe access gates before restoring the cached pristine image and the existing fenced boot flow. Require READY/DONE, ChMan validation, host ACK and CONFIG_GET before accepting work again. Unsupported ownership profiles remain quarantined. Retain metadata for closed firmware-visible BOs and old boot/MALLOC arenas. Reclaim old resources only after validated restart; charge retired arenas to the existing limits and bound failed-boot retention. Release the old CPU pin only after quiescence and acquire its replacement before any boot write. The existing domain-link lifetime pin remains. Use opaque kernel program/process IDs, independent of reused firmware wire IDs. Invalidate the cache across restart without resetting the allocator, so clients reload rather than executing a stale identifier. Add KUnit non-reuse/exhaustion checks and matching reset diagnostics. Carried onto aurora-wip 9ed109d. The conflicts were the include list, the client struct and the wire IDs in the procedure call. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
The H14 firmware never got a program back. Every LOAD_PROGRAM and CREATE_PROCESS stayed in the firmware until reboot, and so did the section buffers the driver kept for it. On an M2, ten or eleven MobileNet-sized programs loaded by short-lived processes were enough for the firmware to stop answering. The next LOAD timed out with 17 firmware allocations (17 MB) outstanding, well inside the driver's own limits, and the device stayed quarantined until reboot. Give every program a lifetime. Each file holds a reference on the programs it loaded, and EXEC and PROC_CREATE refuse a program the file holds none on. When the last reference goes, the driver sends TERMINATE_PROCESS and then DESTROY_PROGRAM, and only after both are acknowledged does it drop its references on the section buffers. A failed unload keeps the program and its buffers until a verified firmware restart. Answer the firmware's FREE requests on the SHAREDMALLOC ring. The firmware posts one when a pool shrinks, for example when a process is terminated, and waits for the answer with its shared memory lock held, sometimes after the command that caused it was acknowledged. The driver used to take such a slot for a malformed MALLOC. It now answers the request, frees the buffer and reuses its table slot, so the table and its byte count follow the live allocations. The ring is served before each command, while a command or call is pending, and for 10 ms of quiet after each unload command. A timed-out command now logs the allocation ring and the T2H rings at the host cursors, and debugfs fw_memory reports the live allocations, bytes and programs. The request classes, the slot reuse rule and the per-file program references follow omarchy-ane by Joshua Warren (MIT). KUnit ane-t6021-lifetime covers the request classes, slot reuse, shared programs, unload order, held programs, a restart during an unload and the table limits. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
|
M2 hardware run, 01/11 12:04-12:10, 7.3.0-aurora-tt3 with this module. Result: not ready, keep draft. What works
What fails
Both failures fail closed with no system impact. The M2 is back on the original module. Next step: decode what TERMINATE_PROCESS requires after a multi-task procedure, and what T8112 CPU_STATUS reports for a stopped CPU, before another device run. 🤖 Generated with Claude Code |
On the M2 the previous commit unloads single-task programs cleanly, but TERMINATE_PROCESS after a program with more than one task has run never completes and the firmware stops answering. The firmware waits for its own flush with no timeout, no host step is missing, and there is no other command that frees such a process. Every useful network is multi-task, so unloading on close cannot be the design. Separate a program from its residency in the firmware. - A program is single-task only when its TD property section (load id 7) and its TD stream (load id 3) both count one task, read from the same snapshot as the cache key. Anything else counts as multi-task, and a multi-task process is never terminated. - At the last close a single-task program, or one without a process, is unloaded as before. A multi-task program stays resident as a cache entry that the next load of the same bytes reuses with no command. - At most eight programs are resident. Each process holds a 2 MiB firmware allocation and a LOAD sent with eight resident never completed. Before every LOAD the driver unloads single-task programs (unreferenced first, then least recently used), and when none is left it restarts the firmware at that idle point. - Programs keep their kernel IDs, section references and LOAD records while files hold them. After an eviction or a restart the next PROC_CREATE or EXEC loads the program again and creates its process, so clients see no change. A restart drops unreferenced cache entries. - The restart is a state machine. A planned restart sends POWER_DOWN (0x0b), waits for its completion and for WFI, clears CPU_CONTROL RUN and then bit 5, and requires CPU_STATUS STOPPED with RUN clear before any domain goes off. The old code waited for RUNNING to clear and STOPPED to set right after clearing RUN, which never happens on T8112 (0x2c idle, 0x28 halted, neither stopped). After a command timeout only the RUN clear is tried. If STOPPED is not seen nothing is powered off and the device stays quarantined with its mappings, power claim and pin. A refused POWER_DOWN leaves the live firmware in service. - debugfs fw_memory also reports resident, cached and single-task programs, the limit, the budget restarts and the firmware generation. The KUnit suite ane-t6021-lifetime covers the task count parsers, the never-terminate rule, the cache, the resident budget and eviction order, reload after a restart with stable IDs, a thirty-program sequence that never exceeds the budget, and the restart stop ordering. The TD walk follows the block walk that omarchy-ane's libane section builder by Joshua Warren (MIT) documents. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
POWER_DOWN (0x0b) on the 13.5 legacy firmware is the 8-byte header only; any other length asserts. The handler stops the firmware timers, requests its power state and waits in WFI for good, so it never posts a completion and its slot stays firmware-owned. The previous commit sent 16 bytes and waited for a completion, so the first planned restart would have quarantined the device. Post the header without waiting, after answering any request already on the SHAREDMALLOC ring (a core in WFI cannot finish that handshake). The dispatcher clears the completion field on entry, so mark it and wait for the clear, then require CPU_STATUS IDLE on twenty reads 100 us apart before clearing RUN. Drop the extra CPU_CONTROL bit 5 clear: it is not part of the ASC register contract and bit 5 is already clear while the core runs. STOPPED with RUN clear is still required before any power domain goes off. STOP (0x01) is not sent first. It runs the same no-timeout flush that never returns after a multi-task call, and the host already proves the instance idle under the firmware lock. The resident limit stays at eight. Document it as what it is: the firmware's L2 spill pool holds eight 2 MiB buffers and grows on every CREATE_PROCESS while it holds fewer, the program and process tables are far larger (240 and 496 advertised), and a LOAD sent with eight processes resident was seen to never complete. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
|
M2 hardware run, 01/11 15:36-15:43, 7.3.0-aurora-fleet14b with this branch at 7af2409 (two boots), then the stock module (one boot). Result: not ready, keep draft. The M2 is back on the stock module and initramfs. What works
What fails
Consequence for this PR: the rule "never terminate a multi-task process" was based on the two first-shift repros, which used two of these programs. It may not be needed for well-formed multi-task programs. The next step is to find what in those programs wedges the firmware (compiler side) and to test TERMINATE on a program that does not wedge. Timing (lead's classify question, stock module): MobileNetV1 per-call time is 1.31 ms with back-to-back calls, and up to 1.65 ms after a sleep gap of 1 ms or more (CPU wake-up). Firmware perf mode (0x10aa) changes nothing. The demo's 10-12 ms "selected" time is mostly its own Python packing around a 1.3-1.7 ms ANE call, not ANE or driver time. Evidence: full dmesg of all three boots and the per-step JSON are kept with the lane reports. 🤖 Generated with Claude Code |
The H14 firmware currently remains live while system PM suspends its power and IOMMU suppliers. The next command can time out after resume, leaving the device unusable until reboot. Fence submitters under the firmware mutex and split the existing lifetime restart transaction at its proven-stop boundary. System suspend uses the same cooperative shutdown and ASC stop helper as planned recovery. Keep the transaction and all old backing across the supplier transition, then use the existing accessibility checks, cold boot, handshake and lifetime commit on resume. Only a verified restart reopens submissions. Runtime recovery continues to perform its existing explicit power cycle. Reuse the shared program table and lazy reload policy, preserving public program IDs; introduce no second replay or allocation-retirement path. Leave failed stops and restarts fenced with the lifetime owner's existing retention policy. Add KUnit coverage for system callback wiring, three sleep cycles, serialization, stop/restart errors and the shared stop-only boundary. Document the M2 platform-test cycles and subsequent s2idle acceptance run. This change depends on the shared H14 lifetime work in linux #737. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
Header word 2 of each H14 TD block marks the first task of a program (0x08) and its last (0x22), 0 between, both (0x2a) on a single task. All 1503 decoded Apple H14 programs follow that. A compiler bug emitted 0x2a on every task of a multi-task layer. On the M2 such a program's call returns, and then the firmware never completes another command until reboot, with this driver and with the stock one. That is the hang the earlier commits read as a TERMINATE_PROCESS wedge after multi-task programs: both repro programs had the malformed flags. Check the flags in the same snapshot that keys the cache and refuse a malformed program with -EINVAL before the firmware sees it, so one client cannot take the ANE away from every other until reboot. A stream that does not parse is left to the firmware's own descriptor check. KUnit td_flags_test covers the single, two- and three-task forms and the broken ones. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
|
M2 hardware run 2, 01/11 16:14-16:19, 7.3.0-aurora-fleet14b with be53192 plus test-only debugfs hooks (a switch that makes newly loaded programs terminable, and a restart trigger; never committed). The M2 is back on the stock module, smoke 20/20.
So the "never terminate a multi-task process" rule is not needed. Its only evidence was programs with malformed task flags, which are now refused at LOAD. Next commit: unload every program at last close and keep the restart for HELD or uncertain cases only. That will need one more M2 check. 🤖 Generated with Claude Code |
The rule that a multi-task process is never terminated came from two M2 repros that both used programs with malformed first/last task flags, which the previous commit refuses at LOAD. On the M2 with well-formed programs, TERMINATE_PROCESS and DESTROY_PROGRAM complete for processes of 2, 4, 8, 10 and 45 tasks (a MobileNetV1), and the firmware allocations go back to the idle baseline every time. Drop the rule and the task count it needed. The last close now unloads every program. Room for a new LOAD comes from unloading the least recently used program a file still holds, which loads again with a new process on its next use. A firmware restart is left only for the case where every resident program is HELD, that is a load or unload whose outcome is unknown. The malformed program refusal, the resident limit, the restart state machine and the POWER_DOWN stop stay as they are. KUnit drops the task count cases and covers unload at last close for any program, LRU eviction of held-open programs, and a restart only when all residents are HELD. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
The H14 firmware currently remains live while system PM suspends its power and IOMMU suppliers. The next command can time out after resume, leaving the device unusable until reboot. Fence submitters under the firmware mutex and split the existing lifetime restart transaction at its proven-stop boundary. System suspend uses the same cooperative shutdown and ASC stop helper as planned recovery. Keep the transaction and all old backing across the supplier transition, then use the existing accessibility checks, cold boot, handshake and lifetime commit on resume. Only a verified restart reopens submissions. Runtime recovery continues to perform its existing explicit power cycle. Reuse the shared program table and lazy reload policy, preserving public program IDs; introduce no second replay or allocation-retirement path. Leave failed stops and restarts fenced with the lifetime owner's existing retention policy. Add KUnit coverage for system callback wiring, three sleep cycles, serialization, stop/restart errors and the shared stop-only boundary. Document the M2 platform-test cycles and subsequent s2idle acceptance run. This change depends on the shared H14 lifetime work in linux #737. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
Runtime PM is disabled during the late/noirq phases, between the normal suspend and resume callbacks. Clarify that ordering and wrap the adapter documentation. The system callbacks still leave the supplier transition to system PM and do not invoke the runtime recovery power cycle. Add the sleep test module description required by modpost. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
|
M2 hardware run 3, 01/11 18:03-18:14, 7.3.0-aurora-fleet14c with 51d33d3 plus a test-only debugfs restart trigger (never committed). The M2 is back on the stock fleet14c module, smoke 20/20.
🤖 Generated with Claude Code |
|
Merging. Hardware result on the M2 (T8112, fleet14b/fleet14c), across four slots today: malformed programs (first/last task markers on every task) refused at LOAD; 72 well-formed programs (single-task, multi-task and linked up to 45 tasks) unload at last close with firmware allocations back to baseline; the planned firmware restart proves STOPPED (CPU_STATUS 0x2e) every time and MobileNetV1 held open across it stays top-1 16/16 with bit-identical output; TERMINATE and DESTROY of well-formed multi-task processes are clean; three pm_test freeze cycles pass with MobileNet held open (16/16 after) and a fresh MobileNet 16/16; 560 unload/reload cycles under the 8-resident limit with every command acknowledged. The one sub-check not captured (MobileNet output during the 15 s eviction stress) is covered by the same reload path the restart test exercises, and will be rerun with the fixed script in the next M2 slot. 🤖 Generated with Claude Code |
|
M2 check after merge, 01/11 18:53-18:55, stock 7.3.0-aurora-fleet14d (aurora-wip 4759557, which includes this PR). No module install, no test hooks. This closes the one gap left by run 3: MobileNetV1 correctness while it is unloaded for room and loaded again. MobileNetV1 (compiler-fixed package) stayed open in one process for 16 reference images and then 60000 passes. For 15 s of that, 10 multi-task programs looped in 10 other processes, which is 11 live programs against the limit of 8 resident. At the mid-point the driver reported 8 resident, 17 firmware allocations (8 spill buffers), 0 restarts and firmware generation 0. So programs were unloaded and reloaded for room without a firmware restart.
🤖 Generated with Claude Code |
…tion/aurora Bring integration/aurora up to aurora-wip b359258, the source of 7.3.0-aurora-fleet14f, promoted on the M1 Pro, M2, Neo and J616s on 2026-11-01 and 11-02. The range also covers the fleet14c, fleet14d and fleet14e sources (f41ac3d, 4759557, 757fc07), each booted on hardware. It adds aurora-silicon#773, aurora-silicon#776, aurora-silicon#777, aurora-silicon#737, aurora-silicon#713, aurora-silicon#785, aurora-silicon#786, aurora-silicon#788, aurora-silicon#789 and aurora-silicon#787. No conflicts. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
H14 (M2, T8112) program lifetime. Before this PR the driver never gave a program or process back to the firmware. Every process holds one 2 MiB firmware allocation, and a LOAD sent with eight processes resident never completes, so about eight programs could be loaded per boot and then BO_INIT failed until reboot.
The first M2 run of this PR (comment below) showed that unloading on close works for single-task programs and halts the firmware for multi-task ones. The firmware facts since then: TERMINATE_PROCESS waits for its own flush with no timeout, no host step is missing, and no command frees such a process. A cold firmware restart is the only way to reclaim it, and the ASC must be proven stopped (CPU_STATUS bit 1) before power removal. On T8112 0x2c is idle and 0x28 halted, neither is stopped.
Commits
accel/ane: restart owned H14 firmware after a command timeout (carried from accel/ane: add bounded timeout recovery for H13 and owned H14 #692).
accel/ane: free H14 firmware allocations and unload programs on close. Per-file program references, SHAREDMALLOC FREE answered, unload commands, debugfs
fw_memory.accel/ane: H14 program lifetime without multi-task terminate.
fw_memoryalso shows resident, cached and single-task programs, the limit, the restarts and the firmware generation.accel/ane: post H14 POWER_DOWN without waiting for a completion. POWER_DOWN is the 8-byte header only and never completes (the firmware ends in WFI). The driver marks the completion field, waits for the dispatcher to clear it, then requires IDLE on twenty reads 100 us apart before the RUN clear. STOP (0x01) is not sent: it runs the same no-timeout flush that never returns after a multi-task call. The limit of eight is documented as the firmware's 8-buffer L2 spill pool plus the observed LOAD hang, not a table ceiling (240 programs and 496 processes advertised).
accel/ane: refuse H14 programs with malformed first/last task flags. The hardware run below found the real trigger of the "multi-task TERMINATE wedge": a compiler bug wrote 0x2a (first and last task) in header word 2 of every task of a multi-task layer, where all 1503 decoded Apple H14 programs use 0x08 on the first, 0 between and 0x22 on the last. Such a program's call returns and then the firmware never completes another command, with this driver and the stock one. The driver now refuses those programs at LOAD with -EINVAL. Compiler fix: aurora-silicon/mil-hwx-compiler PR arm64: apple: describe J700 CPU, power and storage topology #16.
accel/ane: unload every H14 program at last close. With malformed programs refused, TERMINATE and DESTROY complete on the M2 for processes of 2, 4, 8, 10 and 45 tasks, so the never-terminate rule and its task count are gone. Room for a LOAD comes from unloading the least recently used program a file still holds (it loads again on next use). The firmware restart is left for the case where every resident program is HELD.
accel/ane: stop and restart H14 firmware across system sleep, and 8. clarify PM phases and describe the sleep tests (from the system-sleep lane, reviewed and taken in unchanged). System suspend fences submitters under the firmware mutex and runs the same planned stop as the restart for room (POWER_DOWN, WFI, RUN clear, STOPPED proven); if STOPPED is not proven the suspend is refused and nothing is powered off. Resume checks the ASC is still stopped, cold-boots the firmware with the same boot and handshake, and the programs files hold reload on next use with their IDs.
Checks
ane-t6021-lifetime16/16,ane-h14-sleep5/5,ane-pm-recovery6/6 (task count parsers, never-terminate rule, cache reuse, budget and eviction order, reload with stable IDs after a restart, a thirty-program sequence that never exceeds the budget, restart stop ordering). The 3 failures are theane-h16-hwxforms, tensor and snapshot cases, which fail the same way on the base.Open items
Hardware: see the comments. Commits 1 to 5 passed on the M2 (second run). A check of commits 6 to 8 (including three platform suspend cycles) is booked; merge after it passes. Keep draft until then.
🤖 Generated with Claude Code