Commit ca8656a2 authored by Matthew Auld's avatar Matthew Auld Committed by Rodrigo Vivi

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/514Signed-off-by: default avatarMatthew Auld <matthew.auld@intel.com>
Cc: Matthew Brost <matthew.brost@intel.com>
Reviewed-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
Signed-off-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
parent ef6ea972
...@@ -506,6 +506,7 @@ static int xe_bo_trigger_rebind(struct xe_device *xe, struct xe_bo *bo, ...@@ -506,6 +506,7 @@ static int xe_bo_trigger_rebind(struct xe_device *xe, struct xe_bo *bo,
vm_resv_locked = true; vm_resv_locked = true;
else if (ctx->resv != xe_vm_resv(vm)) { else if (ctx->resv != xe_vm_resv(vm)) {
spin_lock(&vm->notifier.list_lock); spin_lock(&vm->notifier.list_lock);
if (!(vma->gpuva.flags & XE_VMA_DESTROYED))
list_move_tail(&vma->notifier.rebind_link, list_move_tail(&vma->notifier.rebind_link,
&vm->notifier.rebind_list); &vm->notifier.rebind_list);
spin_unlock(&vm->notifier.list_lock); spin_unlock(&vm->notifier.list_lock);
...@@ -513,8 +514,9 @@ static int xe_bo_trigger_rebind(struct xe_device *xe, struct xe_bo *bo, ...@@ -513,8 +514,9 @@ static int xe_bo_trigger_rebind(struct xe_device *xe, struct xe_bo *bo,
} }
xe_vm_assert_held(vm); xe_vm_assert_held(vm);
if (list_empty(&vma->combined_links.rebind) && if (vma->tile_present &&
vma->tile_present) !(vma->gpuva.flags & XE_VMA_DESTROYED) &&
list_empty(&vma->combined_links.rebind))
list_add_tail(&vma->combined_links.rebind, list_add_tail(&vma->combined_links.rebind,
&vm->rebind_list); &vm->rebind_list);
......
...@@ -1460,6 +1460,7 @@ void xe_vm_close_and_put(struct xe_vm *vm) ...@@ -1460,6 +1460,7 @@ void xe_vm_close_and_put(struct xe_vm *vm)
} }
list_move_tail(&vma->combined_links.destroy, &contested); list_move_tail(&vma->combined_links.destroy, &contested);
vma->gpuva.flags |= XE_VMA_DESTROYED;
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment