Skip to content

Commit 0328bb0

Browse files
trusinowiczgregkh
authored andcommitted
accel/ivpu: Fix race condition when unbinding BOs
[ Upstream commit 0081263 ] 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: 48aea7f ("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 [ The context change is due to the commit e0c0891 ("accel/ivpu: Rework bind/unbind of imported buffers") and the proper adoption is done. ] Signed-off-by: Rahul Sharma <black.hawk@163.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent f772805 commit 0328bb0

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

drivers/accel/ivpu/ivpu_gem.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,14 +240,15 @@ static void ivpu_gem_bo_free(struct drm_gem_object *obj)
240240

241241
mutex_lock(&vdev->bo_list_lock);
242242
list_del(&bo->bo_list_node);
243-
mutex_unlock(&vdev->bo_list_lock);
244243

245244
drm_WARN_ON(&vdev->drm, !drm_gem_is_imported(&bo->base.base) &&
246245
!dma_resv_test_signaled(obj->resv, DMA_RESV_USAGE_READ));
247246
drm_WARN_ON(&vdev->drm, ivpu_bo_size(bo) == 0);
248247
drm_WARN_ON(&vdev->drm, bo->base.vaddr);
249248

250249
ivpu_bo_unbind_locked(bo);
250+
mutex_unlock(&vdev->bo_list_lock);
251+
251252
drm_WARN_ON(&vdev->drm, bo->mmu_mapped);
252253
drm_WARN_ON(&vdev->drm, bo->ctx);
253254

0 commit comments

Comments
 (0)