tu/drm/virtio: Avoid freeing zombified tu_sparse_vma

This is d3cedd2fa5 ("tu/drm: msm's has_set_iova codepath should avoid
freeing zombified tu_sparse_vma") but for virtio.

Fixes: 764b3d9161 ("tu: Implement transient attachments and lazily allocated memory")
Signed-off-by: Valentine Burley <valentine.burley@collabora.com>
(cherry picked from commit f1366ca144)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40752>
This commit is contained in:
Valentine Burley 2026-03-19 11:16:20 +01:00 committed by Eric Engestrom
parent 2aa33f41e6
commit b6640c1609
2 changed files with 11 additions and 4 deletions

View file

@ -3854,7 +3854,7 @@
"description": "tu/drm/virtio: Avoid freeing zombified tu_sparse_vma",
"nominated": true,
"nomination_type": 2,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "764b3d9161c27afb57d20536c6968fa5085f34f1",
"notes": null

View file

@ -753,6 +753,8 @@ virtio_bo_init(struct tu_device *dev,
}
*out_bo = bo;
if (lazy_vma)
lazy_vma->msm.backs_lazy_bo = true;
/* We don't use bo->name here because for the !TU_DEBUG=bo case bo->name is NULL. */
tu_bo_set_kernel_name(dev, bo, name);
@ -947,9 +949,14 @@ static void
virtio_sparse_vma_finish(struct tu_device *dev,
struct tu_sparse_vma *vma)
{
mtx_lock(&dev->vma_mutex);
util_vma_heap_free(&dev->vma, vma->msm.iova, vma->msm.size);
mtx_unlock(&dev->vma_mutex);
/* For has_set_iova, if a lazy BO was mapped into this sparse VMA
* the allocation will be handed off to the zombie VMA mechanism.
*/
if (!vma->msm.backs_lazy_bo) {
mtx_lock(&dev->vma_mutex);
util_vma_heap_free(&dev->vma, vma->msm.iova, vma->msm.size);
mtx_unlock(&dev->vma_mutex);
}
}
static VkResult