Skip to content

Commit fa998a9

Browse files
committed
drm/panthor: Lock the VM resv before calling drm_gpuvm_bo_obtain_prealloc()
drm_gpuvm_bo_obtain_prealloc() will call drm_gpuvm_bo_put() on our pre-allocated BO if the <BO,VM> association exists. Given we only have one ref on preallocated_vm_bo, drm_gpuvm_bo_destroy() will be called immediately, and we have to hold the VM resv lock when calling this function. Fixes: 647810e ("drm/panthor: Add the MMU/VM logical block") Signed-off-by: Boris Brezillon <[email protected]> Reviewed-by: Liviu Dudau <[email protected]> Reviewed-by: Steven Price <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 2b55639 commit fa998a9

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

drivers/gpu/drm/panthor/panthor_mmu.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,9 +1251,17 @@ static int panthor_vm_prepare_map_op_ctx(struct panthor_vm_op_ctx *op_ctx,
12511251
goto err_cleanup;
12521252
}
12531253

1254+
/* drm_gpuvm_bo_obtain_prealloc() will call drm_gpuvm_bo_put() on our
1255+
* pre-allocated BO if the <BO,VM> association exists. Given we
1256+
* only have one ref on preallocated_vm_bo, drm_gpuvm_bo_destroy() will
1257+
* be called immediately, and we have to hold the VM resv lock when
1258+
* calling this function.
1259+
*/
1260+
dma_resv_lock(panthor_vm_resv(vm), NULL);
12541261
mutex_lock(&bo->gpuva_list_lock);
12551262
op_ctx->map.vm_bo = drm_gpuvm_bo_obtain_prealloc(preallocated_vm_bo);
12561263
mutex_unlock(&bo->gpuva_list_lock);
1264+
dma_resv_unlock(panthor_vm_resv(vm));
12571265

12581266
/* If the a vm_bo for this <VM,BO> combination exists, it already
12591267
* retains a pin ref, and we can release the one we took earlier.

0 commit comments

Comments
 (0)