Repository navigation
drm/asahi: g16: let the firmware unbind a drained compute UMA manager - #4198
Conversation
Commit ebc3b14 ("drm/asahi: g16: keep compute UMA managers bound and ASC-cached") kept each VM's compute UMA manager bound between its jobs, by publishing a submission counter one past the submissions. The firmware saves and unbinds a manager only when a command finishes with COMPLETED equal to that counter, so a drained manager stayed bound in its hardware slot after its VM went idle or away. The slot's next user, such as a private shader-context scratch (SCS) unit of another VM, then displaced it without a save. On the J773g, several Vulkan processes then hit GPU recoveries: 21 in two runs, every one with event 0xf (compute pipe 0, which all SCS compute uses). Where a fault was latched, the GPU had read the base compute freelist at compute_state(0) in the context of the one job in flight, whose VM doesn't map it. The parent of that change's merge had 0 recoveries. Publish the submission count itself, as before that commit and as macOS 26B123 does (an idle manager's counter equals COMPLETED). A manager with a later command queued still stays bound, and the ASC-cached slot records stay. Fixes: ebc3b14 ("drm/asahi: g16: keep compute UMA managers bound and ASC-cached") Signed-off-by: DjDeveloperr <hey@djdev.me>
|
J773g (Apple Mac mini M4, T8132, G16G B0, os-fw 27.2, 24 GB RAM, kernel
Cause (linux#3707 recovery repro): CAUSE PASS
Performance (
|
DjDeveloperr
left a comment
There was a problem hiding this comment.
Independent review of b0426e1e278d by a reviewing agent that didn't write it. No code blocker. One row left before merge: J516s.
What it does. *counter goes back to the submission count, the protocol main had before #3695, while #3695's cached records stay. A drained shared manager is saved and unbound by the firmware with its last command, so it can't be left bound after its VM is idle or gone.
Checked
- Order against work in flight. The counter is written once per flight, before
wmb(), the WRITE and the doorbell. If a new flight is published while the last command of an older one completes, the firmware either sees the new count and keeps the manager bound, or saves it and later reloads the same record, which the host leaves alone (bind_compute_umareturns the live record and writes nothing). Both are safe. COMPLETED counts completions (init_recordlines it up with the next submission), so flights that finish out of order across pipes save the manager only after the last one. - If the firmware never saves. Nothing new waits on the firmware. The host takes the slot back on the service stamp, as before. A firmware that didn't save would leave the slot as it is on main today, so it is never worse. A hung command still goes through recovery, and aborted flights still keep their slot quarantined with their commands counted.
- Locking. No new shared state. Everything changed runs under the engine's
&mut self, as before. Retirement now writes nothing, which removes the only error path it had (a failed counter write ended in a fail-stop). - Idle power-off. Unchanged: idle passes still invalidate and rebuild. That is now only a precaution, since the firmware also saved the cursors.
- Forbidden patterns. No runtime switch and no SoC gate. No new constant: the change removes a
+ 1and its overflow check.
Hardware. The J773g arm used this head's diff of the four driver files, byte for byte. The repro recovered on the stock module and ran clean on two boots with the change. No row got slower, and the procs d8/d16 cost (5.2 % and 7.2 %) is under the 15 % gate (receipt above). On main after #4185 (5bb2f1eed073) the diff merges cleanly with the same patch-id (tree 9370a502e313).
Local checks on that merge (pc, hosted-CI image, no network): asahi-m4 26 of 26 scripts (test-resources 100 passed), g16 2 of 2, g15 19 of 19, m3-recovery 2 of 2. arm64 LLVM=1 W=1 drivers/gpu/drm/asahi/ with G15 and G16 on builds with the same 38 warnings as main. checkpatch --strict is clean apart from the commit-id lookup.
Left before merge
- A J516s (T6030) row. The body lists it, and the g16 backend is shared. The save at drain on top of cached records has run only on T8132 firmware. Run it on main
5bb2f1eed073+ this head, which also covers #4185 together with this change: gpubench compute rows plus a multi-process compute/ray-query CTS mix, 0 recoveries, 0 failed cases,compute_umarebuilds and reseeds inaurora-g16/stats.
Small note, not pushed so the tested head stays the same: g16/sleep.rs:92 still says "every UMA manager left bound". After this change, a manager is left bound only while its commands run.
|
J516s (M3 Pro, T6030, G15S B1, 18 active GPU cores, OS firmware Covers
Arm B functional & stress results:
Paired
|
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
|
Additional J773g (
|
What: Let the firmware unbind a compute UMA manager once its last command completes, instead of keeping it bound while its VM is idle or gone. This is the most likely cause of the J773g GPU recoveries with several Vulkan processes (linux#3707).
Tested: J773g (M4 mini, T8132), module-only arm with this head's driver diff: the linux#3707 repro recovered on the stock module and ran clean on two boots with this change, 0 recoveries and 0 failed cases over gpubench, the repro kit and the 4-process mix (27,496 cases per boot). ABBA performance: no row slower; #3695's own
compute.lightprocs rows cost 5.2 % (d8) and 7.2 % (d16) (row). Host tests and the arm64 W=1 build ofdrivers/gpu/drm/asahi/pass on the merge with main5bb2f1eed073(Evidence).Risk: two-way · M4 (T8132) and M3 (T8122, T6030), which share the g16 backend. It gives back part of #3695's gain on
compute.lightprocs (8 to 12 % with its hold and cached records together); the cached records stay. A plain revert undoes it.Not yet: a J516s (M3 Pro, T6030) row. The g16 backend is shared, and the firmware's save at drain on top of #3695's cached records has run only on the J773g.
Details
#3695 publishes
*counter = submissions + 1while a VM's shared compute UMA manager has commands in flight, so the firmware doesn't save and unbind the manager when a command completes. When the last one retires the host writes the counter back, but no command completes after that, so the firmware never unbinds it. The manager stays bound in its hardware slot (1 of 32), also after its VM closed.Two kinds of user share those slots:
pick_scs_compute_slots()).By the code's own note, binding a manager loads the incoming record only and never saves the outgoing one (
UmaBoundinslots.rs). Before #3695 the outgoing one was always saved and unbound first, because a drained manager hadCOMPLETED == *counter. The host only checked that no shared command was in flight in the slot (compute_uma_private_ready()), and that stays true with a manager left bound.*counteris now the submission count again. A later queued command still keeps the manager bound. The rest of #3695 and #3699 is unchanged: ASC-cached device-lifetime slot records, residency tracking, and rebuild without a reseed.macOS 26B123 keeps
*counter == COMPLETEDon idle managers: the procs-d8 snapshot that #3695 quotes shows it for all eight. No capture shows it one past the submissions.Evidence
Hardware arm: this head's diff of the four driver files, byte for byte, applied to the source of the kernel the J773g runs (
7.3.0-j773g-main3685+);aurora.kobuild ID7132c4cb.Merge with main
5bb2f1eed073(after #4185; tree9370a502e313): this head's diff applies with the same patch-id. Hosted-CI image, no network:asahi-m4/run-host-tests.py26 of 26 scripts (test-resources100 passed),--only g162 of 2,--only g1519 of 19,--only m3-recovery2 of 2. arm64LLVM=1 W=1 drivers/gpu/drm/asahi/(G15 and G16 on, clang 23, rustc 1.100) builds with the same 38 warnings as main.checkpatch.pl --strict: 0 errors, 0 checks; its 2 warnings are the commit idebc3b149b8ec, which a tree without git can't look up (it is on main).All on the J773g (M4 mini, G16G), several
deqp-vkprocesses at once.8ec8740a1e6f+ display/PCIe PRs786a426ecae9+ PRs outside asahif7e3388dd07d+ #3685Between
8ec8740a1e6fand the two recovering kernels, the only change indrivers/gpu/drm/asahi/g16is drm/asahi: g16: keep compute UMA managers bound and ASC-cached #3695 and drm/asahi: g16: rebuild a drained compute UMA manager without reseeding its pool #3699.All 21 recoveries have event 0xf, which is compute pipe 0. SCS compute only runs there; other compute spreads over 8 pipes (events 15 to 22). So the job that timed out was on the ray tracing pipe.
Every one has one flight in flight. 15 have all fault banks zero: the job timed out, it didn't fault.
The other 6 latched the same two faults,
va 0x7003000c00and0x7003000b80(read unmapped), in the context of the live VM whose job was the one in flight. That is freelist lines 24 and 23 ofcompute_state(0), the shared manager's freelist. A VM that has only SCS compute maps nothing there. So the GPU used a shared manager's freelist while a VM without a shared manager ran, as if the slot still held the old allocator state.The first recovery came with the first mix of ray-tracing-stage and other cases. The ray query / ray tracing pipeline chunks before it (38 of them) had none, and first cases lost were
dEQP-VK.subgroups.*.ray_tracing.*.One process is enough: a clean boot running one
deqp-vkprocess ofray_querycases recovered the same way (event 0xf, all banks zero, 2 flights). The ray tracing units always take slots 1 and 2, and a VM's manager takes the next slot in turn from a device-wide counter, so on a fresh boot the first VMs' managers sit there too. Nothing in the host's check stops a private unit from binding over that manager in the same VM or the next device of the same process.Not shown yet: that this change alone removes the recoveries, and which job exactly displaced which manager.