Repository navigation
drm/asahi: g16: bind a VM to its TTBAT slot with its first queue - #4077
Merged
Merged
Conversation
A user VM takes one of the 63 TTBAT slots when it is created and keeps it until its last firmware lease goes. A Vulkan client creates two VMs: its physical device's, which never gets a queue, and its logical device's. So the slots run out at half as many clients as the contexts could serve. Slots are short to begin with. The newest retired compute owner of every pipe, the newest render owner, and the owner epoch of every PB slot keep their VM bound after its client exits, until a later publication displaces them. With eight compute pipes and twenty PB slots that is up to 29 slots of clients that are gone. On a J773g desktop with gpubench compute.light procs running, 21 of the 63 slots were held like that and 9 by the desktop, which left room for 16 Vulkan processes and nothing more. With the sixteen pipes of linux#3340, 29 were, and VM_CREATE failed with ENOSPC. Those leases have to stay: releasing a closed VM's PB epoch early let the parameter manager write through a reused context (047b934). But only the jobs of a queue run in a VM's context, so a VM without one needs no slot. Keep it unbound in the registry and bind it when its first queue is created. Its root is named by the TTBAT only then, with every mapping made before it already visible to the walker. Slots stay exclusive and are reserved before they are bound, as before, so a leased slot is still never handed out again and the slot allocator never waits. A failed binding leaves the VM unbound for another try. The per-file limit of eight VMs still counts every VM, bound or not. The device limit and the per-process share count bound VMs, so running out of slots is now ENOSPC from QUEUE_CREATE rather than from VM_CREATE. The fail-stop path also latches its error on unbound VMs. test-vm-slots.py runs the production VM and queue creation against a model of the slots, with the pipe and PB slot counts of hw.rs: every lease held by an exited client, the desktop, then sixteen Vulkan processes. Without this change the thirteenth process fails there, and the ninth with sixteen pipes. Signed-off-by: DjDeveloperr <hey@djdev.me>
Registry::reserve() takes a TTBAT slot for a VM's first queue and no longer counts the VM against its file. Reserve without a file; the file limit is covered by the asahi-m4 selftest test-vm-registry.py. Signed-off-by: DjDeveloperr <hey@djdev.me>
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
RyanTheTide
approved these changes
Dec 3, 2026
RyanTheTide
left a comment
Contributor
There was a problem hiding this comment.
The idle and bound paths preserve the file quota and existing firmware lease lifetime. Binding is serialized, a failed bind leaves the idle entry available for retry, and close during publication is handled. The host case exercises the slot pressure reported on J773g. The hardware row is still pending.
This was referenced Dec 3, 2026
Contributor
Author
|
J773g row at What
Tested
Risk
Not yet
|
Contributor
Author
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.
What: bind a G16 VM to its TTBAT slot when its first queue is created, not when the VM is.
There are 63 slots and a VM used to keep one from VM_CREATE until its last firmware lease went. A Vulkan client creates two VMs: the physical device's (
hk_physical_device.c, never gets a queue) and the logical device's. Only a queue's jobs run in a VM's context, so the first one needs no slot.Slots are also short because the newest retired compute owner of every pipe, the newest render owner and the owner epoch of every PB slot keep their VM bound after its client exits: up to 8 + 1 + 20 = 29 on main. On J773g in the #3340 row,
vm_bindingsshowed 30 bound VMs for 9 open handles on main and 38 for 9 with #3340's 16 pipes, where VM_CREATE failed with ENOSPC. Those leases stay. Releasing a closed VM's PB epoch early faulted before (047b934ce47a), and nothing here shortens a lease.Registrykeeps VMs without a queue unbound (IdleVm);vm::lookup()binds one for its first queue, once, under a mutex. A failed binding leaves the VM unbound for another try, and a VM closed meanwhile keeps nothing.Tested:
asahi-m4/test-vm-slots.pyruns the production VM and queue creation withhw.rs's pipe and PB slot counts: every lease held by an exited client, 9 desktop VMs, then 16 Vulkan processes. It fails on main (13th process, errno 28, 63 slots in use) and on drm/asahi: g16: widen compute concurrency to 64/16 and cache shared UMA and fw_stamp #3340 ateb8c98e615c0(9th process), and passes here. It also checks that a leased slot isn't reused until its last owner goes, one binding for all queues of a VM, a failed binding, a close during the binding, the file quota and fail-stop.tools/asahi/run-host-tests.py --only asahi-m4passes (all scripts,test-resources.py84/84),--only g162/2 with 3/3 mutants killed.W=1build ofdrivers/gpu/drm/asahi/: no errors; the only warning invm.rsis main'sfetch_updatedeprecation (rustc 1.100.1). checkpatch--strictclean except the MAINTAINERS reminder for the new file, which the directory's entry covers.Risk: two-way · Macs on the g16 backend (T8132; T6030 and T8122). A plain revert undoes it.
vkCreateDevice.Not yet: J773g and J516s rows. KUnit. T8122 has no row.