Repository navigation
accel/ane: reuse the firmware's freed pools and release programs at close - #823
Merged
Merged
Conversation
Every program LOAD makes the firmware ask for a 2 MiB EXPP process pool over SHAREDMALLOC. The firmware frees it after UNLOAD (seen on H17, often only during a later program), and the FREE handler retires the surface but, by design, keeps its backing, mapping and quota until reset, because the engine may still have touched it. Nothing ever served that memory again, so the 12 MiB shared quota ran out at the sixth program of a boot. On the J616s (fleet14h) the sixth MobileNet LOAD got "SHAREDMALLOC refused 0 200000 45585050 error -28", CREATE failed and the session was quarantined until reboot. Serve a new request from a retired allocation of the same tag and size: same DVA, same handle as when it was first served, zeroed like new memory, then acknowledged as a normal allocation. Only memory the firmware gave back by FREE is reused; memory it still owns is never handed out twice, and without a FREE the quota still runs out as before. Both backends now log each FREE and each reuse, so the firmware's FREE behaviour is visible in dmesg. KUnit: twenty LOAD/UNLOAD pool lifetimes with an immediate FREE (H17 and the H16 native reply) reuse one pool, twenty with a late FREE alternate between two, reused memory is zero, a retired pool never serves another tag or size, and without FREE the seventh 2 MiB request is still refused. Assisted-by: LLM Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
Closing the accel file tears the program down with TERMINATE and UNLOAD, but nothing else ended: the program, its 8.4 MB HWX snapshot (MobileNet) and every mapping it used (about 12.6 MB for MobileNet) stayed until reboot. Repeated loads in one boot therefore grew without bound: kernel memory by the snapshot, and the program DVA window (1 GiB on H16, 512 MiB on H17) by the mappings, on top of the shared pool leak fixed in the previous commit. This is the H16/H17 counterpart of the H14 program lifetime (#737). At close, once TERMINATE and UNLOAD are acknowledged: - serve the SHAREDMALLOC ring until it has been quiet for 10 ms (at most 100 ms), since the firmware posts the FREE of the process pool after the UNLOAD reply and waits for it with its lock held; - hand the program's region and aux mappings to the session's spares; they stay mapped until reset like every firmware-visible mapping, and a later LOAD takes a spare of the same size and permission, zeroed, before mapping new memory; - the accel layer then frees the program and its snapshot. A program whose teardown failed keeps its memory, its mappings and its struct until reset, as before. Every program's first EXECUTE is still queued, so reused memory never inherits a stale binding. KUnit: fifty H16 and fifty H17 MobileNet load/execute/close cycles map memory only for the first program and get zeroed memory back, a failed teardown keeps everything, a FREE posted after UNLOAD is answered by the settle loop, and the shared pool test now runs fifty cycles. Assisted-by: LLM Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
notmysegv
pushed a commit
to notmysegv/linux
that referenced
this pull request
Nov 4, 2026
…tion/aurora Bring integration/aurora up to aurora-wip e1524e6, the source of 7.3.0-aurora-fleet14l, promoted on all four machines on 2026-11-02. The range also covers the fleet14i, fleet14j and fleet14k sources (a8fa302, d67eece, ce900d1). It adds aurora-silicon#822, aurora-silicon#823, aurora-silicon#824, aurora-silicon#827, aurora-silicon#829, aurora-silicon#834, aurora-silicon#835, aurora-silicon#836, aurora-silicon#838, aurora-silicon#840 and aurora-silicon#839. No conflicts. Assisted-by: LLM Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
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.
Fixes ANE program loads failing after the fifth per boot on H16 (M4 Pro), and the same growth on H17 (Neo).
Each LOAD makes the firmware ask for a 2 MiB EXPP pool by SHAREDMALLOC. It frees that pool after the program is unloaded, but the driver neither honoured the FREE nor reused the memory, so the shared window ran out: on fleet14h the 6th LOAD of a boot got
SHAREDMALLOC refused ... error -28and the session was quarantined until reboot. Program region and section mappings and the 8.4 MB HWX snapshot also grew with every load. Same class as the H14 fix in #737.a3175c51A SHAREDMALLOC of the same tag and size takes a pool the firmware has returned by FREE (same DVA and handle, zeroed). Memory the firmware still owns is never reused.ffe88a04Program lifetime at last close of the accel fd (the only unload path in ABI 3, so a client that just closes is covered): after TERMINATE and UNLOAD are acknowledged the SHAREDMALLOC ring is served until it is quiet so the late FREE is answered, region and aux mappings become session spares reused by later loads, and the program and HWX snapshot are freed. A failed teardown keeps everything.Hardware:
KUnit 176/176 (50-cycle H16 and H17 tests, close without unload, late FREE, no reuse without FREE, failed close), host tests 161/161, W=1 and checkpatch clean.
🤖 Generated with Claude Code