Repository navigation
accel/ane: h16: take a program's process pool before LOAD - #2897
Open
RyanTheTide wants to merge 2 commits into
Open
RyanTheTide wants to merge 2 commits into
RyanTheTide wants to merge 2 commits into
Conversation
Every CREATE makes the H16/H17 firmware ask for a 2 MiB EXPP process pool by SHAREDMALLOC, and it answers the CREATE only once that request was served. A request the host cannot serve, for lack of memory or of the 12 MiB shared quota, is never answered: the transport fails, the CREATE is lost, and the session is quarantined, taking every other loaded program with it. The host knows the request is coming, so take the pool first: before a LOAD (and a replay), make sure a retired EXPP allocation is there, allocating one now and keeping it retired if not. The firmware's request then reuses it as it reuses any pool given back by FREE. With no memory or no quota the LOAD now fails with -ENOMEM or -ENOSPC before any traffic, the engine stays up and every other program keeps running. A FREE of a torn-down program's pool that is still posted is served first, and the reservation tried once more. The firmware's request still goes through the same checks; a request the host did not foresee and cannot serve fails the transport as before. KUnit: past the quota a LOAD fails with -ENOSPC and no command sent, the other programs keep running and a closed program's pool serves the next LOAD; no memory gives -ENOMEM the same way; a FREE posted after the settle is served by the next LOAD; and at the transport level a reserved allocation serves its request without an allocation and a refused reservation leaves the transport working. The fake firmware now asks for the pool during CREATE and frees it after UNLOAD. [ported onto the per-program command records: the replay takes the pool before its record instead of after an arena room check] Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
A shared allocation the backend hands back for a firmware request is checked (16 KiB aligned DVA, exact size, no overlap with the IPC area, the command pool or another allocation), and one that fails the check fails the transport. The same check runs when a LOAD reserves its process pool ahead of the request, but there it only returned -EPROTO: the backend's mapping is not recorded, so every later LOAD made and dropped another 2 MiB mapping that the backend keeps until teardown. Fail the transport there as well, and quarantine the session when a reservation finds the transport failed, as the request path does. KUnit: a misaligned backend surface fails the reservation with -EPROTO, fails the transport, records nothing, and a second reservation does not allocate again. Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
5 of 7 tasks
Author
|
Review at 871c584. Review at 871c584. Reserving the pool before LOAD is the right shape: the foreseen request can no longer go unanswered. A few problems remain:
|
DjDeveloperr
requested changes
Nov 23, 2026
DjDeveloperr
left a comment
There was a problem hiding this comment.
Formal §1–§6 pre-PR checklist review at 871c584c86805616005b6dcb62fd018454b32da7 (host-tests: green).
Pre-reserving the process pool before LOAD is the right architectural fix, and the KUnit coverage (302/303 pass, 4/4 mutant kills) plus H16 A/B evidence (J616s, Neo, J713) are strong. Three blockers remain:
Blockers
- §4 Missing author
Signed-off-by:on commit56b0be94cc922b045f04de4591a89ecc368e214b:
The commit is authored byBartosz Nitka <niteria@gmail.com>(ported fromniteria/linux), but carries onlySigned-off-by: Ryan Murray <ryan@aurorasilicon.org>. Please include the author'sSigned-off-by: Bartosz Nitka <niteria@gmail.com>trailer. - §2
h16_replay()returns without quarantining the session whenh16_process_pool()fails (drivers/accel/ane/ane_h16_program.c:2110-2112):
Ifh16_process_pool(s)returns-ENOSPCor-ENOMEM(without settings->transport->error),h16_replay()returns directly instead of callingh16_fail(s, ret). Both callers (ane_h16_backend.c:589,ane_fw_cold.c:816) log"PROGRAM REPLAY FAILED ...; session quarantined"andane_h16_session_replay()'s docstring requires quarantining on any failed replay, yets->quarantinedremainsfalseafter a partial replay. Route the error throughh16_fail(s, ret). - §1 / §5 Missing H17 (M5) hardware row & explicit §5 regression counts:
- The change targets both H16 and H17 (
ane_fw_cold.c,allow_free), but no H17 (M5) load-to-quota / close-reload / s2idle-replay row has been run yet (listed under "Still to run"). - Please include explicit §5 regression counts (0 SELinux denials, 0 failed units, 0 new kernel errors) for the J616s, Neo, and J713 hardware rows.
- The change targets both H16 and H17 (
Non-blocking notes
- Hardcoded
(SZ_2M, ANE_FW_SHARED_EXPP)reservation (ane_h16_program.c:646): If a firmware build ever requests a different EXPP pool size or tag, the first LOAD pins one unused 2 MiB retired slot out of the 12 MiBANE_FW_SHARED_TOTALquota (subsequent LOADs see that retired entry inane_fw_shared_reusable()and do not allocate again, so it doesn't leak per LOAD, but 2 MiB stays wasted). Recording the observed EXPP size/tag or documenting why 2 MiB holds across all H16/H17 builds would make this cleaner. - Quota-edge lock hold (
ane_h16_program.c:649): Callingane_fw_transport_settle()(up to 100 ms) under the session lock on every-ENOSPCLOAD can stall concurrent EXECs if a client retries LOAD in a loop at the quota edge. - Merge ordering with
#2854: Note in the PR body which PR lands first given the overlappingane_h16_program_test.cfake-firmware changes.
Checklist summary
- §1 No model gating: Pass in code; blocked on H17 (M5) hardware row.
- §2 Production-ready: Blocked on
h16_replay()missingh16_fail()quarantine path. - §3 Safety: Pass.
- §4 Clean-room & attribution: Blocked on missing author
Signed-off-by:in56b0be94cc92(zero AI trailers in commits;Assisted-by:in PR body). - §5 Evidence: Strong KUnit (302/303 + 4/4 mutant kills) and H16 A/B runs; blocked on H17 (M5) row and explicit §5 regression counts.
- §6 Naming: Pass.
Assisted-by: LLM (Gemini 4 Neon)
|
Merge readiness at
Areas: Updated by pr-readiness on every push, edit and review, and every 30 minutes. Rules: merge policy · labels. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Every CREATE makes the H16/H17 firmware ask the host for a 2 MiB process pool (SHAREDMALLOC) and wait for the answer before it replies. The host caps shared allocations at 12 MiB (
ANE_FW_SHARED_TOTAL). A request the host cannot serve, because the cap is reached or memory is short, is never answered. The transport fails, the CREATE is lost and the session is quarantined, and every other loaded program goes with it. On H16 the recovery power cycle loses the loaded programs. On H17 the session stays quarantined until reboot.Change
accel/ane: h16: take a program's process pool before LOAD(Bartosz Nitka's commit from niteria/linuxane/h17-cma-enomem, ported onto the current tip). Before a LOAD or a replay, the host makes sure a retired EXPP allocation is there, allocating one now if needed. The firmware's request then reuses it, the same way it reuses a pool given back by FREE. Without memory or quota, the LOAD fails with -ENOMEM or -ENOSPC before any firmware traffic. The engine stays up and the other programs keep running. The port's only conflicts are with the per-program command records (accel/ane: h16, h17: give program memory and DVA back after close #2240): the replay now takes the pool before its record.accel/ane: fail the transport when a reserved shared pool is invalid. The reserve path runs the same surface checks as the request path but only returned -EPROTO, leaving the backend's mapping unrecorded, so each later LOAD mapped another one. It now fails the transport and quarantines the session, as the request path does.No chip or board checks. Selection is by the shared-allocation tag and size the firmware asks for. No new parameters.
Testing
KUnit (arm64 qemu,
ane.kunitconfig, this head): 303 run, 302 pass, 1 skip (apple_g17_rx_util_min_test, needsCONFIG_UCLAMP_TASK, unrelated).Same run with both fix bodies reverted (tests kept): 4 fail, exactly the new cases:
ane_transport_shared_reserve_invalid_test,program_process_pool_quota_test,program_process_pool_nomem_test,program_process_pool_late_free_test.J616s (M4 Pro, H16), fleet81 default kernel, this driver loaded as modules, one boot per arm, default command line apart from the one-shot module blacklist used to swap the driver. Eight programs opened and kept, then churn at the quota edge, then 200 load/run/close cycles:
Neo (A18 Pro), fleet82 default kernel, same method and rows:
J713 (M4 Air), fleet81, same method: user-space rows identical with and without this PR (five resident, the rest -ENOSPC, everything else passes). The journal differs: without it, three refused SHAREDMALLOCs, each quarantining the session and resetting the engine (the replay keeps the residents on this Mac). With it, zero refusals and three clean "no process pool" refusals before CREATE.
Still to run
Reviewer notes
ANE_FW_SHARED_MAXandANE_FW_SHARED_TOTALchecks moved unchanged intoane_fw_shared_add(). Bytes are counted once at add, never on reuse. The reply handlei + 1equals the old post-incrementshared_count.ane_fw_transport_report()and the tagged lookups skip it. It is zeroed again when served. Nothing frees shared backing before teardown.carry_shared), so a replay of N programs finds N retired EXPP pools and never allocates.