Skip to content

drm/asahi: g17: let a refused render take back idle render pools - #1948

Merged
DjDeveloperr merged 1 commit into
integration/aurorafrom
djdev/g17-reclaim-idle-render-pools
Nov 15, 2026
Merged

DjDeveloperr merged 1 commit into
integration/aurorafrom
djdev/g17-reclaim-idle-render-pools

Conversation

@DjDeveloperr

@DjDeveloperr DjDeveloperr commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Every queue that renders has a render pool. The pool's pages are mapped in an address window that the pools of all clients share, and the window has room for about forty pools. When a render finds no room for its queue's pool, the driver is meant to take back the pools of idle queues first (a queue with nothing in flight, whose pool the firmware has released, populates its pool again on its next render) and to wait only if that returns nothing.

That reclaim never returned a render pool. It hands the pages it takes back to the caller's batch, which frees them after the device lock is released, and it stops as soon as the batch has no room. Both callers passed a batch that is created without room for render pool pages. Until now a render pool was given back only when its queue was destroyed, or by the event worker after its whole client had been idle and evicted under memory pressure.

A client that kept more queues with populated pools than the window holds therefore got no room for one more, although the others were idle. Seen with a GL conformance case that keeps many contexts alive in one process, each of which has rendered once: the next context's render waited and failed, and the client saw a lost device after

G17 capacity refusal LowerVa count=...
GPU work of a client failed (EBUSY, ...); the client sees a lost device

Change

  • The reclaim of both capacity waits (a render refused room, and a compute command refused room for its pool) gets a batch with room for the render pools it gives back.
  • It runs only while the shared window is short: while it refuses a pool, or has no room left for one more. At other times a refusal of other capacity, such as no free render pair, takes no pool back.
  • Nothing changes until a submission is refused capacity while the window is short. Then every idle queue, of any client, gives its pool back and populates it again on its next render, as evicted clients' queues already do.
  • On M5 nothing changes: this reclaim does not run there.

Limit

More queues rendering at the same time than the window has room for still wait, for up to about 26 seconds, until one has been idle long enough for the firmware to release its pool (about 16 ms after its last render). The queue that waits can belong to any client. Handing pools over between busy queues in turn is a larger change and not part of this one.

Testing

  • One new KUnit case (a_reclaim_has_room_for_the_render_pools_it_gives_back). A full kernel build (Image, modules) with KUnit enabled compiles and links with this change; the case itself was not run.
  • The host test of the reclaim (tools/asahi/g17-shared-pool-tests.py) now also checks that both callers hand it the batch with room, and only while the window is short. The model part of that test already covered the reclaim with a batch that has room, which is why it did not catch this.
  • MacBook Neo, one boot of a test build with two test-only switches: one restores the old behaviour, one limits how many of the render pools created during the test may be populated, so that a few clients reach the limit.
    • One process running the GL conformance cases that keep many contexts alive (dEQP-EGL.functional.multicontext.*, dEQP-EGL.functional.image.render_multiple_contexts.*), limit of eight pools. Old behaviour: the ninth context's render was refused for 24 seconds, then the kernel logged the lost-device line above; no pool was given back. With the change: all 74 cases ran in about two seconds (20 passed, 54 not supported, none failed), the limit was reached 8 times, 67 pools were given back, and the kernel logged no lost-device line.
    • Vulkan conformance lists with the change on and a limit of one or two pools: two, three and four clients at once, one of them a ray-query stress. 201 more pools were given back; every case that ran to completion passed (the runner stops the ones still running when a run ends), and no client lost its device.
    • The machine's next boot logged no GPU driver warning or error.
    • The test build has the trigger of an earlier revision (only while the window refuses a pool). The second trigger, no room left for one more pool, was not exercised on hardware.

🤖 Generated with Claude Code

Every queue that renders has a render pool whose pages are mapped in an
address window that the pools of all clients share; the window has room
for about forty pools. A render that finds no room for its queue's pool
first asks idle queues to give theirs back, and only then waits: a queue
with nothing in flight, whose pool the firmware has released, populates
its pool again on its next render.

That request never returned a render pool. The reclaim hands the pages
it takes back to the caller's batch, which frees them after the device
lock is released, and it stops when the batch has no room; both callers
passed a batch created without room for render pool pages. Until now a
render pool was given back only when its queue was destroyed, or by the
event worker after its whole client had been idle and evicted under
memory pressure. A client that kept more queues with populated pools
than the window holds therefore got no room for one more, although the
others were idle: the render waited about 26 seconds and failed, and
the client saw a lost device after

  G17 capacity refusal LowerVa count=...
  GPU work of a client failed (EBUSY, ...)

Give the reclaim of both capacity waits a batch with room for the pools
it gives back, and run it only while the window is short: while it
refuses a pool, or has no room left for one more. At other times a
refusal of other capacity takes no pool back. On M5 nothing changes.

More queues rendering at the same time than the window has room for
still wait, for up to about 26 seconds, until one has been idle long
enough for the firmware to release its pool.

Signed-off-by: Diljit Singh <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant