Commit 7eec9151 authored by Dave Airlie's avatar Dave Airlie
Browse files

drm/ttm/tt: add wrappers to set tt state.



This adds 2 getters and 4 setters, however unbound and populated
are currently the same thing, this will change, it also drops
a BUG_ON that seems not that useful.

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-2-airlied@gmail.com
parent 9c3006a4
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1304,7 +1304,7 @@ static int amdgpu_ttm_tt_populate(struct ttm_bo_device *bdev,
			return -ENOMEM;

		ttm->page_flags |= TTM_PAGE_FLAG_SG;
		ttm->state = tt_unbound;
		ttm_tt_set_populated(ttm);
		return 0;
	}

@@ -1324,7 +1324,7 @@ static int amdgpu_ttm_tt_populate(struct ttm_bo_device *bdev,
		drm_prime_sg_to_page_addr_arrays(ttm->sg, ttm->pages,
						 gtt->ttm.dma_address,
						 ttm->num_pages);
		ttm->state = tt_unbound;
		ttm_tt_set_populated(ttm);
		return 0;
	}

+2 −2
Original line number Diff line number Diff line
@@ -1298,14 +1298,14 @@ nouveau_ttm_tt_populate(struct ttm_bo_device *bdev,
	struct device *dev;
	bool slave = !!(ttm->page_flags & TTM_PAGE_FLAG_SG);

	if (ttm->state != tt_unpopulated)
	if (ttm_tt_is_populated(ttm))
		return 0;

	if (slave && ttm->sg) {
		/* make userspace faulting work */
		drm_prime_sg_to_page_addr_arrays(ttm->sg, ttm->pages,
						 ttm_dma->dma_address, ttm->num_pages);
		ttm->state = tt_unbound;
		ttm_tt_set_populated(ttm);
		return 0;
	}

+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 || bo->tbo.ttm->state != tt_bound)
	if (!bo->tbo.ttm || !ttm_tt_is_bound(bo->tbo.ttm))
		return true;

	if (!mmu_notifier_range_blockable(range))
+2 −2
Original line number Diff line number Diff line
@@ -611,14 +611,14 @@ static int radeon_ttm_tt_populate(struct ttm_bo_device *bdev,
			return -ENOMEM;

		ttm->page_flags |= TTM_PAGE_FLAG_SG;
		ttm->state = tt_unbound;
		ttm_tt_set_populated(ttm);
		return 0;
	}

	if (slave && ttm->sg) {
		drm_prime_sg_to_page_addr_arrays(ttm->sg, ttm->pages,
						 gtt->ttm.dma_address, ttm->num_pages);
		ttm->state = tt_unbound;
		ttm_tt_set_populated(ttm);
		return 0;
	}

+1 −1
Original line number Diff line number Diff line
@@ -249,7 +249,7 @@ int ttm_bo_move_memcpy(struct ttm_buffer_object *bo,
	 * Don't move nonexistent data. Clear destination instead.
	 */
	if (old_iomap == NULL &&
	    (ttm == NULL || (ttm->state == tt_unpopulated &&
	    (ttm == NULL || (!ttm_tt_is_populated(ttm) &&
			     !(ttm->page_flags & TTM_PAGE_FLAG_SWAPPED)))) {
		memset_io(new_iomap, 0, new_mem->num_pages*PAGE_SIZE);
		goto out2;
Loading