[PATCH v4 22/30] drm/xe: Move vma rebinding to the drm_exec locking loop
Matthew Brost
matthew.brost at intel.com
Fri Mar 8 05:07:58 UTC 2024
From: Thomas Hellström <thomas.hellstrom at linux.intel.com>
Rebinding might allocate page-table bos, causing evictions.
To support blocking locking during these evictions,
perform the rebinding in the drm_exec locking loop.
Signed-off-by: Matthew Brost <matthew.brost at intel.com>
Signed-off-by: Thomas Hellström <thomas.hellstrom at linux.intel.com>
---
drivers/gpu/drm/xe/xe_exec.c | 12 ++++--------
drivers/gpu/drm/xe/xe_vm.c | 12 +++++++-----
2 files changed, 11 insertions(+), 13 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_exec.c b/drivers/gpu/drm/xe/xe_exec.c
index 7d676e3610fa..7f91b4b13634 100644
--- a/drivers/gpu/drm/xe/xe_exec.c
+++ b/drivers/gpu/drm/xe/xe_exec.c
@@ -106,6 +106,10 @@ static int xe_exec_fn(struct drm_gpuvm_exec *vm_exec)
if (ret)
return ret;
+ ret = xe_vm_rebind(vm, false);
+ if (ret)
+ return ret;
+
/*
* 1 fence slot for the final submit, and 1 more for every per-tile for
* GPU bind and 1 extra for CPU bind. Note that there are potentially
@@ -284,14 +288,6 @@ int xe_exec_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
goto err_exec;
}
- /*
- * Rebind any invalidated userptr or evicted BOs in the VM, non-compute
- * VM mode only.
- */
- err = xe_vm_rebind(vm, false);
- if (err)
- goto err_put_job;
-
/* Wait for rebinds */
if (!xe_vm_in_lr_mode(vm)) {
err = drm_sched_job_add_resv_dependencies(&job->drm,
diff --git a/drivers/gpu/drm/xe/xe_vm.c b/drivers/gpu/drm/xe/xe_vm.c
index 47a0d3a6cda5..e7bc9c3a8a83 100644
--- a/drivers/gpu/drm/xe/xe_vm.c
+++ b/drivers/gpu/drm/xe/xe_vm.c
@@ -519,7 +519,13 @@ static int xe_preempt_work_begin(struct drm_exec *exec, struct xe_vm *vm,
if (err)
return err;
- return drm_gpuvm_validate(&vm->gpuvm, exec);
+ err = drm_gpuvm_validate(&vm->gpuvm, exec);
+ if (err)
+ return err;
+
+ err = xe_vm_rebind(vm, true);
+
+ return err;
}
static void preempt_rebind_work_func(struct work_struct *w)
@@ -571,10 +577,6 @@ static void preempt_rebind_work_func(struct work_struct *w)
if (err)
goto out_unlock;
- err = xe_vm_rebind(vm, true);
- if (err)
- goto out_unlock;
-
/* Wait on rebinds */
wait = dma_resv_wait_timeout(xe_vm_resv(vm),
DMA_RESV_USAGE_KERNEL,
--
2.34.1
More information about the Intel-xe
mailing list