Skip to content

drm/asahi: g13: defer freeing a completed command until its stamps land - #1828

Merged
DjDeveloperr merged 1 commit into
integration/aurorafrom
gpu/m1pro-g13-cts-hang
Nov 13, 2026
Merged

DjDeveloperr merged 1 commit into
integration/aurorafrom
gpu/m1pro-g13-cts-hang

Conversation

@RyanTheTide

Copy link
Copy Markdown
Contributor

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 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. But 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, 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 BufferManager slot and
caps user queues at 127. The G17 path re-fixed the same class with its
stamps_owed hold-until-covered logic (#1823); the G13 legacy path was left
exposed after the revert.

Fix

Reinstate the deferred free, bounded so it does not reintroduce the 127-queue
limit:

  • Hold the most recently drained completed command and release 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.
  • Release the held command at queue idle (pending empty and no pending jobs):
    that completion was signalled by the last command's RetireStamp (the final
    microsequence 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::drop flushes the held command as the queue's firmware
    context is invalidated; fail_all drops it with the rest once the GPU dies.

Testing

  • Targeted drivers/gpu/drm/asahi/ build (ARCH=arm64, LLVM=1, W=1): clean, no
    new warnings.
  • Long Vulkan CTS soak on M1 Pro (J314/J316): pending hardware slot. Will update
    with results before merge.

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]>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

M2 (t8112, G14G) hardware qual — FULL Vulkan mustpass: PASS, 0 GPU-firmware crashes

This change also covers the M2's G14G legacy-retirement path. Proven on an M2 with a one-shot test kernel 7.3.0-aurora-g13df1 (production fleet72 + this PR), booted non-default with a dead-man, SELinux Enforcing throughout, then restored to the fleet72 default and the test kernel removed.

Vulkan CTS 1.4.7.0 full mustpass (asahi/honeykrisp, ov-h2):

  • chunks: 246/246
  • cases: 1,470,718 → Pass 456,648, NotSupported 1,014,070
  • 0 Fail / Crash / Timeout (Pass + NotSupported = total)
  • fwcrash=0, gputimeout=0
  • triage: 0 non-pass, 0 untriaged real failures

GPU-firmware wedge check (the regression this PR targets):

  • co-processor has crashed this boot: 0 (before and after the full soak)
  • no AGX/RTKit faults or channel timeouts during CTS (the only asahi/RTKit log lines were DCP display-controller init messages at boot)
  • ran ~33 min of sustained Vulkan CTS on the fixed kernel with no deferred-free wedge

Matches the M1 Pro result on the same g13df1 kernel. The deferred-free fix holds on the M2 GPU firmware under sustained Vulkan CTS.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Full Vulkan CTS mustpass on M1 Pro (Apple G13S / T6000) with this PR applied — 0 GPU firmware crashes.

Proof kernel 7.3.0-aurora-fleet72 + this PR's single drm/asahi commit only (matched CLANG/LLVM + rustc toolchain, SELinux enforcing), Mesa overlay from aurora-wip. One-shot boot, user-space run, then back to the stock kernel.

vulkan-cts-1.4.7.0, 4 parallel jobs, full mustpass:

metric value
chunks 246 / 246
cases 1,470,718
Pass 456,646
NotSupported 1,014,071
Fail 1
firmware "co-processor has crashed" 0

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):

  • 1 Fail — dEQP-VK.api.copy_and_blit.copy_commands2.blit_image.all_formats.color.3d.b10g11r11_ufloat_pack32.b10g11r11_ufloat_pack32.general_general_linear_stripes_y (a userspace blit format/precision case).
  • 1 recoverable GPU timeout early in the run (kernel log: unit dPM, address 0x0, Timeout count: 0); the driver recovered and all remaining chunks completed (harness attributed 2 affected cases to the single reset).

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants