diff options
author | Thomas Hellström <thomas.hellstrom@linux.intel.com> | 2023-09-08 11:17:11 +0200 |
---|---|---|
committer | Rodrigo Vivi <rodrigo.vivi@intel.com> | 2023-12-21 11:41:06 -0500 |
commit | 08a4f00e62bc96eabf7d876933f84600a3dc5e69 (patch) | |
tree | 0a8b6e553f32f714620a2f72e05cfccc5a43a259 /drivers/gpu/drm/xe/xe_bo.c | |
parent | 9fa81f914a1ce8ee7a5a0ce6f275a636a15bb109 (diff) |
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_bo.c')
-rw-r--r-- | drivers/gpu/drm/xe/xe_bo.c | 43 |
1 files changed, 26 insertions, 17 deletions
diff --git a/drivers/gpu/drm/xe/xe_bo.c b/drivers/gpu/drm/xe/xe_bo.c index 3cfd3f37c81e..ee8e3c940cf4 100644 --- a/drivers/gpu/drm/xe/xe_bo.c +++ b/drivers/gpu/drm/xe/xe_bo.c @@ -1082,13 +1082,11 @@ static void xe_gem_object_close(struct drm_gem_object *obj, struct xe_bo *bo = gem_to_xe_bo(obj); if (bo->vm && !xe_vm_in_fault_mode(bo->vm)) { - struct ww_acquire_ctx ww; - XE_WARN_ON(!xe_bo_is_user(bo)); - xe_bo_lock(bo, &ww, 0, false); + xe_bo_lock(bo, false); ttm_bo_set_bulk_move(&bo->ttm, NULL); - xe_bo_unlock(bo, &ww); + xe_bo_unlock(bo); } } @@ -1873,26 +1871,37 @@ int xe_gem_mmap_offset_ioctl(struct drm_device *dev, void *data, return 0; } -int xe_bo_lock(struct xe_bo *bo, struct ww_acquire_ctx *ww, - int num_resv, bool intr) +/** + * xe_bo_lock() - Lock the buffer object's dma_resv object + * @bo: The struct xe_bo whose lock is to be taken + * @intr: Whether to perform any wait interruptible + * + * Locks the buffer object's dma_resv object. If the buffer object is + * pointing to a shared dma_resv object, that shared lock is locked. + * + * Return: 0 on success, -EINTR if @intr is true and the wait for a + * contended lock was interrupted. If @intr is set to false, the + * function always returns 0. + */ +int xe_bo_lock(struct xe_bo *bo, bool intr) { - struct ttm_validate_buffer tv_bo; - LIST_HEAD(objs); - LIST_HEAD(dups); + if (intr) + return dma_resv_lock_interruptible(bo->ttm.base.resv, NULL); - XE_WARN_ON(!ww); + dma_resv_lock(bo->ttm.base.resv, NULL); - tv_bo.num_shared = num_resv; - tv_bo.bo = &bo->ttm; - list_add_tail(&tv_bo.head, &objs); - - return ttm_eu_reserve_buffers(ww, &objs, intr, &dups); + return 0; } -void xe_bo_unlock(struct xe_bo *bo, struct ww_acquire_ctx *ww) +/** + * xe_bo_unlock() - Unlock the buffer object's dma_resv object + * @bo: The struct xe_bo whose lock is to be released. + * + * Unlock a buffer object lock that was locked by xe_bo_lock(). + */ +void xe_bo_unlock(struct xe_bo *bo) { dma_resv_unlock(bo->ttm.base.resv); - ww_acquire_fini(ww); } /** |