Commit 5bc73067 authored by Christian König's avatar Christian König Committed by Alex Deucher

drm/ttm: remove TTM_BO_PRIV_FLAG_MOVING

Instead of using the flag just remember the fence of the last move operation.

This avoids waiting for command submissions pipelined after the move, but
before accessing the BO with the CPU again.
Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Signed-off-by: default avatarChristian König <christian.koenig@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 74561cd4
...@@ -149,6 +149,7 @@ static void ttm_bo_release_list(struct kref *list_kref) ...@@ -149,6 +149,7 @@ static void ttm_bo_release_list(struct kref *list_kref)
ttm_tt_destroy(bo->ttm); ttm_tt_destroy(bo->ttm);
atomic_dec(&bo->glob->bo_count); atomic_dec(&bo->glob->bo_count);
fence_put(bo->moving);
if (bo->resv == &bo->ttm_resv) if (bo->resv == &bo->ttm_resv)
reservation_object_fini(&bo->ttm_resv); reservation_object_fini(&bo->ttm_resv);
mutex_destroy(&bo->wu_mutex); mutex_destroy(&bo->wu_mutex);
...@@ -1138,7 +1139,7 @@ int ttm_bo_init(struct ttm_bo_device *bdev, ...@@ -1138,7 +1139,7 @@ int ttm_bo_init(struct ttm_bo_device *bdev,
bo->mem.page_alignment = page_alignment; bo->mem.page_alignment = page_alignment;
bo->mem.bus.io_reserved_vm = false; bo->mem.bus.io_reserved_vm = false;
bo->mem.bus.io_reserved_count = 0; bo->mem.bus.io_reserved_count = 0;
bo->priv_flags = 0; bo->moving = NULL;
bo->mem.placement = (TTM_PL_FLAG_SYSTEM | TTM_PL_FLAG_CACHED); bo->mem.placement = (TTM_PL_FLAG_SYSTEM | TTM_PL_FLAG_CACHED);
bo->persistent_swap_storage = persistent_swap_storage; bo->persistent_swap_storage = persistent_swap_storage;
bo->acc_size = acc_size; bo->acc_size = acc_size;
...@@ -1585,7 +1586,6 @@ int ttm_bo_wait(struct ttm_buffer_object *bo, ...@@ -1585,7 +1586,6 @@ int ttm_bo_wait(struct ttm_buffer_object *bo,
return -EBUSY; return -EBUSY;
reservation_object_add_excl_fence(resv, NULL); reservation_object_add_excl_fence(resv, NULL);
clear_bit(TTM_BO_PRIV_FLAG_MOVING, &bo->priv_flags);
return 0; return 0;
} }
EXPORT_SYMBOL(ttm_bo_wait); EXPORT_SYMBOL(ttm_bo_wait);
......
...@@ -465,6 +465,7 @@ static int ttm_buffer_object_transfer(struct ttm_buffer_object *bo, ...@@ -465,6 +465,7 @@ static int ttm_buffer_object_transfer(struct ttm_buffer_object *bo,
INIT_LIST_HEAD(&fbo->lru); INIT_LIST_HEAD(&fbo->lru);
INIT_LIST_HEAD(&fbo->swap); INIT_LIST_HEAD(&fbo->swap);
INIT_LIST_HEAD(&fbo->io_reserve_lru); INIT_LIST_HEAD(&fbo->io_reserve_lru);
fbo->moving = NULL;
drm_vma_node_reset(&fbo->vma_node); drm_vma_node_reset(&fbo->vma_node);
atomic_set(&fbo->cpu_writers, 0); atomic_set(&fbo->cpu_writers, 0);
...@@ -665,7 +666,8 @@ int ttm_bo_move_accel_cleanup(struct ttm_buffer_object *bo, ...@@ -665,7 +666,8 @@ int ttm_bo_move_accel_cleanup(struct ttm_buffer_object *bo,
* operation has completed. * operation has completed.
*/ */
set_bit(TTM_BO_PRIV_FLAG_MOVING, &bo->priv_flags); fence_put(bo->moving);
bo->moving = fence_get(fence);
ret = ttm_buffer_object_transfer(bo, &ghost_obj); ret = ttm_buffer_object_transfer(bo, &ghost_obj);
if (ret) if (ret)
......
...@@ -48,15 +48,14 @@ static int ttm_bo_vm_fault_idle(struct ttm_buffer_object *bo, ...@@ -48,15 +48,14 @@ static int ttm_bo_vm_fault_idle(struct ttm_buffer_object *bo,
{ {
int ret = 0; int ret = 0;
if (likely(!test_bit(TTM_BO_PRIV_FLAG_MOVING, &bo->priv_flags))) if (likely(!bo->moving))
goto out_unlock; goto out_unlock;
/* /*
* Quick non-stalling check for idle. * Quick non-stalling check for idle.
*/ */
ret = ttm_bo_wait(bo, false, true); if (fence_is_signaled(bo->moving))
if (likely(ret == 0)) goto out_clear;
goto out_unlock;
/* /*
* If possible, avoid waiting for GPU with mmap_sem * If possible, avoid waiting for GPU with mmap_sem
...@@ -68,17 +67,23 @@ static int ttm_bo_vm_fault_idle(struct ttm_buffer_object *bo, ...@@ -68,17 +67,23 @@ static int ttm_bo_vm_fault_idle(struct ttm_buffer_object *bo,
goto out_unlock; goto out_unlock;
up_read(&vma->vm_mm->mmap_sem); up_read(&vma->vm_mm->mmap_sem);
(void) ttm_bo_wait(bo, true, false); (void) fence_wait(bo->moving, true);
goto out_unlock; goto out_unlock;
} }
/* /*
* Ordinary wait. * Ordinary wait.
*/ */
ret = ttm_bo_wait(bo, true, false); ret = fence_wait(bo->moving, true);
if (unlikely(ret != 0)) if (unlikely(ret != 0)) {
ret = (ret != -ERESTARTSYS) ? VM_FAULT_SIGBUS : ret = (ret != -ERESTARTSYS) ? VM_FAULT_SIGBUS :
VM_FAULT_NOPAGE; VM_FAULT_NOPAGE;
goto out_unlock;
}
out_clear:
fence_put(bo->moving);
bo->moving = NULL;
out_unlock: out_unlock:
return ret; return ret;
......
...@@ -173,7 +173,7 @@ struct ttm_tt; ...@@ -173,7 +173,7 @@ struct ttm_tt;
* @lru: List head for the lru list. * @lru: List head for the lru list.
* @ddestroy: List head for the delayed destroy list. * @ddestroy: List head for the delayed destroy list.
* @swap: List head for swap LRU list. * @swap: List head for swap LRU list.
* @priv_flags: Flags describing buffer object internal state. * @moving: Fence set when BO is moving
* @vma_node: Address space manager node. * @vma_node: Address space manager node.
* @offset: The current GPU offset, which can have different meanings * @offset: The current GPU offset, which can have different meanings
* depending on the memory type. For SYSTEM type memory, it should be 0. * depending on the memory type. For SYSTEM type memory, it should be 0.
...@@ -239,7 +239,7 @@ struct ttm_buffer_object { ...@@ -239,7 +239,7 @@ struct ttm_buffer_object {
* Members protected by a bo reservation. * Members protected by a bo reservation.
*/ */
unsigned long priv_flags; struct fence *moving;
struct drm_vma_offset_node vma_node; struct drm_vma_offset_node vma_node;
......
...@@ -503,9 +503,6 @@ struct ttm_bo_global { ...@@ -503,9 +503,6 @@ struct ttm_bo_global {
#define TTM_NUM_MEM_TYPES 8 #define TTM_NUM_MEM_TYPES 8
#define TTM_BO_PRIV_FLAG_MOVING 0 /* Buffer object is moving and needs
idling before CPU mapping */
#define TTM_BO_PRIV_FLAG_MAX 1
/** /**
* struct ttm_bo_device - Buffer object driver device-specific data. * struct ttm_bo_device - Buffer object driver device-specific data.
* *
......
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