From f1366ca14479254ed29b6aa6c1d218ca8af6456f Mon Sep 17 00:00:00 2001 From: Valentine Burley Date: Thu, 19 Mar 2026 11:16:20 +0100 Subject: [PATCH] tu/drm/virtio: Avoid freeing zombified tu_sparse_vma This is d3cedd2fa56 ("tu/drm: msm's has_set_iova codepath should avoid freeing zombified tu_sparse_vma") but for virtio. Fixes: 764b3d9161c ("tu: Implement transient attachments and lazily allocated memory") Signed-off-by: Valentine Burley Part-of: --- src/freedreno/vulkan/tu_knl_drm_virtio.cc | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/freedreno/vulkan/tu_knl_drm_virtio.cc b/src/freedreno/vulkan/tu_knl_drm_virtio.cc index af0bae25c63..b03fdb1d203 100644 --- a/src/freedreno/vulkan/tu_knl_drm_virtio.cc +++ b/src/freedreno/vulkan/tu_knl_drm_virtio.cc @@ -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); @@ -949,9 +951,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