summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/xe/xe_vm.c
diff options
context:
space:
mode:
authorThomas Hellström <thomas.hellstrom@linux.intel.com>2023-09-08 11:17:11 +0200
committerRodrigo Vivi <rodrigo.vivi@intel.com>2023-12-21 11:41:06 -0500
commit08a4f00e62bc96eabf7d876933f84600a3dc5e69 (patch)
tree0a8b6e553f32f714620a2f72e05cfccc5a43a259 /drivers/gpu/drm/xe/xe_vm.c
parent9fa81f914a1ce8ee7a5a0ce6f275a636a15bb109 (diff)
downloadlwn-08a4f00e62bc96eabf7d876933f84600a3dc5e69.tar.gz
lwn-08a4f00e62bc96eabf7d876933f84600a3dc5e69.zip
drm/xe/bo: Simplify xe_bo_lock()
xe_bo_lock() was, although it only grabbed a single lock, unnecessarily using ttm_eu_reserve_buffers(). Simplify and document the interface. v2: - Update also the xe_display subsystem. v4: - Reinstate a lost dma_resv_reserve_fences(). - Improve on xe_bo_lock() documentation (Matthew Brost) Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com> Reviewed-by: Matthew Brost <matthew.brost@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20230908091716.36984-2-thomas.hellstrom@linux.intel.com Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Diffstat (limited to 'drivers/gpu/drm/xe/xe_vm.c')
-rw-r--r--drivers/gpu/drm/xe/xe_vm.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/drivers/gpu/drm/xe/xe_vm.c b/drivers/gpu/drm/xe/xe_vm.c
index 24ee74f62385..2bd1fa34256a 100644
--- a/drivers/gpu/drm/xe/xe_vm.c
+++ b/drivers/gpu/drm/xe/xe_vm.c
@@ -267,13 +267,16 @@ static void arm_preempt_fences(struct xe_vm *vm, struct list_head *list)
static int add_preempt_fences(struct xe_vm *vm, struct xe_bo *bo)
{
struct xe_exec_queue *q;
- struct ww_acquire_ctx ww;
int err;
- err = xe_bo_lock(bo, &ww, vm->preempt.num_exec_queues, true);
+ err = xe_bo_lock(bo, true);
if (err)
return err;
+ err = dma_resv_reserve_fences(bo->ttm.base.resv, vm->preempt.num_exec_queues);
+ if (err)
+ goto out_unlock;
+
list_for_each_entry(q, &vm->preempt.exec_queues, compute.link)
if (q->compute.pfence) {
dma_resv_add_fence(bo->ttm.base.resv,
@@ -281,8 +284,9 @@ static int add_preempt_fences(struct xe_vm *vm, struct xe_bo *bo)
DMA_RESV_USAGE_BOOKKEEP);
}
- xe_bo_unlock(bo, &ww);
- return 0;
+out_unlock:
+ xe_bo_unlock(bo);
+ return err;
}
/**
@@ -1033,12 +1037,11 @@ bo_has_vm_references_locked(struct xe_bo *bo, struct xe_vm *vm,
static bool bo_has_vm_references(struct xe_bo *bo, struct xe_vm *vm,
struct xe_vma *ignore)
{
- struct ww_acquire_ctx ww;
bool ret;
- xe_bo_lock(bo, &ww, 0, false);
+ xe_bo_lock(bo, false);
ret = !!bo_has_vm_references_locked(bo, vm, ignore);
- xe_bo_unlock(bo, &ww);
+ xe_bo_unlock(bo);
return ret;
}
@@ -2264,7 +2267,6 @@ vm_bind_ioctl_ops_create(struct xe_vm *vm, struct xe_bo *bo,
u32 operation, u8 tile_mask, u32 region)
{
struct drm_gem_object *obj = bo ? &bo->ttm.base : NULL;
- struct ww_acquire_ctx ww;
struct drm_gpuva_ops *ops;
struct drm_gpuva_op *__op;
struct xe_vma_op *op;
@@ -2323,7 +2325,7 @@ vm_bind_ioctl_ops_create(struct xe_vm *vm, struct xe_bo *bo,
case XE_VM_BIND_OP_UNMAP_ALL:
XE_WARN_ON(!bo);
- err = xe_bo_lock(bo, &ww, 0, true);
+ err = xe_bo_lock(bo, true);
if (err)
return ERR_PTR(err);
@@ -2333,7 +2335,7 @@ vm_bind_ioctl_ops_create(struct xe_vm *vm, struct xe_bo *bo,
ops = drm_gpuvm_bo_unmap_ops_create(vm_bo);
drm_gpuvm_bo_put(vm_bo);
- xe_bo_unlock(bo, &ww);
+ xe_bo_unlock(bo);
if (IS_ERR(ops))
return ops;
@@ -2369,13 +2371,12 @@ static struct xe_vma *new_vma(struct xe_vm *vm, struct drm_gpuva_op_map *op,
{
struct xe_bo *bo = op->gem.obj ? gem_to_xe_bo(op->gem.obj) : NULL;
struct xe_vma *vma;
- struct ww_acquire_ctx ww;
int err;
lockdep_assert_held_write(&vm->lock);
if (bo) {
- err = xe_bo_lock(bo, &ww, 0, true);
+ err = xe_bo_lock(bo, true);
if (err)
return ERR_PTR(err);
}
@@ -2384,7 +2385,7 @@ static struct xe_vma *new_vma(struct xe_vm *vm, struct drm_gpuva_op_map *op,
op->va.range - 1, read_only, is_null,
tile_mask);
if (bo)
- xe_bo_unlock(bo, &ww);
+ xe_bo_unlock(bo);
if (xe_vma_is_userptr(vma)) {
err = xe_vma_userptr_pin_pages(vma);