Repository navigation
drm/asahi: g13: defer freeing a completed command until its stamps land - #1828
Conversation
On the G13 legacy path a render/compute command retires in WorkQueue::signal()
the instant the driver-visible stamp (the shared Stamp read by the event poll)
reaches the command's completion value: its descriptor GpuObject is handed to
the cleanup workqueue and its memory returns to the allocator for reuse. The
pass stamp is no witness that the firmware is done with the descriptor. The
firmware stores a command's completion stamps (fw_stamp and the final
RetireStamp) through the microsequence embedded in that descriptor, and keeps
touching the descriptor after the driver observes the stamp. Under sustained
load the driver observes a coalesced stamp that has jumped past several
commands, so the last command it drains can still have its firmware tail in
flight. Once that descriptor is freed and reused, the firmware stores through a
stale/reused target and faults with a non-canonical pointer, wedging the GPU.
This reproduces on a J314/J316 (M1 Pro, G13S) after 60-190 chunks of sustained
Vulkan CTS, and matches the observed firmware data abort (FAR 0x8e28...).
This is the bug that commit 513cd1502fb9 ("drm/asahi: workqueue: Defer freeing
the last completed work item") fixed; it was reverted in 83526ea only
because keeping a completed work item per queue pins a BufferManager slot and so
caps user queues at 127. The G17 path re-fixed the same class with its
stamps_owed hold-until-covered logic; the G13 legacy path was left exposed.
Reinstate the deferred free, but release the held command at queue idle. Hold
the most recently drained command and enqueue the previously held one: commands
retire in order, so observing a strictly-later command's stamp proves the held
one's firmware tail has run. When the queue goes idle (pending empty and no
pending jobs) the completion was signalled by the last command's RetireStamp, so
the firmware is done with every retired descriptor; release the held command
there instead of pinning its slot until the next submission. This keeps at most
one extra command (released promptly) alive per active queue and does not
reintroduce the 127-queue limit. WorkQueueInner::drop flushes the held command
as the queue's firmware context is invalidated, and fail_all drops it with the
rest once the GPU has died.
Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
M2 (t8112, G14G) hardware qual — FULL Vulkan mustpass: PASS, 0 GPU-firmware crashesThis change also covers the M2's G14G legacy-retirement path. Proven on an M2 with a one-shot test kernel Vulkan CTS 1.4.7.0 full mustpass (asahi/honeykrisp, ov-h2):
GPU-firmware wedge check (the regression this PR targets):
Matches the M1 Pro result on the same |
|
Full Vulkan CTS mustpass on M1 Pro (Apple G13S / T6000) with this PR applied — 0 GPU firmware crashes. Proof kernel vulkan-cts-1.4.7.0, 4 parallel jobs, full mustpass:
The run completed cleanly through the entire chunk 60–190 window that reproduces the firmware wedge on the unpatched kernel: zero firmware co-processor crashes, kernel stayed up the whole run, 0 failed systemd units, restored normally afterward. Non-fatal items (neither is a GPU hang / unrelated to this kernel change):
|
DjDeveloperr
left a comment
There was a problem hiding this comment.
Approve: holding the last drained command until a later stamp or queue idle bounds the extra lifetime to one command per queue, and the drop/fail_all paths release it. WorkQueue::ver is only built for the G13/G14 GpuManager, so the G17 runtime is untouched. The two full mustpass runs (M1 Pro, M2) with 0 firmware crashes cover it.
Problem
On the G13 legacy path (Apple M1 Pro, T6000/G13S), the GPU firmware stops
responding after sustained Vulkan CTS (~60-190 chunks), occasionally with a
firmware data abort through a non-canonical pointer (FAR 0x8e28...).
WorkQueue::signal()retires a render/compute command the instant thedriver-visible stamp (the shared
Stampread by the event poll) reaches thecommand's completion value: its descriptor
GpuObjectis handed to the cleanupworkqueue and its memory returns to the allocator for reuse. But the firmware
stores a command's completion stamps (
fw_stampand the finalRetireStamp)through the microsequence embedded in that descriptor, and keeps touching
the descriptor after the driver observes the stamp. Under sustained load the
driver observes a coalesced stamp that has jumped past several commands, so the
last command it drains can still have its firmware tail in flight. Once that
descriptor is freed and reused, the firmware stores through a stale/reused
target and faults, wedging the GPU.
This is the bug that commit 513cd1502fb9 ("drm/asahi: workqueue: Defer freeing
the last completed work item") fixed; it was reverted in 83526ea only
because keeping a completed work item per queue pins a
BufferManagerslot andcaps user queues at 127. The G17 path re-fixed the same class with its
stamps_owedhold-until-covered logic (#1823); the G13 legacy path was leftexposed after the revert.
Fix
Reinstate the deferred free, bounded so it does not reintroduce the 127-queue
limit:
held one. Commands retire in order, so observing a strictly-later command's
stamp proves the held one's firmware tail has run.
pendingempty and no pending jobs):that completion was signalled by the last command's
RetireStamp(the finalmicrosequence op), so the firmware is done with every retired descriptor.
Releasing it there frees the slot instead of pinning it until the next
submission. This keeps at most one extra command alive per active queue,
released promptly.
WorkQueueInner::dropflushes the held command as the queue's firmwarecontext is invalidated;
fail_alldrops it with the rest once the GPU dies.Testing
drivers/gpu/drm/asahi/build (ARCH=arm64, LLVM=1, W=1): clean, nonew warnings.
with results before merge.