Skip to content

drm/asahi: grow a TVB buffer only while the firmware is not using it - #2468

Merged
DjDeveloperr merged 4 commits into
integration/aurorafrom
gpu/g13-tvb-grow-idle
Nov 20, 2026
Merged

DjDeveloperr merged 4 commits into
integration/aurorafrom
gpu/g13-tvb-grow-idle

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Problem

On the M1 Pro (G13S, two GPU clusters), several short-lived GPU clients rendering at once make the tiler write to
VA 0 (TE, VCE or dPM "Unmapped" fault at address 0x0, then a GPU timeout and a failed job). This is the transient
3D blit CTS failure on G13S.

The cause is TVB growth while the buffer is in use. A fresh client's TVB starts at 8 blocks, and a clustered
layered render needs 7 + 2 * layers blocks, so a 3D blit grows the buffer on almost every pass while the
previous pass on the same buffer is still running. Growing appends blocks to the live block list, and the render
then sends an InitBuffer for the bound buffer-manager slot, both while the firmware owns the buffer.
ensure_blocks() already holds back the page count in that case, but nothing else.

Change

Size the TVB for every render of a submission before any of it is published, and only once no earlier render of
the queue can still use the buffer:

  • get_tiling_params() now validates the render's flags and size, so the sizing pass (which runs before
    submit_render()) rejects a zero-sized render with EINVAL instead of overflowing.
  • The queue tracks the finished fences of its submissions that contain a render. A grow waits for every render up
    to the newest one that completed without error (renders complete in order on the fragment queue; a failed one
    proves nothing about the ones before it).
  • The wait is interruptible (ERESTARTSYS) with no fixed limit, and runs before the job, its VM binding or its
    fence exist, so the ioctl restarts cleanly.
  • The size the overflow statistics ask for is folded into the required size, so busy, GPU-bound clients still grow
    (one wait per 3x step). The statistics are reset only once the buffer grew.
  • The slot re-initialisation stays pending on the queue until a job with a render has been pushed, so a submission
    that fails after a grow does not lose it.
  • Each grow is logged under TVBStats (old and new size, what asked for it).
  • A render that fails in run() keeps the buffer owned when some of its commands may have reached the firmware
    (marked published before the first run_job()): it stays in the set until a later clean completion, and a grow
    that meets it fails with ECANCELED. A render that carried the slot init and failed before publishing reports the
    init lost; renders relying on it fail with ECANCELED before publishing and the next submission re-initialises.

Testing

Head 2077fde, whole kernel 7.3.0-aurora-pr2468fix2 (same config/toolchain):

  • render churn, 30 runs each: M1 Pro 19 completed + 11 aborted by the drm/asahi: G13S GPU firmware crash after DestroyContext under client churn #2506 firmware crash, M2 27 + 3; 0 VA-0
    faults, 0 GPU timeouts on both. M2 same-kernel module A/B 3d6b26b vs 2077fde: 1/20 aborts each.
  • zero/oversized/unknown-flag renders 6/6 EINVAL (M2); KUnit asahi 347 passed, 2 skipped (5 new cases); clippy 0.
  • test-only fault injection (renders that carry the slot init fail run() before publishing), M2: 161 drops, 28
    renders cancelled, re-init each time, 0 faults/timeouts.

Head 3d6b26b, whole kernel 7.3.0-aurora-pr2468fix (fleet74 config, drm/asahi Rust, overflow checks on), booted
on the M1 Pro:

  • zero-sized and oversized render submits (width 0, height 0, 0x0, 16385, unknown flag): all EINVAL, no oops
  • render-churn load (4 long-lived 3D blit renderers + 4 loops of short 3D blit processes): 30 runs, about 23,000
    short processes, 0 VA-0 faults, 0 GPU timeouts, 8-9 s per run
  • deqp subset (2,076 layered/blit/resolve/multisample/multiview cases): identical to stock (1,610 Pass,
    466 NotSupported, 0 changed)
  • GPU-bound glmark2 (off-screen, 2560x1600), before this PR vs this head on the same kernel: score 7513 vs 7554,
    terrain 427 vs 425 fps; overflow-driven grows still happen on the busy client (4x 32 -> 84 blocks, as before)
  • KUnit (arm64, asahi): 344 run, 342 passed, 2 skipped, including the new tiling-parameter cases; host tests
    427/427; clippy: 0 lints in the touched files

Earlier rows (fleet74 kernel with the first commit as a test module, see the provenance comment): before 11 runs /
30 VA-0 timeouts, after 79 runs / 0; M2 (G14G) control identical on both.

Still to run

Reviewer detail: review items and evidence

Review at 3525bfc, answered by 38bd5b1 and 3d6b26b:

  1. Zero-size panic: flags and dimension checks moved into get_tiling_params(); KUnit asahi_render_tiling_params
    (zero/oversized/unknown-flag -> EINVAL, 1x1 and 16K valid, clustered 7 + 2 * layers); hardware zero-size submit
    test on the M1 Pro: 6/6 EINVAL.
  2. last_out is not a TVB idle proof: replaced by tvb_users, the pending finished fences of render submissions
    after the newest one that completed cleanly. A clean completion drops it and every older entry; an error drops
    only that entry. The grow waits newest first until the list is empty.
  3. render_min_tvb_blocks() moved above submit_render()'s doc comment and #[expect]; get_tiling_params()
    private again. Clippy at 3525bfc showed the two lints (render.rs:203 too_many_arguments, render.rs:186
    unfulfilled expectation); at this head there are none in the touched files.
  4. Interruptible wait, MAX_SCHEDULE_TIMEOUT, ERESTARTSYS. The command-count check and the whole sizing pass now
    run before start_op(), bind_vm() and the fence, so nothing exists yet when it restarts.
  5. stats_target_blocks() peeks max_pages without resetting; the target is folded into the required size;
    reset_stats() only after the grow. No stale busy: there is no separate idle check any more.
  6. tvb_init_pending on the queue, set by a grow, passed to the first render, cleared only after job.push().
    Nits: TVBStats grow log in submit(); wait_fence() shared by the close path and the grow.

Firmware-crash rate on this kernel, same load: head 16/30 runs, the first commit alone 11/20 runs (fleet74 with
the first commit: 9/47), so the higher rate comes with the newer integration base, not with these commits.

Build log (full kernel from scratch at 3d6b26b), KUnit, host tests, clippy:
https://gist.github.com/RyanTheTide/8e219be16565f338d7c43c4b31595ce0

How the cause was found: a per-submission trace (lock-free ring in a test build, dumped only at fault time) for
every faulting queue showed tiny heap use (overflow_count 0, max_pages 11) and the block count going
8 -> 15 -> 19 -> 21 -> 23 -> 31 -> 39, driven by min_tvb_blocks while the previous scene was in flight, with the
fault on the latest grown render. Ruled out on hardware: serialising each queue's first render, the legacy inline
submit and receive fast paths, deferring only the InitBuffer. A bigger initial TVB (64 blocks) also removes the
faults at unchanged speed, which confirms growth as the cause. Waiting for the buffer's scene count to reach 0
would deadlock: the work queue keeps the last completed command (and its scene) until a later one completes.

Assisted-by: LLM (Claude:Opus 5.5)

The firmware buffer manager owns a TVB buffer while scenes on it are in
flight. The render path grew the buffer for every render that needed
more blocks (min_tvb_blocks, or the overflow statistics), even with the
previous scenes of the same buffer still running: ensure_blocks()
appended blocks to the live block list and the render then sent an
InitBuffer for the bound slot. ensure_blocks() already holds back the
page count while scenes are active ("only if the buffer manager is
idle"), but the block list and the InitBuffer still changed under the
running scenes.

A fresh context starts with a small buffer and a layered render needs
7 + 2 * layers blocks when it is clustered, so a 3D blit grows it on
almost every pass, while the previous pass still tiles. On the M1 Pro
(G13S, two clusters) with several such contexts at once, the tiler
then writes to VA 0 (TE, VCE or dPM fault, then a GPU timeout).

Size the buffer for every render of a submission before any of it is
published, and only once the queue's earlier work, the only other user
of the buffer, has completed: a required grow waits for the queue's
last job, a grow from the overflow statistics only happens on an idle
queue (the firmware handles a full heap itself). The first render of
the submission then re-initialises the slot with the new size.

Signed-off-by: Ryan Murray <[email protected]>

@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.

Thanks Ryan. The diagnosis is convincing, and sizing the TVB once per submission before anything is published is the right shape. A few things need to change first.

Must fix

  1. User-triggerable panic. The new first pass calls render_min_tvb_blocks() (queue/mod.rs:898) on a render command that has not been validated. get_tiling_params() computes x_max: (width - 1) and te_screen: ((tiles_y - 1) << 12) | (tiles_x - 1) (render.rs:165-167), and the width_px == 0 / height_px == 0 check only runs later in submit_render() (render.rs:228). With CONFIG_RUST_OVERFLOW_CHECKS=y (the default, and set in our 7.3.0 config), any client can oops the kernel from the submit ioctl with a zero-width render, while the queue mutex is held. Please move the flags and dimension checks into get_tiling_params(), so every caller has them.

  2. last_out does not prove the TVB is idle. It is the fence of the queue's last job, whatever that job contained. A compute-only job without a VDM barrier can complete before the render job ahead of it (the FIXME at queue/mod.rs:850 says as much, and the kernel does not force that barrier). Then busy is false while that render still uses the buffer, and we grow it under the firmware again. The same happens if the last job failed in run() before reaching the firmware: its fence carries an error while the job before it still runs. Please track the finished fence of the last submission that contained a render, and use it for busy and for the wait. Renders complete in order on the fragment queue, and JobFence covers both halves. Please also treat an error status as not proven idle.

  3. render_min_tvb_blocks() went in between submit_render()'s doc comment plus #[expect(clippy::too_many_arguments)] and submit_render() itself (render.rs:184-203). The new function now has the wrong doc text and an unfulfilled expectation, and the 10-argument submit_render() lost its expectation, so CLIPPY=1 warns twice. Please move the new function above the doc comment.

Should fix

  1. The grow wait (queue/mod.rs:762-783) is uninterruptible and fails the submission with ETIMEDOUT after 5 s. Earlier work can legitimately take longer: the scheduler timeout is 100 s, compute timeouts are configurable, and the previous job may still be waiting on its in-fences. Mesa turns a failed submit into device lost. The wait also holds off the freezer during suspend. Please wait interruptibly and return ERESTARTSYS. file.rs already passes it through quietly, and nothing has been published at that point, so the restart is clean. Please drop the 5 s cap, or use the scheduler timeout.

  2. Statistics-driven growth now only happens when the queue is idle at submit time. A GPU-bound client with frames in flight is rarely idle there, so its TVB can stay at the dimension minimum and keep doing partial renders. Before this PR it grew while busy (unsafely, but it grew). Suggestion: peek max_pages without resetting it, and fold the 3x target into the required size, so a stats grow waits once like a required grow. Growth is 3x per step, so that is a handful of waits per queue lifetime. Also, after the wait at line 942, busy is stale, so the stats grow is skipped right after we made the queue idle.

  3. The slot re-initialisation can be lost. The grow is published at lines 944-948, but the InitBuffer only goes out with the first render's commands. If the submission then fails, the next submission sees need == false and tvb_grown == false, and with the same slot rebind() == false, so the slot keeps the old size. Failure points after the grow: the command-count check, a barrier index, read_supported(), flags or timestamps in submit_render(), or ENOMEM after auto_grow_idle() already grew. A pending-init flag on the queue, cleared only after job.push(), fixes it.

Nits

  • The TVBStats messages went away with the removed render.rs block, and DebugFlags::TVBStats has no users now. Please log the grow (old and new blocks, reason) in submit().
  • get_tiling_params() does not need pub(super). Its new caller is in the same impl.
  • wait_last_out_for_grow() duplicates wait_submitted(). One helper would do.

Evidence

  • The M1 Pro rows ran a test module with an A/B debug bit in an unchanged kernel. Please confirm that code matches 3525bfc, or rerun about 10 runs of the same load on a build of this head, and attach the build log. No integration/aurora CI job compiles drm/asahi.
  • This path serves G13, G14 and G14X only. The G14G control is single-cluster and never takes the clustered 7 + 2 * layers path, so please add a G14X row (M2 Pro or Max): the same load plus the deqp subset.
  • For item 5, a GPU-bound geometry-heavy run on G13S, before and after, with frame time and TVB size from TVBStats.

Leaving the firmware DestroyContext crash for a follow-up is fine. A separate issue for it would help.

The TVB sizing pass in Queue::submit() calls render_min_tvb_blocks(),
and with it get_tiling_params(), on every render command of a
submission before submit_render() has checked the command. With
CONFIG_RUST_OVERFLOW_CHECKS, a render with a width or height of 0 then
panics on `width - 1` / `tiles_x - 1` inside the submit ioctl, with the
queue lock held.

Move the flag and dimension checks from submit_render() into
get_tiling_params(), so every caller gets EINVAL for such a command
before any arithmetic on its size. Add KUnit cases for zero, oversized
and unknown-flag renders, and for the clustered layered TVB minimum.

Also put render_min_tvb_blocks() above submit_render()'s doc comment
and #[expect(clippy::too_many_arguments)], which it had split from
submit_render(), and make get_tiling_params() private again.

Fixes: 3525bfc ("drm/asahi: grow a TVB buffer only while the firmware is not using it")
Signed-off-by: Ryan Murray <[email protected]>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Build provenance for the M1 Pro / M2 rows above, plus a build of this PR's head.

The rows were not built from 3525bfc. They used a module-only build on top of the production fleet74 kernel:

Base kernel (unchanged, running on the Macs) 7.3.0-aurora-fleet74 = aurora-silicon/linux 1f710d269d74867b697995a4ed305b07f4a22053
aurora.ko source fleet74 1f710d26 + this PR's diff: buffer.rs, queue/mod.rs, queue/render.rs byte-identical to 354310418b79 (same patch-id as 3525bfc, 43d50e9c)
Delta to 3525bfc the base only: integration/aurora 6ae9c3ca is 569 commits past fleet74 (83 files under drivers/gpu/drm/asahi + rust/ changed; none of the 3 patched files)
Toolchain clang/LLD 22.1.6, rustc 1.97.1 (8bab26f4f 2026-07-14, LLVM 22.1.6), bindgen 0.73.2
Config the shipped fleet74 config, unchanged
vermagic 7.3.0-aurora-fleet74 SMP preempt mod_unload aarch64
sha256 21daa0af1000aa2e69b6979fc10521a05f0819083301f24b2b8d3429da2eaae1 (clean fix module: M1 Pro deqp subset, M2 control)
Loading one-shot boot of the fleet74 kernel with modprobe.blacklist=aurora, then insmod

The 79 "after" mix runs used test builds of the same module (same base, the fix plus test-only trace/debug bits, the fix switched by a debug bit so one binary gave both arms).

Build of the PR head. A module built from 3525bfc can't be loaded on fleet74: integration's drm/asahi calls apple_sleep_note_sub(), which fleet74 doesn't have, and struct apple_rtkit_ops gained a field. So I built the whole kernel at 3525bfc with the fleet74 config instead. olddefconfig added only CONFIG_APPLE_J613_DISPLAY_SYNC=y. Result: Image modules dtbs build with 0 errors. drm/asahi gives the same 16 dead_code warnings as the fleet74 build and none in the patched files.

  • release 7.3.0-aurora-pr2468, vermagic 7.3.0-aurora-pr2468 SMP preempt mod_unload aarch64
  • aurora.ko sha256: build tree b19c99bb08eeec01d68876ae8db4a7e2d47e1f823d17ceb15fc73b911ee36f14, installed (stripped + signed) 8140af541872d30ff3b586bae40e640e85496e3bae8927ca21ee97b5e9c535c0
  • Image sha256 11f434a90c0697854b68dd5eec2e3f7367c537a53da559142e6b25b3837234d3

Build logs and the exact recipe for both builds: https://gist.github.com/RyanTheTide/81d48cc8fd5b3861c250f09fd09290e7 (full kernel log, drm/asahi excerpt, and the log of the module used for the rows).

Still to run: the M1 Pro load (10 mix runs) on this 3525bfc kernel. I'll post the result here.

The TVB grow waited for, or tested, the queue's last job. That job may
not hold the TVB at all: a compute-only job without a VDM barrier can
complete while the render ahead of it still runs, and a job that failed
in run() before reaching the firmware carries an error while the job
before it still runs. The buffer was then grown under the firmware
again.

Track the finished fences of the submissions that contain a render.
Renders complete in order on the fragment queue and a job's fence
covers all of its commands, so a render submission that completed
without error proves every earlier render done; one that failed proves
nothing about the ones before it. A grow waits for all renders up to
the newest that completed cleanly.

The wait is interruptible and returns ERESTARTSYS on a signal, instead
of failing the submission with ETIMEDOUT after 5 s (Mesa reports a
failed submit as a lost device, and earlier work may legitimately run
longer). It runs before the job, its VM binding or its fence exist, so
the ioctl restarts cleanly. The command count is checked before it.

Growth from the overflow statistics only happened on an idle queue, so
a GPU-bound client kept partial renders. Read the statistics without
resetting them and fold their 3x target into the size the submission
needs, so they grow with one wait per growth step, and reset them only
once the buffer grew.

The slot re-initialisation after a grow went out only with the first
render of the same submission. If that submission then failed, the
next one saw no grow and kept the old slot size. Keep it pending on the
queue until a job with a render has been pushed.

Log each grow (old and new size, what asked for it) under TVBStats,
and share one fence wait helper with the queue's close path.

Fixes: 3525bfc ("drm/asahi: grow a TVB buffer only while the firmware is not using it")
Signed-off-by: Ryan Murray <[email protected]>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Pushed 38bd5b1 and 3d6b26b on top of 3525bfc (new commits, no rebase). Item by item:

  1. The flags and size checks are in get_tiling_params() now, with KUnit cases. A zero-size submit on the M1 Pro returns EINVAL (6 of 6 invalid renders), no oops.
  2. The grow waits on the finished fences of the queue's render submissions, back to the newest one that completed without error. An error status only drops that entry, and the older ones are still waited for.
  3. render_min_tvb_blocks() sits above the doc comment and #[expect], and get_tiling_params() is private. CLIPPY=1 showed both lints at 3525bfc and none in the touched files at this head.
  4. The wait is interruptible, returns ERESTARTSYS and has no cap. It runs before start_op(), bind_vm() and the fence are created, and the command-count check moved ahead of it.
  5. max_pages is read without a reset, and the 3x target is folded into the required size. With glmark2 running GPU-bound, the busy client still grew from overflows (4x 32 -> 84 blocks, same as before the PR).
  6. A pending slot init lives on the queue and is cleared only after job.push().
    Nits are done too: the grow is logged under TVBStats, and one wait helper is shared.

Provenance: every M1 Pro row in the updated description ran exactly 3d6b26b, as the whole kernel 7.3.0-aurora-pr2468fix with its in-tree aurora.ko. The before/after perf rows and the 3525bfc control used external aurora.ko builds against that same kernel. The full from-scratch build log is in https://gist.github.com/RyanTheTide/8e219be16565f338d7c43c4b31595ce0. Results: 30 churn runs with 0 VA-0 faults, the deqp subset identical to stock, and glmark2 7513 before vs 7554 at this head.

Still open: the M2 rows (that Mac is down right now) and a G14X row. The firmware crash is tracked in #2506. Its rate is higher on this integration kernel, about the same for 3525bfc alone (11 of 20 runs) as for this head (16 of 30).

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

M2 (J413, T8112, G14G single cluster) row at 3d6b26b: PASS, no regression.

Same whole-kernel build as the M1 Pro rows (7.3.0-aurora-pr2468fix at 3d6b26b, in-tree aurora.ko), installed as a non-default entry; production fleet74 as the reference.

row stock fleet74 3d6b26b
deqp-vk subset (2076 layered/blit/resolve/multisample/multiview) 1610 pass / 466 NS / 0 fail 1610 / 466 / 0, case-by-case identical
invalid renders (zero/oversized/unknown flag) - 6/6 EINVAL, no oops
churn runs completed 29 / 30 30 / 30
churn runs aborted by a fw crash 1 / 30 0 / 30
VA-0 / TE faults, "Fault info" 0 0
GPU timeouts 0 0

Churn = 4 long-lived 3D-blit renderers (2880 cases each) plus 4 VkDevice create/destroy churners, ~1000 churn processes per run (30,317 on the head, 29,953 on stock). The single stock abort (run 21, RTKit crash, GPU dead until reboot) is the separate firmware crash in #2506; 1/30 vs 0/30 is not a meaningful difference.

glmark2-es2-gbm off-screen 2560x1600, same kernel, base module (pre-PR) vs head module, 5 reps each:

scene base fps / frame time head fps / frame time
terrain 236 / 4.247 ms (4.240-4.255) 236 / 4.255 ms (4.250-4.266)
refract 234 / 4.284 ms 234 / 4.286 ms
jellyfish 3727 / 0.269 ms 3721 / 0.269 ms
build (vbo) 6693 / 0.149 ms 6727 / 0.149 ms
shading (phong) 5153 / 0.194 ms 5191 / 0.193 ms
ideas 5975 / 0.167 ms 5994 / 0.167 ms
full-set score 4783 4809

The M2 does take the overflow-driven grow: 6 grows from 32 to 76 blocks in each bench run (same submissions on base and head), handled with 0 faults, 0 timeouts and 0 firmware crashes. The clustered (G14X) path still needs a G14X row.

Method and evidence
  • Kernel: 7.3.0-aurora-pr2468fix, whole tree at 3d6b26b (PR head at test time, unchanged), same pkg as the M1 Pro rows. A/B modules for the bench: aurora-base.ko (6ae9c3c, pre-PR) and aurora-head.ko (3d6b26b), both built against that kernel, loaded on modprobe.blacklist=aurora boots with debug_flags=TVBStats.
  • Boots: one in-tree one-shot (zero-size test, subset, 30 churn runs on one boot) and two blacklist one-shots (bench), all with a 50-min dead-man; every boot returned in 27 s. Stock rows ran on production fleet74 (subset without reboot; churn control over two plain reboots of the default because the stock fw crash leaves the GPU dead).
  • Kernel log of the head boot: 0 err-level lines. TVB grow lines: 69 on both modules.
  • vkmark is not installed on the M2, so no vkmark row.
  • Machine restored to fleet74 (default, next_entry empty, Enforcing, 0 failed units, test kernel and entries removed).
  • Evidence (lab store): traces/gpu/20261120-pr2468-m2/ (per-run kernel logs, subset result lists, bench output).

QueueJob::run() can fail on either side of publishing its commands to
the firmware, and the scheduler then signals the job's finished fence
with that error right away. The TVB grow treated every such fence as
"never ran" and dropped it, and the slot init a grow attaches to the
next render was cleared once that render was pushed. Two holes:

- A failure after run_job() published commands (the doorbell send
  failed) leaves work the firmware may still pick up. Its vertex or
  compute half was rolled back, so no fence will ever signal its end.
  Dropping the entry let a later submission grow the buffer under it.

- A render that carries the slot init and fails before publishing
  anything (e.g. ENOMEM in WorkQueue::submit()) loses that init, while
  later renders, built without one, go on to reach the firmware with
  a slot that does not match the grown buffer.

Each render job now shares a small TvbJob with its queue: run() marks it
published right before the first run_job(), and a failing init carrier
that published nothing reports its init lost. The queue classifies its
render fences as pending, done, failed-unpublished or failed-published:
a failed-published entry stays until a later clean completion proves it
done (renders complete in order on the fragment queue), and a grow that
finds one as the newest outstanding render fails the submission with
ECANCELED instead of waiting on a fence that has already signalled.
A render that relies on a lost init fails in run() with ECANCELED before
it publishes anything, and the next submission re-initialises the slot.

The classification and pruning are pure functions with KUnit cases.

Fixes: 3525bfc ("drm/asahi: grow a TVB buffer only while the firmware is not using it")
Signed-off-by: Ryan Murray <[email protected]>
@RyanTheTide

RyanTheTide commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor Author

Pushed 2077fde on top of 3d6b26b (new commit, no rebase). It answers the error-path question: you were right, both cases were holes.

Failure after publishing. run() can return an error after run_job() wrote a command to the ring, when the doorbell send fails (RTKit crashed, not running, or the mailbox timed out). The scheduler then signals the finished fence with that error right away, and 3d6b26b dropped the entry. Nothing else would ever signal for that work either: the job's other halves were rolled back, so its JobFence never completes. A fragment command waits on its vertex stamp, so a published fragment stays parked, but a published vertex command can still run on a later doorbell. Keeping the fence "until it signals" therefore doesn't work, because it already has. Instead, run() now marks the job as published right before the first run_job(). An entry that failed after that point stays in the set until a later clean completion proves it done (renders still finish in order on the fragment queue), and only the newest such entry is kept. A grow that finds one as the newest outstanding render fails that submission with ECANCELED and leaves the buffer alone. In practice this path means the GPU firmware is already gone.

Slot init lost before publishing. The init a grow attaches to the next render was cleared once that render was pushed. If that render then failed before publishing (the realistic case is an allocation failure in WorkQueue::submit()), its init never reached the firmware. Later renders, built without an init, could still reach it. Each render job now records which init it relies on. A failing init carrier that published nothing reports its init lost, renders that rely on it fail in run() with ECANCELED before publishing anything, and the next submission re-initialises the slot.

The classification and pruning are pure functions with KUnit cases (5 new, all pass; asahi suite 347 pass, 2 skipped). CLIPPY=1 reports 0 lints in the touched files.

Rows at 2077fde (whole kernel 7.3.0-aurora-pr2468fix2, in-tree aurora.ko; churn table split as you asked):

Mac churn runs completed aborted by fw crash (#2506) VA-0 / TE / Fault info GPU timeouts
M1 Pro (G13S) 30 19 11 0 0
M2 (G14G) 30 27 3 0 0
M2, same kernel, 3d6b26b module 20 19 1 0 0
M2, same kernel, 2077fde module 20 19 1 0 0

The M1 Pro abort rate matches what the integration base showed before (16/30 at 3d6b26b). On the M2, the matched A/B puts both heads at 1/20.

Fault injection (test-only module parameter, not in this PR): every 2nd render that carries a slot init fails run() before publishing.

  • M2, 30 short glmark2 clients at 2560x1600 (each grows its TVB once). The 3D-blit churn never grows a TVB on G14G.
    • 3d6b26b: 45 lost inits, 0 faults.
    • 2077fde: 77 drops, then 77 re-inits, 0 faults.
    • 2077fde with legacy_inline_submit=0, so jobs queue behind the failing one: 161 drops, 28 renders cancelled because they relied on a lost init, 0 faults, 0 timeouts, 0 firmware crashes.
  • M1 Pro: both 3d6b26b and 2077fde wedge the queue under injection (DRM scheduler job timeouts, WorkQueue: Job::commit() out of order, EINVAL submits). So a render that fails in run() before publishing already breaks the workqueue event sequence on G13S, whatever the TVB code does. That's a separate pre-existing issue (drm/asahi: a job that fails in run() before publishing breaks its queue's event order #2546), and it means the M1 Pro can't isolate the lost-init case.
Method, provenance, files
  • Kernel: 2077fde, integration 6ae9c3c base, shipped fleet74 config, clang/LLD 22.1.6, rustc 1.97.1, bindgen 0.73.2. Image sha256 5017d729..., aurora.ko 3e93c4c4... A/B modules were built against that same kernel and loaded on modprobe.blacklist=aurora one-shot boots.
  • Churn: 4 long-lived 3D-blit renderers (2880 cases each) plus 4 VkDevice create/destroy churners, the same mix.sh as the earlier rows. A run counts as aborted when the firmware crashed during it.
  • Terrain frame times before/after were in the M2 row (4.247 vs 4.255 ms). This commit only touches failure paths and adds bookkeeping per render submission.
  • Zero/oversized/unknown-flag renders: 6/6 EINVAL on the M2 at this head.
  • Injection patch: one pr_info per drop, cancel and re-init. Counts come from the kernel log of each boot.

@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.

Approving at 2077fde. All six review points are addressed, and Joshua's error-path question is closed by the new commit. A render whose post-publish failure is signalled with an error now keeps its TVB entry until a later clean completion, so a grow against it fails with ECANCELED instead of rewriting a live buffer. A render that relies on a slot init which never reached the firmware fails before publishing, and the next submission re-initialises. The pruning is a pure function with KUnit cases. Evidence: full-kernel build at this head (7.3.0-aurora-pr2468fix2), M1 Pro and M2 churn with 0 VA-0 faults and 0 timeouts, M2 matched A/B equal on #2506 aborts, and fault injection with 161 dropped inits and 0 faults. The G14X row from an M2 Pro/Max is post-merge verification. #2506 and #2546 stay separate.

@DjDeveloperr
DjDeveloperr merged commit e00fb9a into integration/aurora Nov 20, 2026
1 check passed
@RyanTheTide
RyanTheTide deleted the gpu/g13-tvb-grow-idle branch November 27, 2026 13:21
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