Commit 8bb31587 authored by Christian König's avatar Christian König

drm/ttm: remove bo->moving

This is now handled by the DMA-buf framework in the dma_resv obj.

Also remove the workaround inside VMWGFX to update the moving fence.
Signed-off-by: default avatarChristian König <christian.koenig@amd.com>
Reviewed-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20220407085946.744568-14-christian.koenig@amd.com
parent 1d7f5e6c
...@@ -2447,6 +2447,8 @@ int amdgpu_amdkfd_gpuvm_restore_process_bos(void *info, struct dma_fence **ef) ...@@ -2447,6 +2447,8 @@ int amdgpu_amdkfd_gpuvm_restore_process_bos(void *info, struct dma_fence **ef)
struct amdgpu_bo *bo = mem->bo; struct amdgpu_bo *bo = mem->bo;
uint32_t domain = mem->domain; uint32_t domain = mem->domain;
struct kfd_mem_attachment *attachment; struct kfd_mem_attachment *attachment;
struct dma_resv_iter cursor;
struct dma_fence *fence;
total_size += amdgpu_bo_size(bo); total_size += amdgpu_bo_size(bo);
...@@ -2461,10 +2463,13 @@ int amdgpu_amdkfd_gpuvm_restore_process_bos(void *info, struct dma_fence **ef) ...@@ -2461,10 +2463,13 @@ int amdgpu_amdkfd_gpuvm_restore_process_bos(void *info, struct dma_fence **ef)
goto validate_map_fail; goto validate_map_fail;
} }
} }
ret = amdgpu_sync_fence(&sync_obj, bo->tbo.moving); dma_resv_for_each_fence(&cursor, bo->tbo.base.resv,
if (ret) { DMA_RESV_USAGE_KERNEL, fence) {
pr_debug("Memory eviction: Sync BO fence failed. Try again\n"); ret = amdgpu_sync_fence(&sync_obj, fence);
goto validate_map_fail; if (ret) {
pr_debug("Memory eviction: Sync BO fence failed. Try again\n");
goto validate_map_fail;
}
} }
list_for_each_entry(attachment, &mem->attachments, list) { list_for_each_entry(attachment, &mem->attachments, list) {
if (!attachment->is_mapped) if (!attachment->is_mapped)
......
...@@ -612,9 +612,8 @@ int amdgpu_bo_create(struct amdgpu_device *adev, ...@@ -612,9 +612,8 @@ int amdgpu_bo_create(struct amdgpu_device *adev,
if (unlikely(r)) if (unlikely(r))
goto fail_unreserve; goto fail_unreserve;
amdgpu_bo_fence(bo, fence, false); dma_resv_add_fence(bo->tbo.base.resv, fence,
dma_fence_put(bo->tbo.moving); DMA_RESV_USAGE_KERNEL);
bo->tbo.moving = dma_fence_get(fence);
dma_fence_put(fence); dma_fence_put(fence);
} }
if (!bp->resv) if (!bp->resv)
......
...@@ -74,13 +74,12 @@ static int amdgpu_vm_cpu_update(struct amdgpu_vm_update_params *p, ...@@ -74,13 +74,12 @@ static int amdgpu_vm_cpu_update(struct amdgpu_vm_update_params *p,
{ {
unsigned int i; unsigned int i;
uint64_t value; uint64_t value;
int r; long r;
if (vmbo->bo.tbo.moving) { r = dma_resv_wait_timeout(vmbo->bo.tbo.base.resv, DMA_RESV_USAGE_KERNEL,
r = dma_fence_wait(vmbo->bo.tbo.moving, true); true, MAX_SCHEDULE_TIMEOUT);
if (r) if (r < 0)
return r; return r;
}
pe += (unsigned long)amdgpu_bo_kptr(&vmbo->bo); pe += (unsigned long)amdgpu_bo_kptr(&vmbo->bo);
......
...@@ -204,14 +204,19 @@ static int amdgpu_vm_sdma_update(struct amdgpu_vm_update_params *p, ...@@ -204,14 +204,19 @@ static int amdgpu_vm_sdma_update(struct amdgpu_vm_update_params *p,
struct amdgpu_bo *bo = &vmbo->bo; struct amdgpu_bo *bo = &vmbo->bo;
enum amdgpu_ib_pool_type pool = p->immediate ? AMDGPU_IB_POOL_IMMEDIATE enum amdgpu_ib_pool_type pool = p->immediate ? AMDGPU_IB_POOL_IMMEDIATE
: AMDGPU_IB_POOL_DELAYED; : AMDGPU_IB_POOL_DELAYED;
struct dma_resv_iter cursor;
unsigned int i, ndw, nptes; unsigned int i, ndw, nptes;
struct dma_fence *fence;
uint64_t *pte; uint64_t *pte;
int r; int r;
/* Wait for PD/PT moves to be completed */ /* Wait for PD/PT moves to be completed */
r = amdgpu_sync_fence(&p->job->sync, bo->tbo.moving); dma_resv_for_each_fence(&cursor, bo->tbo.base.resv,
if (r) DMA_RESV_USAGE_KERNEL, fence) {
return r; r = amdgpu_sync_fence(&p->job->sync, fence);
if (r)
return r;
}
do { do {
ndw = p->num_dw_left; ndw = p->num_dw_left;
......
...@@ -418,7 +418,6 @@ static void ttm_bo_release(struct kref *kref) ...@@ -418,7 +418,6 @@ static void ttm_bo_release(struct kref *kref)
dma_resv_unlock(bo->base.resv); dma_resv_unlock(bo->base.resv);
atomic_dec(&ttm_glob.bo_count); atomic_dec(&ttm_glob.bo_count);
dma_fence_put(bo->moving);
bo->destroy(bo); bo->destroy(bo);
} }
...@@ -714,9 +713,8 @@ void ttm_bo_unpin(struct ttm_buffer_object *bo) ...@@ -714,9 +713,8 @@ void ttm_bo_unpin(struct ttm_buffer_object *bo)
EXPORT_SYMBOL(ttm_bo_unpin); EXPORT_SYMBOL(ttm_bo_unpin);
/* /*
* Add the last move fence to the BO and reserve a new shared slot. We only use * Add the last move fence to the BO as kernel dependency and reserve a new
* a shared slot to avoid unecessary sync and rely on the subsequent bo move to * fence slot.
* either stall or use an exclusive fence respectively set bo->moving.
*/ */
static int ttm_bo_add_move_fence(struct ttm_buffer_object *bo, static int ttm_bo_add_move_fence(struct ttm_buffer_object *bo,
struct ttm_resource_manager *man, struct ttm_resource_manager *man,
...@@ -746,9 +744,6 @@ static int ttm_bo_add_move_fence(struct ttm_buffer_object *bo, ...@@ -746,9 +744,6 @@ static int ttm_bo_add_move_fence(struct ttm_buffer_object *bo,
dma_fence_put(fence); dma_fence_put(fence);
return ret; return ret;
} }
dma_fence_put(bo->moving);
bo->moving = fence;
return 0; return 0;
} }
...@@ -951,7 +946,6 @@ int ttm_bo_init_reserved(struct ttm_device *bdev, ...@@ -951,7 +946,6 @@ int ttm_bo_init_reserved(struct ttm_device *bdev,
bo->bdev = bdev; bo->bdev = bdev;
bo->type = type; bo->type = type;
bo->page_alignment = page_alignment; bo->page_alignment = page_alignment;
bo->moving = NULL;
bo->pin_count = 0; bo->pin_count = 0;
bo->sg = sg; bo->sg = sg;
bo->bulk_move = NULL; bo->bulk_move = NULL;
......
...@@ -228,7 +228,6 @@ static int ttm_buffer_object_transfer(struct ttm_buffer_object *bo, ...@@ -228,7 +228,6 @@ static int ttm_buffer_object_transfer(struct ttm_buffer_object *bo,
atomic_inc(&ttm_glob.bo_count); atomic_inc(&ttm_glob.bo_count);
INIT_LIST_HEAD(&fbo->base.ddestroy); INIT_LIST_HEAD(&fbo->base.ddestroy);
fbo->base.moving = NULL;
drm_vma_node_reset(&fbo->base.base.vma_node); drm_vma_node_reset(&fbo->base.base.vma_node);
kref_init(&fbo->base.kref); kref_init(&fbo->base.kref);
...@@ -500,9 +499,6 @@ static int ttm_bo_move_to_ghost(struct ttm_buffer_object *bo, ...@@ -500,9 +499,6 @@ static int ttm_bo_move_to_ghost(struct ttm_buffer_object *bo,
* operation has completed. * operation has completed.
*/ */
dma_fence_put(bo->moving);
bo->moving = dma_fence_get(fence);
ret = ttm_buffer_object_transfer(bo, &ghost_obj); ret = ttm_buffer_object_transfer(bo, &ghost_obj);
if (ret) if (ret)
return ret; return ret;
...@@ -546,9 +542,6 @@ static void ttm_bo_move_pipeline_evict(struct ttm_buffer_object *bo, ...@@ -546,9 +542,6 @@ static void ttm_bo_move_pipeline_evict(struct ttm_buffer_object *bo,
spin_unlock(&from->move_lock); spin_unlock(&from->move_lock);
ttm_resource_free(bo, &bo->resource); ttm_resource_free(bo, &bo->resource);
dma_fence_put(bo->moving);
bo->moving = dma_fence_get(fence);
} }
int ttm_bo_move_accel_cleanup(struct ttm_buffer_object *bo, int ttm_bo_move_accel_cleanup(struct ttm_buffer_object *bo,
......
...@@ -46,17 +46,13 @@ ...@@ -46,17 +46,13 @@
static vm_fault_t ttm_bo_vm_fault_idle(struct ttm_buffer_object *bo, static vm_fault_t ttm_bo_vm_fault_idle(struct ttm_buffer_object *bo,
struct vm_fault *vmf) struct vm_fault *vmf)
{ {
vm_fault_t ret = 0; long err = 0;
int err = 0;
if (likely(!bo->moving))
goto out_unlock;
/* /*
* Quick non-stalling check for idle. * Quick non-stalling check for idle.
*/ */
if (dma_fence_is_signaled(bo->moving)) if (dma_resv_test_signaled(bo->base.resv, DMA_RESV_USAGE_KERNEL))
goto out_clear; return 0;
/* /*
* If possible, avoid waiting for GPU with mmap_lock * If possible, avoid waiting for GPU with mmap_lock
...@@ -64,34 +60,30 @@ static vm_fault_t ttm_bo_vm_fault_idle(struct ttm_buffer_object *bo, ...@@ -64,34 +60,30 @@ static vm_fault_t ttm_bo_vm_fault_idle(struct ttm_buffer_object *bo,
* is the first attempt. * is the first attempt.
*/ */
if (fault_flag_allow_retry_first(vmf->flags)) { if (fault_flag_allow_retry_first(vmf->flags)) {
ret = VM_FAULT_RETRY;
if (vmf->flags & FAULT_FLAG_RETRY_NOWAIT) if (vmf->flags & FAULT_FLAG_RETRY_NOWAIT)
goto out_unlock; return VM_FAULT_RETRY;
ttm_bo_get(bo); ttm_bo_get(bo);
mmap_read_unlock(vmf->vma->vm_mm); mmap_read_unlock(vmf->vma->vm_mm);
(void) dma_fence_wait(bo->moving, true); (void)dma_resv_wait_timeout(bo->base.resv,
DMA_RESV_USAGE_KERNEL, true,
MAX_SCHEDULE_TIMEOUT);
dma_resv_unlock(bo->base.resv); dma_resv_unlock(bo->base.resv);
ttm_bo_put(bo); ttm_bo_put(bo);
goto out_unlock; return VM_FAULT_RETRY;
} }
/* /*
* Ordinary wait. * Ordinary wait.
*/ */
err = dma_fence_wait(bo->moving, true); err = dma_resv_wait_timeout(bo->base.resv, DMA_RESV_USAGE_KERNEL, true,
if (unlikely(err != 0)) { MAX_SCHEDULE_TIMEOUT);
ret = (err != -ERESTARTSYS) ? VM_FAULT_SIGBUS : if (unlikely(err < 0)) {
return (err != -ERESTARTSYS) ? VM_FAULT_SIGBUS :
VM_FAULT_NOPAGE; VM_FAULT_NOPAGE;
goto out_unlock;
} }
out_clear: return 0;
dma_fence_put(bo->moving);
bo->moving = NULL;
out_unlock:
return ret;
} }
static unsigned long ttm_bo_io_mem_pfn(struct ttm_buffer_object *bo, static unsigned long ttm_bo_io_mem_pfn(struct ttm_buffer_object *bo,
......
...@@ -1161,12 +1161,6 @@ int vmw_resources_clean(struct vmw_buffer_object *vbo, pgoff_t start, ...@@ -1161,12 +1161,6 @@ int vmw_resources_clean(struct vmw_buffer_object *vbo, pgoff_t start,
*num_prefault = __KERNEL_DIV_ROUND_UP(last_cleaned - res_start, *num_prefault = __KERNEL_DIV_ROUND_UP(last_cleaned - res_start,
PAGE_SIZE); PAGE_SIZE);
vmw_bo_fence_single(bo, NULL); vmw_bo_fence_single(bo, NULL);
if (bo->moving)
dma_fence_put(bo->moving);
return dma_resv_get_singleton(bo->base.resv,
DMA_RESV_USAGE_WRITE,
&bo->moving);
} }
return 0; return 0;
......
...@@ -94,7 +94,6 @@ struct ttm_tt; ...@@ -94,7 +94,6 @@ struct ttm_tt;
* @deleted: True if the object is only a zombie and already deleted. * @deleted: True if the object is only a zombie and already deleted.
* @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.
* @moving: Fence set when BO is moving
* @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.
* @cur_placement: Hint of current placement. * @cur_placement: Hint of current placement.
...@@ -147,7 +146,6 @@ struct ttm_buffer_object { ...@@ -147,7 +146,6 @@ struct ttm_buffer_object {
* Members protected by a bo reservation. * Members protected by a bo reservation.
*/ */
struct dma_fence *moving;
unsigned priority; unsigned priority;
unsigned pin_count; unsigned pin_count;
......
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