Commit 86008a75 authored by Dave Airlie's avatar Dave Airlie
Browse files

drm/ttm: add optional bind/unbind via driver.

parent ecfe6953
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
@@ -222,6 +222,9 @@ void ttm_tt_destroy(struct ttm_bo_device *bdev, struct ttm_tt *ttm)
		fput(ttm->swap_storage);

	ttm->swap_storage = NULL;
	if (bdev->driver->ttm_tt_destroy)
		bdev->driver->ttm_tt_destroy(bdev, ttm);
	else
		ttm->func->destroy(bdev, ttm);
}

@@ -310,6 +313,9 @@ EXPORT_SYMBOL(ttm_dma_tt_fini);
void ttm_tt_unbind(struct ttm_bo_device *bdev, struct ttm_tt *ttm)
{
	if (ttm->state == tt_bound) {
		if (bdev->driver->ttm_tt_unbind)
			bdev->driver->ttm_tt_unbind(bdev, ttm);
		else
			ttm->func->unbind(bdev, ttm);
		ttm->state = tt_unbound;
	}
@@ -331,6 +337,9 @@ int ttm_tt_bind(struct ttm_bo_device *bdev,
	if (ret)
		return ret;

	if (bdev->driver->ttm_tt_bind)
		ret = bdev->driver->ttm_tt_bind(bdev, ttm, bo_mem);
	else
		ret = ttm->func->bind(bdev, ttm, bo_mem);
	if (unlikely(ret != 0))
		return ret;
+36 −0
Original line number Diff line number Diff line
@@ -90,6 +90,42 @@ struct ttm_bo_driver {
	 */
	void (*ttm_tt_unpopulate)(struct ttm_bo_device *bdev, struct ttm_tt *ttm);

	/**
	 * ttm_tt_bind
	 *
	 * @bdev: Pointer to a ttm device
	 * @ttm: Pointer to a struct ttm_tt.
	 * @bo_mem: Pointer to a struct ttm_resource describing the
	 * memory type and location for binding.
	 *
	 * Bind the backend pages into the aperture in the location
	 * indicated by @bo_mem. This function should be able to handle
	 * differences between aperture and system page sizes.
	 */
	int (*ttm_tt_bind)(struct ttm_bo_device *bdev, struct ttm_tt *ttm, struct ttm_resource *bo_mem);

	/**
	 * ttm_tt_unbind
	 *
	 * @bdev: Pointer to a ttm device
	 * @ttm: Pointer to a struct ttm_tt.
	 *
	 * Unbind previously bound backend pages. This function should be
	 * able to handle differences between aperture and system page sizes.
	 */
	void (*ttm_tt_unbind)(struct ttm_bo_device *bdev, struct ttm_tt *ttm);

	/**
	 * ttm_tt_destroy
	 *
	 * @bdev: Pointer to a ttm device
	 * @ttm: Pointer to a struct ttm_tt.
	 *
	 * Destroy the backend. This will be call back from ttm_tt_destroy so
	 * don't call ttm_tt_destroy from the callback or infinite loop.
	 */
	void (*ttm_tt_destroy)(struct ttm_bo_device *bdev, struct ttm_tt *ttm);

	/**
	 * struct ttm_bo_driver member eviction_valuable
	 *