Repository navigation
drm/asahi: g16: lease a TA/FS render queue pair to each rendering VM - #3352
Closed
DjDeveloperr wants to merge 4 commits into
Closed
DjDeveloperr wants to merge 4 commits into
DjDeveloperr wants to merge 4 commits into
Conversation
The TA and FS work images, the scene's own-TA wait and the FS finalize name the render queue's completion events. They were the literals 0x70 and 0x71 of the one TA/FS queue pair. Take them from RenderRefs::event instead, filled from work::render_pair::events(pair), which gives pair p the events 0x70 + 2p and 0x71 + 2p. The block 0x70..0x80 is bits 16..32 of type-1 event word 4, so it can name up to eight pairs. Every render still uses pair 0, so the encoded images are byte-identical and the render goldens are unchanged. Signed-off-by: DjDeveloperr <[email protected]>
Give the render side the structure the compute pipes got in 62e450e, so later renders can use more than one firmware TA/FS queue pair. RENDER_PAIRS stays 1 here, and every render still uses pair 0. - Graphs::render holds RENDER_PAIRS render graphs. Each pair has its own TA and FS qinfo, qstate, work ring, job list, stamps, notifier page and threshold. sched_ctx is shared, and the context still registers once, through pair 0's TA queue. - Pair p completes with events 0x70 + 2p and 0x71 + 2p. Events::drain decodes them from word 4. The stage cells (event times and the recovery snapshot) keep pair 0 at 0/1 and put pairs 1.. after the compute pipes. RetiredStamps keeps a TA and an FS history per pair. - Each pair numbers its stamps and thresholds with its own dense draw ordinal. The UMA counters and the work UUID keep the global one. - The engine keeps TA/FS targets, heads and registered flags per pair. A flight records its pair, and an fs2c barrier waits on the waited render's pair. - Retirement takes the oldest render flight of each pair. A later flight on the same pair makes the queue and stamp proof a "passed" one. Any other render flight or later record makes the proof on the shared TA/FS submit channels a "passed" one. - Progress is sampled per pair and renews the one render deadline. - Recovery maps a snapshot event to its pair and blames only that pair's flights, since dense per-pair stamps collide across pairs. With one pair every value and image is as before; the host suite covers the per-pair paths with two pairs in its mocks. Signed-off-by: DjDeveloperr <[email protected]>
A PB/UMA allocator slot or render pass slot passes to another owner only once it is displaced. After its last render retires, a slot stays the TA and FS engines' current one until they run a render of another slot. Both ledgers inferred that from the order in which retirements were observed: the PB pool from the last cleanly retired slot, and the pass ledger from a later publication retired on the same queue. That holds while every render runs on one TA/FS queue pair, because the pair retires in publication order. Renders on different queue pairs are observed retiring out of publication order, so the observed order says nothing about which render the engines ran last. Decide by the publication sequence instead: - Pools::publish_flight returns the render's sequence, and retire_flight takes it back. A clean retirement displaces every other slot whose newest render was published before it. - The render pass ledger has ordered pipes: a later publication that retired displaces an owner whatever pair it ran on. Each pair still retires its own owners in order, and pass slots are published on their flight's pair. The compute ledger keeps per-pipe displacement. This relies on renders running on the TA and FS engines in publication order. With the one pair in use, both rules decide exactly as before. Signed-off-by: DjDeveloperr <[email protected]>
Every VM's renders shared one firmware TA/FS queue pair. While two VMs' passes are published on one pair, the GPU faults in the one whose pass runs (linux#3201), so a render of another VM drained the engine first (8722b2e). That serialized multi-process rendering: gpubench render.light with 2 to 16 processes took about 127 µs per frame against Metal's 104 µs. macOS 26B123 gives every Metal process its own TA and FS queue, each with its own job-list entry, all rung through one doorbell. Lease one of RENDER_PAIRS = 8 pairs to each rendering VM instead. The completion-event block 0x70..0x80 names eight pairs, so a compositor and seven clients render without a handoff. Each pair costs fourteen 16 KiB pages at probe. A pair registers with the firmware on its first record, and a VM takes the lowest free pair, so unused pairs stay unregistered. - Leasing. A VM keeps the pair of its renders in flight, so its render waits never leave one in-order pair. Otherwise it takes its last pair if free, else the lowest free pair. Two VMs' renders are never in flight on one pair (cross_vm_render_conflict). - Handoff. When every pair holds another VM's renders, the pair with the fewest passes in flight drains for the waiting render, as compute_handoff_pipe drains a compute pipe, and the other pairs keep running. This replaces the full engine drain. - Render vs another VM's compute still drains, in both directions, and so does any InitBM flight. - Stage order. A prefix's first pass waits for the TA and FS of the newest render in flight when that render is on another pair. Renders so reach the TA and FS engines in publication order, as on one pair, which the PB and pass slot displacement proofs rely on. That render's completion implies every earlier one's, so these waits take the place of the pair's own prev_barrier and fs_dep, and a pass still takes at most MAX_RENDER_RING_ENTRIES entries per ring. One VM's TA still overlaps another VM's FS. Since a pair can wait on another, the pairs keep one render deadline. - Shared submit channels. Like the compute pipes on Channel::Compute, TA/FS channel receipts are latched before another pair's records can lap a long flight, and no record is posted that would lap an unlatched one. - aurora-g16/stats gains "render_pairs: publications <per pair> cross_pair <n>": the renders published on each pair, and those published while another VM's renders were in flight on another pair. A prototype with two pairs and per-VM pairs ran on the J773g with no GPU fault or recovery. render.light procs d2/d4/d8/d16 went from 126.9, 126.6, 127.4 and 128.8 µs to 105.6, 100.9, 102.4 and 102.7 µs; single-VM rows were unchanged. The stage-order barriers and the eight pairs are new here. Signed-off-by: DjDeveloperr <[email protected]>
This was referenced Nov 27, 2026
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.
Draft, for an early design review. It stacks on the linux#3201 fix (
fix/g16-cross-vm-render-drain-stack, which waits on #3180 and #3185) and carries only these 4 commits. Hardware gates are still running.What: on the g16 backend, each VM that renders leases its own firmware TA/FS queue pair, the way compute already leases per-VM workqueues (62e450e). Renders of different VMs then overlap again without sharing one queue.
Design:
RenderRefs. A render's completion events travel inRenderRefs. Pairpuses TA0x70 + 2pand FS0x71 + 2p. Pair 0 keeps 0x70/0x71, so the render goldens don't change.RENDER_PAIRS = 1and changes no behaviour.compute_handoff_pipe.prev_barrierandfs_dep, so a pass still uses at most 5 ring entries.render_pairs:line counts publications per pair and cross-pair overlaps.Tested:
38dbbc32, one boot):03afc089compiles on the J773g. Its first boot, with the linux#3201 lists, drm/asahi: g16: keep renders of a multisampling VM apart from other VMs #3180's hot list and the procs rows, is queued.Risk: two-way door.
Not yet: