Skip to content

Commit ca8656a

Browse files
matt-auldrodrigovivi
authored andcommitted
drm/xe: skip rebind_list if vma destroyed
If we are closing a vm, mark each vma as XE_VMA_DESTROYED and skip touching the rebind_list if this is seen on the eviction path. That way we can safely drop the vm dma-resv lock on the close path without needing to worry about racing with the eviction path trying to add stuff to the rebind_list which can corrupt our contended list, since the destroy and rebind links are the same list entry underneath. References: https://gitlab.freedesktop.org/drm/xe/kernel/-/issues/514 Signed-off-by: Matthew Auld <matthew.auld@intel.com> Cc: Matthew Brost <matthew.brost@intel.com> Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com> Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
1 parent ef6ea97 commit ca8656a

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

drivers/gpu/drm/xe/xe_bo.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -506,15 +506,17 @@ static int xe_bo_trigger_rebind(struct xe_device *xe, struct xe_bo *bo,
506506
vm_resv_locked = true;
507507
else if (ctx->resv != xe_vm_resv(vm)) {
508508
spin_lock(&vm->notifier.list_lock);
509-
list_move_tail(&vma->notifier.rebind_link,
510-
&vm->notifier.rebind_list);
509+
if (!(vma->gpuva.flags & XE_VMA_DESTROYED))
510+
list_move_tail(&vma->notifier.rebind_link,
511+
&vm->notifier.rebind_list);
511512
spin_unlock(&vm->notifier.list_lock);
512513
continue;
513514
}
514515

515516
xe_vm_assert_held(vm);
516-
if (list_empty(&vma->combined_links.rebind) &&
517-
vma->tile_present)
517+
if (vma->tile_present &&
518+
!(vma->gpuva.flags & XE_VMA_DESTROYED) &&
519+
list_empty(&vma->combined_links.rebind))
518520
list_add_tail(&vma->combined_links.rebind,
519521
&vm->rebind_list);
520522

drivers/gpu/drm/xe/xe_vm.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1460,6 +1460,7 @@ void xe_vm_close_and_put(struct xe_vm *vm)
14601460
}
14611461

14621462
list_move_tail(&vma->combined_links.destroy, &contested);
1463+
vma->gpuva.flags |= XE_VMA_DESTROYED;
14631464
}
14641465

14651466
/*

0 commit comments

Comments
 (0)