Files
reims-vgpu/docs
Anees Iqbal 68701c61bf 🐛 Wait at a reset for the queue walks begun before it
The device's reset waits, in the host's settle, for the GPU work the guest
committed before it, so none of that work writes the guest's memory after the
reset returns. A queue walk begun before the reset could still commit work
after the settle looked: the control thread's reset waits for it (the reset
gate), but the settle cannot take that gate, as ring 0's queue creates and
destroys hold it and may wait for the BQL that QEMU holds around the reset. The
walk's GPU work then ran, and wrote the guest's pages, after the reset returned.

The settle now waits, within 30 s of its start, as for the decoder's locks, for
the queue walks begun before the reset (walks.rs: a ticket taken in
begin_command_buffer before the walk asks whether its poster is stale, so a
walk that begins after the reset ends at once and is not waited for). First it
cuts short every wait the control thread's reset cuts short, so no walk waits
for that thread: for other queues' buffers and their events
(Decoders::resetting; commit_order::Cancel now nests, as the two resets may
overlap), for compiles outside the process (GpuDevice::reset_begins, whose
stage-fill suspends nest) and for pipelines still compiling
(Pending::resetting, which nests too). After the walks it releases the events
and surface timelines again, for what the walks made or waited for meanwhile,
then waits for the GPU as before, on progress: the command buffers it waits
for are those committed by then, the walks' among them. Ring 0's block-lane
downloads and cache copies stay out of it. A walk past 30 s ends the process
at "the device's reset", naming the oldest. The settle's line now reads "the
device's reset waited X ms for the W queue walks begun before it (Y ms) and
the N command buffers committed to the GPU before it, Z ms at most with none
of them completing".

What the host observes: rvg_graphics_device_reset and a STATUS write of 0
return only once the queue walks begun before them have ended, which the
header's reset doc and docs/api.md now say. Two tests held the old behaviour
and change with it. a_reset_during_a_walk_comes_after_it had the reset return
with the walk in flight; it now resets on a thread of its own and checks that
the reset waits. reset_chain's stage-fill test had the fill go on through the
settle, cancelled only by the control thread's reset, with the settle setting
the writer's timeline on the CPU; now the settle cancels the fill, the walk
ends with its dispatch refused and commits the writer's buffer, and the settle
waits for it and the reader's on the GPU. Its compile test now moves the clock
past the bound where the reset has not returned, so a red run dies there
rather than hanging.

Tests (tests/reset_walks.rs), each with the control thread's reset held behind
a ring-0 message whose platform call is held, standing for the BQL:
- a_reset_waits_for_a_walk_begun_before_it and
  a_reset_whose_walk_runs_past_the_bound_ends_the_process;
- one per wait class a walk can sit in, each ending inside the bound: a
  COMMIT_ORDER wait, a begin's SURFACE_ORDER wait (whose buffer then waits on
  the GPU for a timeline the settle sets after the walks), a stage's fill and a
  pipeline still compiling.
Job m3-max-79627 (homelab-um870-1) ran them on the fake platform three ways.
Green: all pass, with the progress rule's and the chain's tests (88). Without
the walks wait: the two walk tests, a_reset_during_a_walk_comes_after_it and
the SURFACE_ORDER test, whose timeline is set only after the walks, fail.
Without the settle's cut-shorts: each wait class's test and both chain tests
die at the bound. fmt, the header's check and clippy on the host and the
Windows target are clean (79627); the workspace's 3167 tests pass on
homelab-um870-1's Radeon 780M (79647).
2026-12-02 12:06:18 -08:00
..