A behaviour change the host and the guest observe. design.md says nothing
begun before a reset reaches the guest after it, as a GPU's reset stops its
DMA. But the reset returned while the guest's command buffers committed
before it were still on the GPU: they and the completed handlers that merge
copied ranges back went on writing the rebooted guest's memory.
Now the reset, on the thread that resets (rvg_graphics_device_reset, which
QEMU calls under its BQL, or the guest's STATUS write of 0 on the vCPU),
ends with Host::reset_settles. reims-vgpu first sets every event the
guest's buffers could wait for past every value, and each deferred device
cache copy's event to its number, so no buffer waits for a signal nothing
will send any more. Then it waits for every command buffer committed before
to complete and run its completed handlers (GpuDevice::settle). It waits
for no thread of the device's: a route callback on ring 0's thread or the
control thread takes the BQL. It logs its time and how many it waited for.
The settle is bounded at 30 s, and past it the process ends: a new death,
"the device's reset". Only a GPU no driver recovered reaches it. The drivers
end hung work as a lost device, whose command buffers rt then completes,
failed: amdgpu at 2 s (lockup_timeout's default), and i915's last resort,
its heartbeat's engine reset, at most 25 s after work hangs (a pulse at the
next 2.5 s tick, raised one level a tick to the highest three ticks later,
then twice the 7.5 s preempt timeout; read from intel_engine_heartbeat.c).
The code is absent from the counts of the last good boots, as a new one is.
The BQL's hold grows by the settle. Typically that is the time the GPU
takes to finish what the guest committed before the reset: a settle over
a 1 MiB fill committed just before it took 1.3 ms on an RTX 3090, and one
with nothing in flight waits for none. At worst it is 30 s, only on a GPU
no driver recovered. The host gains one rule: raise_interrupt on the
platform's thread that runs a completed handler must not wait for a lock
the host holds around a reset. QEMU's waits for none: the irqfd's write,
msi_lock, which waits for nothing else, or a bottom half.
The header, docs/api.md (sections 1 and 4, and 5's locks around
raise_interrupt), design.md's Reset and qemu.md's BAR 0 say so. Tested by
a_reset_returns_once_the_guest_s_command_buffers_before_it_have_completed,
red before this change (the reset returned with the buffer on the GPU), and
a_reset_whose_gpu_work_runs_past_the_bound_ends_the_process.