The driver's persistent AQL queues are legacy kernel queues MES maps;
a device reset takes them with MES's state. Upstream's device recovery
now carries them across:
- As upstream halts the device, a DRM client of the device (the hook
upstream gives everything outside amdgpu that must stop before its IPs
suspend) marks every mapped queue unmapped. Kicks are refused until
it is mapped again.
- Once the reset has succeeded and the schedulers run again (where KFD
restores its queues), before the new reset generation is published,
each queue's storage block is written again with an MQD upstream
builds afresh, positioned at the producer's write_dispatch_id, the
reader is moved there, and the queue is mapped. Packets not finished
were lost with the GPU's state; the generation tells clients. The
restore writes the storage through SDMA, so it cannot run from the DRM
client's resume, which precedes the schedulers' restart.
- A queue that cannot be mapped again is retained, and its owner's next
call freezes the session. A queue destroyed after a reset that was not
followed by a restore (the device wedged) is freed without an MES unmap.
The hooks run on the reset domain's thread while the owner queue serves
calls, so dext_aql keeps its own list of mapped queues under a lock held
only across bounded steps (MES map/unmap, storage writes), never across a
wait the reset must finish. Without it a restore could write a queue a
destroy had just freed.
The fixture's device-reset-recovers check failed intermittently: the
fixture's ASIC reset zeroed its engines' read pointers while the driver's
rings kept their write pointers (the fixture's IP blocks had no resume),
and an engine could also carry on mid-batch from the cleared position.
The SDMA engine then executed its stale ring from the start, old fence
values included; amdgpu_fence_process took the lower sequence for a wrap
and signalled every pending fence, so a new client's IB ran before its
page-table update and faulted. The ASIC reset now stops each engine at a
packet boundary, and the fixture's GFX and SDMA blocks resume their rings
at 0 as gfx_v12_0 and sdma_v7_0 do. The check now also asserts both
resumes ran.
Tests: test-aql-reset builds the real dext_aql.mm against a mock MES and
checks restore at the producer's position, kicks refused in between, the
wedged destroy, a failed restore, and the hooks on their own thread
against 300 rounds of create/kick/destroy under ASan and TSan (without
the lock it reports a use-after-free). The production-backend scenarios
cover the hooks' installation and the freeze on a failed restore; the
fixture's device-reset-recovers covers upstream's recovery running the
hooks around a real reset.
Runs the unmodified upstream Linux amdgpu and amdkfd drivers on Apple
Silicon Macs inside a DriverKit system extension, for AMD GPUs attached
over Thunderbolt. The Linux sources come from a pinned submodule and are
compiled against linuxu, a userspace implementation of the Linux kernel
APIs they use. Includes the HSA runtime, the host installer app, the
setup and firmware fetch scripts, and the offline test suite.