Repository navigation
drm/asahi: g17: share per-VM UAT execution context on M5 - #4074
Conversation
Queues belonging to the same VM on M5 were each allocated a distinct UAT execution context ID because exec_share was gated off on M5. Because GPU caches are tagged by address and context ID, graphics-stage storage image writes into Gen10 losslessly compressed surfaces on one queue could leave dirty cache lines invisible to another queue of the same client even after fence synchronization, causing cross-queue image corruption. Enable per-VM execution context sharing on M5 as on G17P, and close three edge cases in exec_share: - Register newly created contexts via exec_share::offer() under the runtime state lock so concurrent queue creation on one VM cannot allocate multiple execution contexts. - Release the UAT root in exec_share::Use::drop() after unlocking SHARES when removing the last user, so a published queue whose sibling later drops without publishing cannot strand the shared root in an idle compute binding. - Match VM instance identity via Vm::same_as() in exec_share::join() so a rebound GPU instance starting its numeric VM counter at 2 cannot join a retained context from a previous instance. Signed-off-by: Erik Bourget <erik@ebourget.net>
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
RyanTheTide
left a comment
There was a problem hiding this comment.
Publishing the shared root under the device mutex closes the duplicate-creator window, and the binding identity prevents joining an unrelated VM with a matching number. The last-sharer path releases the root while scheduler holds still govern lifetime. The exact J716c multi-queue regression and teardown rows cover the fix, alongside the J713 control.
|
We take two rows at |
|
J714s (Apple M5 Pro / T6050 / G17S B1) verification on exact head Build & Boot Setup
1.
|
| Suite | Base (6985e45ab583) |
Head (6aee22f46165) |
|---|---|---|
10× write_image_fragment (2,014 cases/pass, 20,140 total) |
3 Fail (pass 3, 4, 6 — positive control) | 0 Fail (10/10 passes: 1,360 Pass / 654 NotSupported) |
Full dEQP-VK.synchronization.internally_synchronized_objects.multi_queue.* (12,807) |
— | 12,798 Pass / 9 NotSupported / 0 Fail (40.27s) |
Full dEQP-VK.synchronization2.internally_synchronized_objects.multi_queue.* (23,760) |
— | 16,680 Pass / 7,080 NotSupported / 0 Fail (52.88s) |
Combined full multi_queue (36,567) |
— | 29,478 Pass / 7,089 NotSupported / 0 Fail |
Base failing cases (all 128x128, _concurrent, matching #4069):
- Pass 3:
dEQP-VK.synchronization.op.multi_queue.binary_semaphore.write_image_fragment_read_image_compute_indirect.image_128x128_r16g16b16a16_uint_concurrent_maintenance9 - Pass 4:
dEQP-VK.synchronization2.op.multi_queue.fence.write_image_fragment_read_image_compute_indirect.image_128x128_r16g16b16a16_uint_concurrent - Pass 6:
dEQP-VK.synchronization2.op.multi_queue.binary_semaphore.write_image_fragment_read_image_compute.image_128x128_r8g8b8a8_unorm_concurrent
2. Concurrent Queue Create/Teardown Stress (head)
- 4 threads × 25 iterations = 100 devices across 3 queue families:
QUEUE_STRESS_PASS(0errors). /sys/kernel/debug/aurora-g17/capacitypre → post stress:crashed=0,online=1,logical_queues 3/58 → 3/58,render_slots 3/63 → 3/63,retired_render_bindings=0,leaked=0,unsettled=0,failures=0,scheduler_teardown pending=0.
3. GTA V Enhanced A/B (rtgen2n31rc24 6e9190bc5ecd, 2560×1440 Very High RT, FSR Quality, headless :0, Launcher-quiet)
| Arm | Mean FPS | 5-Pass FPS | TCMb Start → Max |
Busy MHz / Util | clamp_s / GPU Faults |
|---|---|---|---|---|---|
Base (6985e45ab583) |
71.491 | [62.753, 66.955, 70.371, 84.220, 73.156] |
58.66°C → 103.54°C |
1609.4 MHz / 97.35% |
0 / 0 |
Head (6aee22f46165) |
71.082 | [61.732, 67.140, 70.630, 82.390, 73.520] |
61.74°C → 105.18°C |
1609.3 MHz / 96.77% |
0 / 0 |
Delta -0.409 FPS (-0.57%) on single non-interleaved A/B with head starting +3.08°C warmer after 4.5 min of continuous CTS+stress (Passes 1, 2, 4 were +0.19 to +0.36 FPS faster on head; Pass 0 util 89.6% vs 99.4% and Pass 3 -1.83 FPS explain the mean delta, within the -0.534 FPS identical-binary warm drift measured across 54.0°C → 60.6°C). 0 GPU faults across both boots; clean handback to stock 7.3.0-m5-pr67 (boot_id=8225dbe8).
|
J700 (MacBook Neo, A18 Pro, T8140, G17P) at exact head Arms: module-only
No GPU fault or recovery, no stuck job, no wrong CRC, 0 leaked, 0 crashed on either arm. The same multi-queue lists passed on stock 7.3.0-41 today (0 Fail), so main's driver loses the device where the shipped one doesn't; that is being bisected separately. Not measured here: the M5 (T6050) half, game fps, and whether #4074 helps once main's own failure is out of the way. Evidence: base |
|
Merged at
Rows: J714s (G17S) pass, J716c (G17C) pass, J713 (G16G) pass, J700 (G17P) no difference between the arms. J700's queue churn and multi-queue CTS checks stop on main as well, so they say nothing about this change; that is a separate main problem. |
What: Enable per-VM shared UAT execution contexts (
exec_share) on M5 so all logical queues of one client share a single context ID, fixing cross-queue corruption of graphics-stage storage image writes into Gen10 losslessly compressed surfaces in Borealis without disabling M5 storage compression. Also fix threeexec_sharelifecycle edge cases (concurrent queue-creation race, last-sharerUse::droproot stranding, and numeric VM ID reuse across GPU instances).Tested: J716c (M5 Max, T6050, G17C) at
6aee22f46165: boots to desktop on default cmdline; 30 passes ofdEQP-VK.synchronization*.op.multi_queue.*write_image_fragment*(40,800/40,800pass, 0 fail vs 1–3 fails/pass onmain13dc5a79c0ec); fulldEQP-VK.synchronization.op.multi_queue.*+synchronization2.op.multi_queue.*(29,478/29,478pass, 0 fail, 0 GPU errors); 8×50 concurrent multi-queue render+compute teardown stress (0 fails, 0 leaked execution contexts). J713 (M4, T8132, G16G) at6aee22f46165: boots to desktop,dEQP-VK.synchronization.op.multi_queue.*12,798/12,798pass, 0 GPU errors. Host tests:337/337g17-*pass.Risk: two-way door · M5 (G17C/G17S/G17D) and G17P (A18 Pro, M4 Pro/Max); shared
mmu.rshelper compiled on all MacsNot yet: G17P (A18 Pro, M4 Pro/Max) hardware run (no G17P Mac in this lab).
Details
Problem
On M5,
g17/runtime.rsexcludeduat.is_m5()fromexec_share::join()andexec_share::offer(), so everyVkQueuecreated on the sameVkDevice(samedrm_asahiVM) received a distinct UAT execution context ID.Because GPU caches are tagged by address and context ID, graphics-stage (
vertex/fragment) storage image writes into Gen10 losslessly compressed surfaces on one queue could leave dirty lines invisible to a second queue of the same client even after CPU fence wait (vkWaitForFences) or semaphore synchronization. Single-queue runs passed 100%, while cross-queue fragment storage writes reliably failed 1–11 cases per pass in Vulkan CTS (dEQP-VK.synchronization*.op.multi_queue.*write_image_fragment*) and 19/300 iterations in a standalone 128×128R16G16B16A16_UINTreproducer under compute load.Changes
exec_shareon M5 (drivers/gpu/drm/asahi/g17/runtime.rs,context.rs,exec_share.rs): Remove the!uat.is_m5()exclusion so logical queues of one VM share a single UAT execution context ID and shared 63-bitWorkStatesclaim mask on M5 just as on G17P, while keeping separate per-queue scheduler pages, QoS slots, and work lists.drivers/gpu/drm/asahi/g17/runtime.rs): Moveexec_share::offer(vm, &execution)insideshared.state.lock()immediately afternew_execution_context()(callingexecution.release()ifofferfails), so concurrentDRM_ASAHI_QUEUE_CREATEcalls on the same VM cannot both missjoin()and allocate multiple execution contexts.drivers/gpu/drm/asahi/g17/exec_share.rs): InUse::drop(), calllast.release()after unlockingSHARESwhen removing the last counted sharer. Previously, if a published compute queue closed while a sibling still held the shared root and that sibling later dropped without publishing (or failed construction after joining),Use::drop()removed theSHARESentry without releasing the root, leaving the idle compute binding'sArc<Context>keeping the root current indefinitely.drivers/gpu/drm/asahi/mmu.rs,g17/exec_share.rs): AddVm::same_as(&self, other: &Vm) -> boolcomparingArc::ptr_eq(&self.binding, &other.binding)and use it inexec_share::join()so a rebound GPU instance restarting its numeric VM ID counter at 2 cannot join a retained context from a previous instance.Evidence
origin/main13dc5a79c0ec6aee22f46165tools/asahi/run-host-tests.py --only g17-):337/337 passed in 7sorigin/main13dc5a79c0ec) on J716c (M5 Max, Borealis Mesagit-75c936dc4a, M5 storage compression on):dEQP-VK.synchronization*.op.multi_queue.*write_image_fragment*(-j 6 --retry-runs 0): 2, 3, 2, 3, 0 failures per pass (10total failures across 6,800 supported runs).dEQP-VK.synchronization.op.multi_queue.*:12,797/12,798pass,1fail (binary_semaphore.write_image_fragment_read_copy_image_to_buffer.image_128x128_r8g8b8a8_unorm_concurrent:Memory contents don't match),9NotSupported.6aee22f46165on J716c (M5 Max, T6050, G17C, Borealis Mesagit-75c936dc4a, M5 storage compression on):/sys/kernel/debug/aurora-g17/capacity: confirmed 8 barrier-synchronized concurrent threads creating queues on 1 VM incrementedlogical_queuesby+8andexecution_contextsby+1(all sharing one context ID).dEQP-VK.synchronization*.op.multi_queue.*write_image_fragment*(2,014cases /1,360supported per pass,-j 6 --retry-runs 0): 40,800 / 40,800 pass, 0 fail, 0 crash, 0 DeviceLost, 0 dmesg lines (4s/pass).dEQP-VK.synchronization.op.multi_queue.*(12,807cases): 12,798 / 12,798 pass, 9 NotSupported, 0 fail, 0 crash, 0 dmesg lines (1m38s).dEQP-VK.synchronization2.op.multi_queue.*(23,760cases): 16,680 / 16,680 pass, 7,080 NotSupported, 0 fail, 0 crash, 0 dmesg lines (1m54s).400device lifetimes): 0 fails; post-stressaurora-g17/capacityshowedcrashed=0,logical_queues used=2,execution_contexts used=2,leaked=0,failures=0, 0 new dmesg GPU lines.6aee22f46165on J713 (M4, T8132, G16G):grub-reboottrial boot; Hyprland desktop up.dEQP-VK.synchronization.op.multi_queue.*(-j 3 --retry-runs 0): 12,798 / 12,798 pass, 9 NotSupported, 0 fail, 0 crash, 0 dmesg lines (1m06s).