Repository navigation
drm/asahi: g16: lease a TA/FS render queue pair to each rendering VM - #3355
DjDeveloperr wants to merge 7 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]>
…r-pairs-on-3201 Stack this series on #3370 (linux#3349: cross-engine barriers wait on the producer's service stamp, one accessor per service-stamp cell). With per-VM render pairs every pair has its own render graph, so a compute's barrier on a render waits on the FS service stamp of the waited render's pair, and retirement reads each pair's TA and FS service stamps through that pair's accessors. Signed-off-by: DjDeveloperr <[email protected]>
The comment over the render barriers said G16 FINALIZE flushes producer caches before fw_stamp advances. linux#3349 showed that it does not make a producer's writes visible to another firmware queue, and the merged service-stamp change makes every cross-engine wait use the service stamp. The render->render waits that stay on fw_stamp only order the TA and FS engines across pairs, which is what the displacement proofs need. Comment only. Signed-off-by: DjDeveloperr <[email protected]>
Document the visibility boundary of the stage-order waits and remove the unused aggregate receipt check. The active retirement path checks the rings and channels separately. Signed-off-by: DjDeveloperr <[email protected]>
|
J516s (M3 Pro, G15S) at Per-VM render pairs recovered most of the cross-process render cost on this Mac. The exact-head kernel booted with zero failed units. The two timing passes used the same native gpubench-vk binary and isolated Mesa Median µs per submit across two passes, lower is faster.
On this head, 1080p MSAA4 postfx procs d1/2/4 measured 998.8 / 732.6 / 799.2 µs. The remaining render.light procs depths d2/8 measured 79.5 / 61.8 µs, queue d16 measured 38.3 µs, and compute.light procs d4/16 measured 30.6 / 27.8 µs. All eight render pairs carried work. Effective clocks reached S8 (1,380 MHz) in 1,766 of 1,913 busy samples. Earlier #3353 row · Earlier #3370 row With one CTS worker and two busy CPU loops, all 238,015 case executions completed. Each of the three multi-queue runs had 29,484 pass and 7,089 unsupported. Each of the two cross-instance runs had 20,008 pass and 42,604 unsupported. All 1,024 implicit cases passed on each of three runs. Zero failures or missing results. The concurrent render.light procs d16 and 1080p MSAA4 postfx procs d4 stress ran 603 seconds. Each completed 138 runs, all 276 returned valid results, and their under-load medians were 367.8 and 4,705.9 µs per submit. The candidate boot recorded zero GPU faults, SErrors, recoveries, or hang kills across timing, CTS, and stress. |
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
There was a problem hiding this comment.
Superseded 12-01: not a hold under the merge bar (no shown failure). Full diff review deferred; follow-ups: land #3370/#3353/#3185, retarget, main CI
Verdict: HOLD at a67f388a
Blockers:
- Targets open non-
mainbase branchfix/g16-3349-compute-service-stamp(#3370, stacked on#3353and#3185); fullmainCI has not run.
Checked:
- Verified
#3370,#3353, and#3185are stillOPEN. - Deferred full diff review until parent PRs land and this PR is retargeted onto
mainwith green CI.
Evidence
- Base ref:
fix/g16-3349-compute-service-stamp(#3370state:OPEN).
Stacked on #3370 (which is on #3353). The four implementation commits are followed by the merge of #3370 and two cleanup commits.
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 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.render_pairs:line counts publications per pair and cross-pair overlaps.Tested: J773g (M4 Mac mini, macOS 26B123 firmware), on
a69f447171c8. Since that boot,a67f388a9ae4clarifies stage order and cross-VM drains, removes an unused receipt helper, checks its two live components directly in the host fixture, and compiles a single-pipe convenience method only in tests. The executed driver paths are identical.Cost against Metal: µs per submit, lower is better. Each kernel was measured on its own boot, median of 2 passes, with 0 GPU faults on every boot. Metal 4 values are native macOS 26B123.
Correctness under CPU load, with 2 busy loops beside every list, one boot:
dEQP-VK.synchronization*multi_queue*dEQP-VK.synchronization*.cross_instance.*(two VMs, so cross-pair waits; 11,384 dma_buf cases)api.copy_and_blitblit_image RGBA8/BGRA8dEQP-VK.synchronization*.implicit.*0 GPU faults on the boot.
J516s (M3 Pro, G15S) on
a69f447171c8, two passes with Mesa69179743d9ae. Compared with drm/asahi: g16: wait for the service stamp in cross-engine barriers #3370, render.light procs d4 went from 119.9 to 66.7 µs and d16 from 126.5 to 61.5 µs. The 1440p MSAA1 postfx procs d4 row went from 2,547.8 to 1,290.3 µs. All eight render pairs carried work. The multi-queue, cross-instance and implicit synchronization lists recorded 29,484, 20,008 and 1,024 passes respectively, with zero failures.Host: at
a67f388a9ae4, all 26 asahi-m4 host selftest files passed. Strict checkpatch reported zero errors, warnings and checks on the complete diff against drm/asahi: g16: wait for the service stamp in cross-engine barriers #3370.Risk: two-way · M4 and M3 Macs on the g16 backend.
Not yet: