]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
accel/ivpu: Fix race condition when unbinding BOs
authorTomasz Rusinowicz <tomasz.rusinowicz@intel.com>
Wed, 29 Oct 2025 07:14:51 +0000 (08:14 +0100)
committerKarol Wachowski <karol.wachowski@linux.intel.com>
Thu, 30 Oct 2025 07:48:00 +0000 (08:48 +0100)
Fix 'Memory manager not clean during takedown' warning that occurs
when ivpu_gem_bo_free() removes the BO from the BOs list before it
gets unmapped. Then file_priv_unbind() triggers a warning in
drm_mm_takedown() during context teardown.

Protect the unmapping sequence with bo_list_lock to ensure the BO is
always fully unmapped when removed from the list. This ensures the BO
is either fully unmapped at context teardown time or present on the
list and unmapped by file_priv_unbind().

Fixes: 48aea7f2a2ef ("accel/ivpu: Fix locking in ivpu_bo_remove_all_bos_from_context()")
Signed-off-by: Tomasz Rusinowicz <tomasz.rusinowicz@intel.com>
Reviewed-by: Jeff Hugo <jeff.hugo@oss.qualcomm.com>
Signed-off-by: Karol Wachowski <karol.wachowski@linux.intel.com>
Link: https://patch.msgid.link/20251029071451.184243-1-karol.wachowski@linux.intel.com
drivers/accel/ivpu/ivpu_gem.c

index 2a159535421ab96a05396e5a141803e202a525b3..7353cfb73bcb1689d6905e5fb841182632cfbb74 100644 (file)
@@ -315,7 +315,6 @@ static void ivpu_gem_bo_free(struct drm_gem_object *obj)
 
        mutex_lock(&vdev->bo_list_lock);
        list_del(&bo->bo_list_node);
-       mutex_unlock(&vdev->bo_list_lock);
 
        drm_WARN_ON(&vdev->drm, !drm_gem_is_imported(&bo->base.base) &&
                    !dma_resv_test_signaled(obj->resv, DMA_RESV_USAGE_READ));
@@ -326,6 +325,8 @@ static void ivpu_gem_bo_free(struct drm_gem_object *obj)
        ivpu_bo_unbind_locked(bo);
        ivpu_bo_unlock(bo);
 
+       mutex_unlock(&vdev->bo_list_lock);
+
        drm_WARN_ON(&vdev->drm, bo->mmu_mapped);
        drm_WARN_ON(&vdev->drm, bo->ctx);