Commit 87ed9423 authored by Dave Airlie's avatar Dave Airlie

drm/ttm: refactor out common code to setup a new tt backed resource

This factors out the code to setup non-system tt.

The same code was used twice in the move paths.
Reviewed-by: default avatarBen Skeggs <bskeggs@redhat.com>
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/20201019071314.1671485-2-airlied@gmail.com
parent cf40c660
...@@ -252,15 +252,9 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo, ...@@ -252,15 +252,9 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
if (ret) if (ret)
goto out_err; goto out_err;
if (mem->mem_type != TTM_PL_SYSTEM) { ret = ttm_bo_move_to_new_tt_mem(bo, ctx, mem);
ret = ttm_tt_populate(bdev, bo->ttm, ctx);
if (ret) if (ret)
goto out_err; goto out_err;
ret = ttm_bo_tt_bind(bo, mem);
if (ret)
goto out_err;
}
} }
if (bdev->driver->move_notify) if (bdev->driver->move_notify)
......
...@@ -45,11 +45,30 @@ struct ttm_transfer_obj { ...@@ -45,11 +45,30 @@ struct ttm_transfer_obj {
struct ttm_buffer_object *bo; struct ttm_buffer_object *bo;
}; };
int ttm_bo_move_to_new_tt_mem(struct ttm_buffer_object *bo,
struct ttm_operation_ctx *ctx,
struct ttm_resource *new_mem)
{
int ret;
if (new_mem->mem_type == TTM_PL_SYSTEM)
return 0;
ret = ttm_tt_populate(bo->bdev, bo->ttm, ctx);
if (unlikely(ret != 0))
return ret;
ret = ttm_bo_tt_bind(bo, new_mem);
if (unlikely(ret != 0))
return ret;
return 0;
}
int ttm_bo_move_ttm(struct ttm_buffer_object *bo, int ttm_bo_move_ttm(struct ttm_buffer_object *bo,
struct ttm_operation_ctx *ctx, struct ttm_operation_ctx *ctx,
struct ttm_resource *new_mem) struct ttm_resource *new_mem)
{ {
struct ttm_tt *ttm = bo->ttm;
struct ttm_resource *old_mem = &bo->mem; struct ttm_resource *old_mem = &bo->mem;
int ret; int ret;
...@@ -67,16 +86,9 @@ int ttm_bo_move_ttm(struct ttm_buffer_object *bo, ...@@ -67,16 +86,9 @@ int ttm_bo_move_ttm(struct ttm_buffer_object *bo,
old_mem->mem_type = TTM_PL_SYSTEM; old_mem->mem_type = TTM_PL_SYSTEM;
} }
if (new_mem->mem_type != TTM_PL_SYSTEM) { ret = ttm_bo_move_to_new_tt_mem(bo, ctx, new_mem);
ret = ttm_tt_populate(bo->bdev, ttm, ctx);
if (unlikely(ret != 0))
return ret;
ret = ttm_bo_tt_bind(bo, new_mem);
if (unlikely(ret != 0)) if (unlikely(ret != 0))
return ret; return ret;
}
ttm_bo_assign_mem(bo, new_mem); ttm_bo_assign_mem(bo, new_mem);
return 0; return 0;
......
...@@ -593,6 +593,10 @@ int ttm_bo_move_ttm(struct ttm_buffer_object *bo, ...@@ -593,6 +593,10 @@ int ttm_bo_move_ttm(struct ttm_buffer_object *bo,
struct ttm_operation_ctx *ctx, struct ttm_operation_ctx *ctx,
struct ttm_resource *new_mem); struct ttm_resource *new_mem);
int ttm_bo_move_to_new_tt_mem(struct ttm_buffer_object *bo,
struct ttm_operation_ctx *ctx,
struct ttm_resource *new_mem);
/** /**
* ttm_bo_move_memcpy * ttm_bo_move_memcpy
* *
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment