Repository navigation
drm/asahi: g17: never reuse a work state before its fence on the A18 Pro - #1978
Merged
DjDeveloperr merged 3 commits intoNov 16, 2026
Merged
Conversation
DjDeveloperr
marked this pull request as ready for review
November 16, 2026 07:28
The capacity snapshot counts the times a cached firmware object was handed out again before the firmware had consumed a control record published after the object came back, but only as one total. The cache holds five families of objects (descriptor storage, work states, queue records, queue configuration and, on M5, scheduler pages), and the total does not say which of them ran into that limit. Give each family's line its own waiting and overrun counts. The total line is unchanged. Signed-off-by: Diljit Singh <[email protected]>
The driver keeps returned firmware objects in a cache and hands them to new queues and contexts. A returned object waits for a fence: the firmware must have consumed a control record published after the object came back. The driver returns descriptor storage, queue records and queue configuration only after the firmware has consumed their owner's release, or when the firmware never saw them, and it already frees the owners' other firmware-visible storage at that point. The fence then waits for a further control record, which may not come while queues are only being created. When a client opens dozens of contexts at once, the objects from the last teardown stay behind that fence, the families fill up, and new queues take objects whose fence was never met. On the A18 Pro, reuse those three families once the firmware has consumed every control record published before the object came back, which includes the owner's release, without waiting for a later one. Work states and scheduler pages keep the stricter fence on every GPU, and so do all families on the other GPUs: that fence came with a fix for an M4 Pro crash on a recycled work state, and stays there until it is shown not to be needed. Signed-off-by: Diljit Singh <[email protected]>
A returned work state waits for the strict fence: the firmware must have consumed a control record published after the object came back. Creating a context publishes no control record, and a teardown pass publishes all of its scheduler releases before any of its contexts is dropped, so every work state of that pass waits for a record that may not come while clients only create queues. When a client opens dozens of contexts at once the family fills up, and new contexts take work states whose fence was never met. On the A18 Pro these are the only cached objects still handed out that way. On the A18 Pro, let each cached work state record how far its address reached the firmware, and pick its fence from that when it comes back: - Unseen: no queue record or command ever named it, because its context failed or closed before publishing anything. The firmware cannot reference it, so it needs no fence. - Released: the firmware consumed its owner's scheduler release and the work list was empty. It is reused at once. The driver already frees the owner's other firmware-visible storage at that point, and reuses descriptor storage and queue records then. - Strict: everything else keeps control_fence(). That is a work state a record or command may still name, and one named by a compute queue record kept installed after its owner exited. Such a record is rewritten when the queue is bound again, possibly for another VM, and nothing on the control ring shows when the firmware stops following the old one, so a later release does not lift the fence there. This is the case 34b438d fenced after an M4 Pro crash on a recycled work state. Every accessor that hands the address to the firmware, the work-list head for queue records and a node for commands, marks the work state. Comparisons with the host's own reads of the head use a separate accessor that does not. A full work-state family whose entries all still wait no longer has its oldest entry reused: the new work state is left uncached, as when every entry is in use. The capacity snapshot counts uncached objects per family and work-state returns per class. M4 and M5 are unchanged: their work states carry no mark and keep the strict fence and the old reuse rule. tools/asahi/g17-object-fence-tests.py compiles the pool and the context accessors against host stubs and checks both. Signed-off-by: Diljit Singh <[email protected]>
DjDeveloperr
force-pushed
the
djdev/g17-object-fence-after-release
branch
from
November 16, 2026 08:35
c186da0 to
8122212
Compare
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.
The driver keeps returned firmware objects in a cache and hands them to new queues and contexts. A returned object waits for a fence: the firmware must have consumed a control record published after the object came back. When no ready object is left and a family has no room for another cached one, a new context takes an object whose fence was not met, and the capacity snapshot counts an overrun.
On the A18 Pro every such overrun is a work state. Creating contexts publishes no control record, and a teardown pass publishes all its scheduler releases before it returns any work state. So during a burst of context creations (the GL conformance cases that keep many contexts alive, for example), every work state returned by the last teardown waits for a record that does not come. The family fills up, and new contexts get work states whose fence was never met. That is the reuse 34b438d fenced after an M4 Pro firmware crash on a recycled work state.
Change
Testing
tools/asahi/run-host-tests.py --only g17and--only asahi-m4pass, including a new test of the work-state classes and of the unchanged decisions on the other GPUs.life.churn3/3, 4,500/4,500 dEQP-VK cases passed.Rebased onto integration/aurora a163d7f (after #1977, #1981 and #1982 merged). The only conflict was in
g17/fw/variant.rs, where #1981'srender_id_at_createand this PR'sobjects_after_releasenow sit side by side, both set for the A18 Pro only.context.rsmerged on its own: the two changes there are independent (#1981's render pool identity, this PR's work-storage return mark). Every file's diff is the same as before, so the logic is unchanged. Host tests: g17 38/38, asahi-m4 1/1. Fedora compile and link check OK. The only new warning is onefetch_updatedeprecation inobject.rs, the same as the existing ones infreelist.rsandmmu.rs.try_updatewould not build with the Rust 1.85 toolchain the Neo kits use.🤖 Generated with Claude Code