aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/drivers/gpu/drm/ttm/ttm_bo_util.c
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2020-10-19 17:13:11 +1000
committerDave Airlie <airlied@redhat.com>2020-10-20 05:03:53 +1000
commitb8b99c7ddccea56b0ac589e5abf8274fe4118d4a (patch)
treef50a06beb0ecd3903acab075ef937409577a6cf0 /drivers/gpu/drm/ttm/ttm_bo_util.c
parentdrm/ttm: refactor out common code to setup a new tt backed resource (diff)
downloadwireguard-linux-b8b99c7ddccea56b0ac589e5abf8274fe4118d4a.tar.xz
wireguard-linux-b8b99c7ddccea56b0ac589e5abf8274fe4118d4a.zip
drm/ttm: split out the move to system from move ttm code
Reviewed-by: Ben Skeggs <bskeggs@redhat.com> Reviewed-by: Christian König <christian.koenig@amd.com> Signed-off-by: Dave Airlie <airlied@redhat.com> Link: https://patchwork.freedesktop.org/patch/msgid/20201019071314.1671485-3-airlied@gmail.com
Diffstat (limited to 'drivers/gpu/drm/ttm/ttm_bo_util.c')
-rw-r--r--drivers/gpu/drm/ttm/ttm_bo_util.c39
1 files changed, 25 insertions, 14 deletions
diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c
index a36c615bdf24..4a461226b6ba 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_util.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
@@ -65,27 +65,38 @@ int ttm_bo_move_to_new_tt_mem(struct ttm_buffer_object *bo,
return 0;
}
-int ttm_bo_move_ttm(struct ttm_buffer_object *bo,
- struct ttm_operation_ctx *ctx,
- struct ttm_resource *new_mem)
+static int ttm_bo_move_to_system(struct ttm_buffer_object *bo,
+ struct ttm_operation_ctx *ctx)
{
struct ttm_resource *old_mem = &bo->mem;
int ret;
- if (old_mem->mem_type != TTM_PL_SYSTEM) {
- ret = ttm_bo_wait_ctx(bo, ctx);
-
- if (unlikely(ret != 0)) {
- if (ret != -ERESTARTSYS)
- pr_err("Failed to expire sync object before unbinding TTM\n");
- return ret;
- }
+ if (old_mem->mem_type == TTM_PL_SYSTEM)
+ return 0;
- ttm_bo_tt_unbind(bo);
- ttm_resource_free(bo, &bo->mem);
- old_mem->mem_type = TTM_PL_SYSTEM;
+ ret = ttm_bo_wait_ctx(bo, ctx);
+ if (unlikely(ret != 0)) {
+ if (ret != -ERESTARTSYS)
+ pr_err("Failed to expire sync object before unbinding TTM\n");
+ return ret;
}
+ ttm_bo_tt_unbind(bo);
+ ttm_resource_free(bo, &bo->mem);
+ old_mem->mem_type = TTM_PL_SYSTEM;
+ return 0;
+}
+
+int ttm_bo_move_ttm(struct ttm_buffer_object *bo,
+ struct ttm_operation_ctx *ctx,
+ struct ttm_resource *new_mem)
+{
+ int ret;
+
+ ret = ttm_bo_move_to_system(bo, ctx);
+ if (unlikely(ret != 0))
+ return ret;
+
ret = ttm_bo_move_to_new_tt_mem(bo, ctx, new_mem);
if (unlikely(ret != 0))
return ret;