Commit 9e9a153b authored by Dave Airlie's avatar Dave Airlie
Browse files

drm/ttm: move ttm binding/unbinding out of ttm_tt paths.



Move these up to the bo level, moving ttm_tt to just being
backing store. Next step is to move the bound flag out.

Reviewed-by: default avatarChristian König <christian.koenig@amd.com>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200915024007.67163-6-airlied@gmail.com
parent 2040ec97
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -552,7 +552,7 @@ static int amdgpu_move_vram_ram(struct ttm_buffer_object *bo, bool evict,
		goto out_cleanup;

	/* Bind the memory to the GTT space */
	r = ttm_tt_bind(bo->bdev, bo->ttm, &tmp_mem);
	r = ttm_bo_tt_bind(bo, &tmp_mem);
	if (unlikely(r)) {
		goto out_cleanup;
	}
+1 −1
Original line number Diff line number Diff line
@@ -924,7 +924,7 @@ nouveau_bo_move_flipd(struct ttm_buffer_object *bo, bool evict, bool intr,
	if (ret)
		goto out;

	ret = ttm_tt_bind(bo->bdev, bo->ttm, &tmp_reg);
	ret = ttm_bo_tt_bind(bo, &tmp_reg);
	if (ret)
		goto out;

+1 −1
Original line number Diff line number Diff line
@@ -53,7 +53,7 @@ static bool radeon_mn_invalidate(struct mmu_interval_notifier *mn,
	struct ttm_operation_ctx ctx = { false, false };
	long r;

	if (!bo->tbo.ttm || !ttm_tt_is_bound(bo->tbo.ttm))
	if (!bo->tbo.ttm || !ttm_bo_tt_is_bound(&bo->tbo))
		return true;

	if (!mmu_notifier_range_blockable(range))
+1 −1
Original line number Diff line number Diff line
@@ -238,7 +238,7 @@ static int radeon_move_vram_ram(struct ttm_buffer_object *bo,
		goto out_cleanup;
	}

	r = ttm_tt_bind(bo->bdev, bo->ttm, &tmp_mem);
	r = ttm_bo_tt_bind(bo, &tmp_mem);
	if (unlikely(r)) {
		goto out_cleanup;
	}
+30 −1
Original line number Diff line number Diff line
@@ -264,7 +264,7 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
			if (ret)
				goto out_err;

			ret = ttm_tt_bind(bdev, bo->ttm, mem);
			ret = ttm_bo_tt_bind(bo, mem);
			if (ret)
				goto out_err;
		}
@@ -1619,6 +1619,35 @@ void ttm_bo_tt_destroy(struct ttm_buffer_object *bo)
{
	if (bo->ttm == NULL)
		return;

	ttm_bo_tt_unbind(bo);
	ttm_tt_destroy(bo->bdev, bo->ttm);
	bo->ttm = NULL;
}

int ttm_bo_tt_bind(struct ttm_buffer_object *bo, struct ttm_resource *mem)
{
	int ret;

	if (!bo->ttm)
		return -EINVAL;

	if (ttm_bo_tt_is_bound(bo))
		return 0;

	ret = bo->bdev->driver->ttm_tt_bind(bo->bdev, bo->ttm, mem);
	if (unlikely(ret != 0))
		return ret;

	ttm_bo_tt_set_bound(bo);
	return 0;
}
EXPORT_SYMBOL(ttm_bo_tt_bind);

void ttm_bo_tt_unbind(struct ttm_buffer_object *bo)
{
	if (ttm_bo_tt_is_bound(bo)) {
		bo->bdev->driver->ttm_tt_unbind(bo->bdev, bo->ttm);
		ttm_bo_tt_set_unbound(bo);
	}
}
Loading