[Intel-xe] [PATCH 08/26] drm/xe: Move drm exec loop to vm_bind_ioctl_ops_execute
Matthew Brost
matthew.brost at intel.com
Thu Oct 26 04:01:55 UTC 2023
The execution of the ops list can allocate memory in TTM which can
trigger an eviction. Lockdep is not happy if the drm exec is closed when
this happens.
Signed-off-by: Matthew Brost <matthew.brost at intel.com>
---
drivers/gpu/drm/xe/xe_vm.c | 46 ++++++++++++++++++--------------------
1 file changed, 22 insertions(+), 24 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_vm.c b/drivers/gpu/drm/xe/xe_vm.c
index d7b3e5309c13..fa4892552a7c 100644
--- a/drivers/gpu/drm/xe/xe_vm.c
+++ b/drivers/gpu/drm/xe/xe_vm.c
@@ -2840,23 +2840,17 @@ static int vm_bind_ioctl_ops_lock(struct drm_exec *exec,
struct xe_vma_op *op;
int err;
- drm_exec_init(exec, DRM_EXEC_INTERRUPTIBLE_WAIT);
- drm_exec_until_all_locked(exec) {
- err = drm_exec_prepare_obj(exec, &xe_vm_ttm_bo(vm)->base, 1);
- drm_exec_retry_on_contention(exec);
- if (err)
- goto out;
+ err = drm_exec_prepare_obj(exec, &xe_vm_ttm_bo(vm)->base, 1);
+ if (err)
+ return err;
- list_for_each_entry(op, &vops->list, link) {
- err = op_lock(exec, vm, op);
- drm_exec_retry_on_contention(exec);
- if (err)
- goto out;
- }
+ list_for_each_entry(op, &vops->list, link) {
+ err = op_lock(exec, vm, op);
+ if (err)
+ return err;
}
-out:
- return err;
+ return 0;
}
static struct dma_fence *ops_execute(struct xe_vm *vm,
@@ -2889,17 +2883,21 @@ static int vm_bind_ioctl_ops_execute(struct xe_vm *vm,
lockdep_assert_held_write(&vm->lock);
- err = vm_bind_ioctl_ops_lock(&exec, vm, vops);
- if (err)
- return err;
+ drm_exec_init(&exec, DRM_EXEC_INTERRUPTIBLE_WAIT);
+ drm_exec_until_all_locked(&exec) {
+ err = vm_bind_ioctl_ops_lock(&exec, vm, vops);
+ drm_exec_retry_on_contention(&exec);
+ if (err)
+ return err;
- fence = ops_execute(vm, vops, true);
- if (IS_ERR(fence)) {
- err = PTR_ERR(fence);
- /* FIXME: Killing VM rather than proper error handling */
- xe_vm_kill(vm, false);
- } else {
- dma_fence_put(fence);
+ fence = ops_execute(vm, vops, true);
+ if (IS_ERR(fence)) {
+ err = PTR_ERR(fence);
+ /* FIXME: Killing VM rather than proper error handling */
+ xe_vm_kill(vm, false);
+ } else {
+ dma_fence_put(fence);
+ }
}
drm_exec_fini(&exec);
--
2.34.1
More information about the Intel-xe
mailing list