Skip to content

accel/ane: h16: take a program's process pool before LOAD - #3159

Merged
RyanTheTide merged 4 commits into
mainfrom
ane/h16-process-pool-before-load-v2
Nov 27, 2026
Merged

RyanTheTide merged 4 commits into
mainfrom
ane/h16-process-pool-before-load-v2

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

What

Replaces #2897 (conflicted with main; new branch on main 569ff3d, no force push). Every H16/H17 CREATE makes the firmware ask for a 2 MiB process pool, and a request the host cannot serve used to fail the transport and quarantine every loaded program. The driver now takes the pool before LOAD, so a LOAD past the quota or out of memory fails with -ENOSPC/-ENOMEM and the engine and other programs keep running. Three commits:

  1. niteria's accel/ane: h16: take a program's process pool before LOAD (ported; one KUnit-file conflict with main's recover-gate test, both kept).
  2. accel/ane: fail the transport when a reserved shared pool is invalid (unchanged from accel/ane: h16: take a program's process pool before LOAD #2897).
  3. New, from the accel/ane: h16: take a program's process pool before LOAD #2897 review: ane_h16_session_replay() quarantines the session on any replay error, including the early -ENOSPC/-ENOMEM returns that skipped h16_fail().

@niteria: your original commit (niteria/linux 1e518c576e74) has no Signed-off-by, so it goes in under Ryan's DCO (b) sign-off with the source noted in the message. Could you reply here with your Signed-off-by: line so it can be added?

Tested

  • ANE KUnit (QEMU arm64) at this head: 324 tests, 323 pass, 1 skip. With only fix 3 reverted, the new program_process_pool_replay_nomem_test fails (session not quarantined, hang not reported) and everything else passes. Logs: traces/ci/20261126-pr-burndown-2897v2 (lab store).
  • Hardware rows from accel/ane: h16: take a program's process pool before LOAD #2897 (J616s, Neo, J713; traces/ane/20261123-sec-ane2-29*) were taken on its old head, before fix 3 and the main merge.

Risk

Risk: two-way · M4 Pro, M4 Air, M5, Neo (a plain revert undoes it).

H16/H17 ANE only. A replay that fails early now quarantines the session (as documented) instead of leaving it open on firmware in an unknown state; the backend's recovery handles a quarantined session the same as after any other failed replay.

Not yet

  • H17 (M5) load-to-quota and close/reload row at this head (ane_fw_cold.c path), plus one Neo no-regression row (kits/test/20261123-sec-ane2-29/drive.sh).
  • niteria's Signed-off-by.
Review items from #2897
  1. Author sign-off: the source commit has none; asked above.
  2. h16_replay() early returns without h16_fail(): fixed in the caller, covers every early return; KUnit added.
  3. Conflict with main: resolved by the new branch. H17 row: under Not yet.

niteria and others added 3 commits November 26, 2026 00:45
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 from niteria/linux 1e518c5 (ane/h17-cma-enomem), which has
 no Signed-off-by; 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>
ane_h16_session_replay() documents that a failed replay quarantines the
session, but h16_replay() returns before h16_fail() when taking the
process pool fails (-ENOSPC, -ENOMEM), when the command buffer cannot
be allocated, or when no firmware record is free. The caller then logs
"PROGRAM REPLAY FAILED" and the backend reports the session quarantined
while s->quarantined stays false, so requests reach firmware whose
state is uncertain.

Quarantine in ane_h16_session_replay() for any replay error. h16_fail()
keeps the first error and reports the hang once, so a replay that
already failed the transport is unchanged.

KUnit: a replay that cannot take its process pool fails with -ENOMEM,
replays nothing and quarantines the session, reported once.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
DjDeveloperr
DjDeveloperr previously approved these changes Nov 25, 2026

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed eaa0b0c12f67: ane_fw_shared_add() / ane_fw_transport_shared_reserve() cleanly pre-reserve the 2 MiB EXPP process pool before LOAD/replay (failing transport on -EPROTO while keeping -ENOMEM/-ENOSPC non-fatal), h16_process_pool() settles once on -ENOSPC for late post-UNLOAD frees, and ane_h16_session_replay() now quarantines via h16_fail() on every early replay error (verified by the new KUnit test). Holding merge for CI, exact-head H17 + Neo rows, and @niteria's Signed-off-by:.

@github-actions github-actions Bot added area:media Area from CODEOWNERS (bot) merge-conflict Conflicts with the base branch (bot) needs-hw-row No hardware row at the PR head (bot) needs-template PR body lacks Tested or Risk (bot) labels Nov 25, 2026
@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Merge readiness at 2eb63b78: not ready yet

Check Detail
CI at head no failing: pr-text / pr-text
Review ok approved by DjDeveloperr
Requested changes ok none
Hardware row at head ok comment at 2eb63b78
Conflicts ok none
PR text ok Risk: two-way · M4 Pro, M4 Air, M5, Neo (a plain revert undoes it). H16/H17 ANE only. A replay that fails early now quarantines the session (as documented) instead of leaving it open on firmware in an unknown state; the backend's recovery handles a quarantined session the same as after any other failed replay.

Areas: area:media

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

main gained the H16 runtime-PM tests (#3154) next to the process-pool
tests in ane_h16_program_test.c; both sets are kept.

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

Copy link
Copy Markdown
Contributor Author

Merged main deca761 (#3154 added H16 runtime-PM tests next to these; both sets kept) as 2eb63b7, signed off. ANE KUnit (QEMU arm64) at 2eb63b7: 330 tests, 329 pass, 1 skip.

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed after merging main at 2eb63b78faed: cleanly keeps both the #3154 H16 runtime-PM tests and #3159's process-pool pre-reservation/replay tests (329/330 ANE KUnit pass, 1 skip). Holding merge for CI, exact-head H17 + Neo rows, and @niteria's Signed-off-by:.

@github-actions github-actions Bot added blast:m4 Macs affected, from Merge risk (bot) blast:m5 Macs affected, from Merge risk (bot) blast:neo Macs affected, from Merge risk (bot) ci-failing A check failed at the PR head (bot) door:two-way Revertible or not, from Merge risk (bot) and removed merge-conflict Conflicts with the base branch (bot) needs-template PR body lacks Tested or Risk (bot) labels Nov 25, 2026
@niteria

niteria commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Verified 44282911e4a4 against my original 1e518c576e74 — looks good to me.

Signed-off-by: Bartosz Nitka niteria@gmail.com

@niteria

niteria commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Hardware row at 2eb63b78faed (H17 / M5)

  • M5 MacBook Air 13" (T8142 / J813, Mac17,3, H17 ANE 420000000.ane / ane_fw_cold.c, firmware 27.2 26B123) at 2eb63b78faede13cce56a6f52c56b82ba3f887e2 (7.3.0-air-m5-2eb63b78faed, zero carried patches, matching t8142-j813.dtb, NixOS default J813 cmdline, no cma= / no ANE module params): PASS.
    • Load-to-quota (add1024, 8 concurrent fds): 5 resident (fd[0..4], shared_bytes=0xa60000), next 3 LOADs (fd[5..7]) refused cleanly up front with -ENOSPC (H17 LOAD: no process pool 1c a60000).
    • Resident execution while at quota: 80/80 exact fp16 across all 5 residents.
    • Close all 5 residents & reload: 20/20 fresh cycles exact.
    • Quota-edge churn at cap=5: 150/150 PASS (each iteration: 6th LOAD → -ENOSPC, resident exec exact, close oldest, reload into retired EXPP pool, exec new resident exact; 150 -ENOSPC refusals).
    • Sequential pool reuse (cycle200): 200/200 PASS (3.47 s).
    • Journal counts across the run: 153 H17 LOAD: no process pool 1c a60000 (3 initial + 150 churn), 0 SHAREDMALLOC refused, 0 quarantines, 0 recoveries/resets.
    • §5 regression tuple: 0 SELinux denials (SELinux disabled on NixOS, lsm=landlock,yama,bpf), 0 failed systemd units, 0 new ANE/driver kernel errors (only 2 expected cma: __cma_alloc_frozen: req-size: 128 pages, ret: -16 buddy-allocator fallbacks when allocating pools 3–4 out of the 32 MiB CMA pool, same as baseline before the separate out-of-CMA patch).
M5 Air (J813) run log & journal excerpts (`boot_id=5107ac73`)
device=/dev/accel/accel0 chip=H17 kernel=7.3.0-air-m5-2eb63b78faed

[1] Load-to-quota (attempting 8 concurrent fds)
  fd[0]: LOAD ok (13.6 ms)
  fd[1]: LOAD ok (0.5 ms)
  fd[2]: LOAD ok (0.5 ms)
  fd[3]: LOAD ok (0.6 ms)
  fd[4]: LOAD ok (0.5 ms)
  fd[5]: LOAD -> -ENOSPC (expected past quota)
  fd[6]: LOAD -> -ENOSPC (expected past quota)
  fd[7]: LOAD -> -ENOSPC (expected past quota)
  => quota_cap=5 resident, enospc_refusals=3

[2] Resident execution (80 runs across 5 residents)
  => residents_exec=80/80 exact

[3] Close all 5 residents & run 20 fresh cycles
  => fresh_after_close=20/20 exact

[4] Quota-edge churn (150 iterations at cap=5)
  => edge_churn=150/150 PASS (enospc=150)

[5] Sequential load/run/close (200 cycles)
  => cycle200=200/200 PASS (3.47 s)

SUMMARY: ALL PHASES PASSED
  cap=5, enospc_initial=3, residents=80/80, fresh=20/20, edge_churn=150/150, cycle200=200/200

Journal verification:

LOAD: no process pool: 153
SHAREDMALLOC refused: 0
quarantine: 0
recover/restart: 0

Sample lines:

ane_t6021 420000000.ane: H17 ANE: first bring-up for a request: 0
ane_t6021 420000000.ane: H17 LOAD program 0 0
ane_t6021 420000000.ane: H17 CREATE process 0 0
...
ane_t6021 420000000.ane: H17 LOAD: no process pool 1c a60000

(Note: Neo / J700 is currently offline; only the M5 / H17 row was run here. Also, pr-text / pr-text passed on run 45631012679, though pr-readiness is still citing the earlier cancelled run 45629750405.)

@github-actions github-actions Bot removed the needs-hw-row No hardware row at the PR head (bot) label Nov 25, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

2eb63b78faed (batched cleanly in J616s Batch #2 5b411e230229 over main 95a983c08be4, 0 merge-tree diffs across all 4 changed files) J616s (MacBook Pro 16" M4 Pro, T6040, Apple M4 Pro (G16S B1), macOS 26.6.2 fw, guarded one-shot 7.3.0-aurora-pr2905+, default cmdline, stock Stage 2 1.0.0b17, boot_id=de17fad3) PASS: 0 failed units, Enforcing, 0 new AVC (1 matching baseline), 0 GPU faults, 0 errors in this subsystem, real rtc1 s2idle 2/2 (success=2 fail=0), eDP connected pre/post-sleep, 406600000.sep + 514600000.mtp RTKit v12 (AppleMTPFirmwareMac-5340.61.4~502, HID keyboard/trackpad/accel/actuator/touch) clean, Borealis VK dEQP-VK.api.smoke.* 8/8 (pre & post-sleep) + glsl.loops.* 624/624, Wi-Fi 3/3 ping pre/post-sleep; stock 7.3.0-aurora-fleet89 restored & verified (b67edc6c).

@RyanTheTide
RyanTheTide merged commit e12e25d into main Nov 27, 2026
19 of 23 checks passed
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Merged as e12e25d. The merge commit records Bartosz's Signed-off-by for 4428291, from his comment here: #3159 (comment)

@RyanTheTide
RyanTheTide deleted the ane/h16-process-pool-before-load-v2 branch November 27, 2026 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:media Area from CODEOWNERS (bot) blast:m4 Macs affected, from Merge risk (bot) blast:m5 Macs affected, from Merge risk (bot) blast:neo Macs affected, from Merge risk (bot) ci-failing A check failed at the PR head (bot) door:two-way Revertible or not, from Merge risk (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants