drm/ttm: split populate out from binding.

Drivers have to call populate themselves now before binding.

Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200915024007.67163-5-airlied@gmail.com
This commit is contained in:
Dave Airlie
2020-09-15 11:16:53 +10:00
parent 395a73f8ba
commit 2040ec970e
7 changed files with 33 additions and 13 deletions

View File

@@ -260,7 +260,11 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
goto out_err;
if (mem->mem_type != TTM_PL_SYSTEM) {
ret = ttm_tt_bind(bdev, bo->ttm, mem, ctx);
ret = ttm_tt_populate(bdev, bo->ttm, ctx);
if (ret)
goto out_err;
ret = ttm_tt_bind(bdev, bo->ttm, mem);
if (ret)
goto out_err;
}

View File

@@ -77,7 +77,12 @@ int ttm_bo_move_ttm(struct ttm_buffer_object *bo,
return ret;
if (new_mem->mem_type != TTM_PL_SYSTEM) {
ret = ttm_tt_bind(bo->bdev, ttm, new_mem, ctx);
ret = ttm_tt_populate(bo->bdev, ttm, ctx);
if (unlikely(ret != 0))
return ret;
ret = ttm_tt_bind(bo->bdev, ttm, new_mem);
if (unlikely(ret != 0))
return ret;
}

View File

@@ -312,8 +312,7 @@ void ttm_tt_unbind(struct ttm_bo_device *bdev, struct ttm_tt *ttm)
}
int ttm_tt_bind(struct ttm_bo_device *bdev,
struct ttm_tt *ttm, struct ttm_resource *bo_mem,
struct ttm_operation_ctx *ctx)
struct ttm_tt *ttm, struct ttm_resource *bo_mem)
{
int ret = 0;
@@ -323,10 +322,6 @@ int ttm_tt_bind(struct ttm_bo_device *bdev,
if (ttm_tt_is_bound(ttm))
return 0;
ret = ttm_tt_populate(bdev, ttm, ctx);
if (ret)
return ret;
ret = bdev->driver->ttm_tt_bind(bdev, ttm, bo_mem);
if (unlikely(ret != 0))
return ret;
@@ -455,6 +450,9 @@ int ttm_tt_populate(struct ttm_bo_device *bdev,
{
int ret;
if (!ttm)
return -EINVAL;
if (ttm_tt_is_populated(ttm))
return 0;
@@ -466,6 +464,7 @@ int ttm_tt_populate(struct ttm_bo_device *bdev,
ttm_tt_add_mapping(bdev, ttm);
return ret;
}
EXPORT_SYMBOL(ttm_tt_populate);
static void ttm_tt_clear_mapping(struct ttm_tt *ttm)
{