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

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
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -2447,6 +2447,8 @@ int amdgpu_amdkfd_gpuvm_restore_process_bos(void *info, struct dma_fence **ef)
		struct amdgpu_bo *bo = mem->bo;
		uint32_t domain = mem->domain;
		struct kfd_mem_attachment *attachment;
		struct dma_resv_iter cursor;
		struct dma_fence *fence;

		total_size += amdgpu_bo_size(bo);

@@ -2461,11 +2463,14 @@ int amdgpu_amdkfd_gpuvm_restore_process_bos(void *info, struct dma_fence **ef)
				goto validate_map_fail;
			}
		}
		ret = amdgpu_sync_fence(&sync_obj, bo->tbo.moving);
		dma_resv_for_each_fence(&cursor, bo->tbo.base.resv,
					DMA_RESV_USAGE_KERNEL, fence) {
			ret = amdgpu_sync_fence(&sync_obj, fence);
			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) {
			if (!attachment->is_mapped)
				continue;
+2 −3
Original line number Diff line number Diff line
@@ -612,9 +612,8 @@ int amdgpu_bo_create(struct amdgpu_device *adev,
		if (unlikely(r))
			goto fail_unreserve;

		amdgpu_bo_fence(bo, fence, false);
		dma_fence_put(bo->tbo.moving);
		bo->tbo.moving = dma_fence_get(fence);
		dma_resv_add_fence(bo->tbo.base.resv, fence,
				   DMA_RESV_USAGE_KERNEL);
		dma_fence_put(fence);
	}
	if (!bp->resv)
+5 −6
Original line number Diff line number Diff line
@@ -74,13 +74,12 @@ static int amdgpu_vm_cpu_update(struct amdgpu_vm_update_params *p,
{
	unsigned int i;
	uint64_t value;
	int r;
	long r;

	if (vmbo->bo.tbo.moving) {
		r = dma_fence_wait(vmbo->bo.tbo.moving, true);
		if (r)
	r = dma_resv_wait_timeout(vmbo->bo.tbo.base.resv, DMA_RESV_USAGE_KERNEL,
				  true, MAX_SCHEDULE_TIMEOUT);
	if (r < 0)
		return r;
	}

	pe += (unsigned long)amdgpu_bo_kptr(&vmbo->bo);

+8 −3
Original line number Diff line number Diff line
@@ -204,14 +204,19 @@ static int amdgpu_vm_sdma_update(struct amdgpu_vm_update_params *p,
	struct amdgpu_bo *bo = &vmbo->bo;
	enum amdgpu_ib_pool_type pool = p->immediate ? AMDGPU_IB_POOL_IMMEDIATE
		: AMDGPU_IB_POOL_DELAYED;
	struct dma_resv_iter cursor;
	unsigned int i, ndw, nptes;
	struct dma_fence *fence;
	uint64_t *pte;
	int r;

	/* 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,
				DMA_RESV_USAGE_KERNEL, fence) {
		r = amdgpu_sync_fence(&p->job->sync, fence);
		if (r)
			return r;
	}

	do {
		ndw = p->num_dw_left;
+2 −8
Original line number Diff line number Diff line
@@ -418,7 +418,6 @@ static void ttm_bo_release(struct kref *kref)
	dma_resv_unlock(bo->base.resv);

	atomic_dec(&ttm_glob.bo_count);
	dma_fence_put(bo->moving);
	bo->destroy(bo);
}

@@ -714,9 +713,8 @@ void ttm_bo_unpin(struct ttm_buffer_object *bo)
EXPORT_SYMBOL(ttm_bo_unpin);

/*
 * Add the last move fence to the BO and reserve a new shared slot. We only use
 * a shared slot to avoid unecessary sync and rely on the subsequent bo move to
 * either stall or use an exclusive fence respectively set bo->moving.
 * Add the last move fence to the BO as kernel dependency and reserve a new
 * fence slot.
 */
static int ttm_bo_add_move_fence(struct ttm_buffer_object *bo,
				 struct ttm_resource_manager *man,
@@ -746,9 +744,6 @@ static int ttm_bo_add_move_fence(struct ttm_buffer_object *bo,
		dma_fence_put(fence);
		return ret;
	}

	dma_fence_put(bo->moving);
	bo->moving = fence;
	return 0;
}

@@ -951,7 +946,6 @@ int ttm_bo_init_reserved(struct ttm_device *bdev,
	bo->bdev = bdev;
	bo->type = type;
	bo->page_alignment = page_alignment;
	bo->moving = NULL;
	bo->pin_count = 0;
	bo->sg = sg;
	bo->bulk_move = NULL;
Loading