Files
metal2vulkan/crates
Anees Iqbal f02e4d40af Spares on ANV: free command buffers without trimming the pool, the kept barriers' submissions fail after a trim
Iris's runtime_lane::predication::streams_run_what_metal_ran failed at 39b45dd232 as a
GpuRecoveryVictim: vkQueueSubmit of a batch returned VK_ERROR_DEVICE_LOST (submit.rs's
submit_batch), because DRM_IOCTL_I915_GEM_EXECBUFFER2 returned ENOENT (strace), the execbuffer's
object list holding an object of handle 0 (INTEL_DEBUG=submit). Bisected to 9c458c96a6, the
give-back's frees moved to the free thread, uncapped.

The cause is ANV's chaining (Mesa main of 2026-11-09, read): a submission's command buffers are
chained, each one's last batch buffer object jumping to the next one's first, and under i915 the
jump adds the next one's object to those the first names (anv_cmd_buffer_record_chain_submit),
which only a reset or begin clears (anv_batch_bo_start). The kept barriers are submitted again as
recorded, so each submission names every command buffer that ever came next after one. A freed
command buffer stays in Mesa's common pool with its first batch buffer object until
vkTrimCommandPool destroys it; batch buffer objects are slices of 2 MiB slabs whose handle is
closed once every slice is free. The spares' uncapped frees and trims emptied whole slabs, and the
next submission of a kept barrier named a closed handle.

The probes on ms01's Iris Xe (Mesa 26.2.6, i915): the stream failed in each of 4 runs as
committed; it passed in each of 2 runs that freed without trimming, 2 that freed nothing, and 3
whose kept barriers were begun with SIMULTANEOUS_USE (which ANV never chains). Every command buffer
submitted at the failure was owned and none freed (an ownership trace of the spares), and the
validation layer, on in that test, reported nothing at the failure.

RuntimeDriverDefect::TrimmedCommandBufferFailsResubmission names it, on every ANV GPU (under the
xe kernel driver ANV records no such objects, but no GPU of it is measured). There a spare pool's
command buffers are freed, still on the free thread, and the pool is not trimmed
(release::PoolBuffers takes a trim flag; Spares::new(trims) from the device's defects); the
priming still trims, its command buffer never following a kept one. The kept barriers keep their
chaining: SIMULTANEOUS_USE would split each batch into an execbuffer per kept barrier. The cost on
ANV: a pool keeps, in the driver, as many command buffers' objects as it held at once, reset.

Tests: tests::spares::device::kept_barriers_run_again_after_the_command_buffers_after_them_were_freed
(a burst whose middle KEPT encoders come after kept barriers, freed past the recent uses, then the
kept barriers submitted again; every command buffer completes, no recovery);
tests::driver_defects lists the defect for every ANV profile. To be run on ms01's Iris Xe with
the fix and without it. api_signatures.tsv blessed (one variant row); docs/REFUSALS.md
regenerated: unchanged.

(cherry picked from commit 4e392a6bc8507445693982c6c041535490a4cc34)
2026-11-09 15:24:02 -08:00
..