[PATCH 14/45] drm/ttm: add move old to system to drivers.
Christian König
christian.koenig at amd.com
Thu Sep 24 12:02:11 UTC 2020
Am 24.09.20 um 07:18 schrieb Dave Airlie:
> From: Dave Airlie <airlied at redhat.com>
>
> Uninline ttm_bo_move_ttm. Eventually want to unhook the unbind out.
>
> Signed-off-by: Dave Airlie <airlied at redhat.com>
Reviewed-by: Christian König <christian.koenig at amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 9 ++++++++-
> drivers/gpu/drm/nouveau/nouveau_bo.c | 9 ++++++++-
> drivers/gpu/drm/radeon/radeon_ttm.c | 10 +++++++++-
> drivers/gpu/drm/ttm/ttm_bo_util.c | 5 +++--
> include/drm/ttm/ttm_bo_driver.h | 2 ++
> 5 files changed, 30 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> index 960a99d6793a..e20ce380f627 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> @@ -568,7 +568,14 @@ static int amdgpu_move_vram_ram(struct ttm_buffer_object *bo, bool evict,
> }
>
> /* move BO (in tmp_mem) to new_mem */
> - r = ttm_bo_move_ttm(bo, ctx, new_mem);
> + r = ttm_bo_move_old_to_system(bo, ctx);
> + if (unlikely(r))
> + goto out_cleanup;
> +
> + r = ttm_tt_set_placement_caching(bo->ttm, new_mem->placement);
> + if (unlikely(r))
> + goto out_cleanup;
> + ttm_bo_assign_mem(bo, new_mem);
> out_cleanup:
> ttm_resource_free(bo, &tmp_mem);
> return r;
> diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
> index 2cb61eea9481..a95d208c76a1 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_bo.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
> @@ -915,7 +915,14 @@ nouveau_bo_move_flipd(struct ttm_buffer_object *bo, bool evict,
> if (ret)
> goto out;
>
> - ret = ttm_bo_move_ttm(bo, ctx, new_reg);
> + ret = ttm_bo_move_old_to_system(bo, ctx);
> + if (ret)
> + goto out;
> +
> + ret = ttm_tt_set_placement_caching(bo->ttm, new_reg->placement);
> + if (ret)
> + goto out;
> + ttm_bo_assign_mem(bo, new_reg);
> out:
> ttm_resource_free(bo, &tmp_reg);
> return ret;
> diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
> index 7b778fc74f7b..89455f2d3bb6 100644
> --- a/drivers/gpu/drm/radeon/radeon_ttm.c
> +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
> @@ -249,7 +249,15 @@ static int radeon_move_vram_ram(struct ttm_buffer_object *bo,
> if (unlikely(r)) {
> goto out_cleanup;
> }
> - r = ttm_bo_move_ttm(bo, ctx, new_mem);
> + r = ttm_bo_move_old_to_system(bo, ctx);
> + if (unlikely(r))
> + goto out_cleanup;
> +
> + r = ttm_tt_set_placement_caching(bo->ttm, new_mem->placement);
> + if (unlikely(r))
> + goto out_cleanup;
> + ttm_bo_assign_mem(bo, new_mem);
> +
> out_cleanup:
> ttm_resource_free(bo, &tmp_mem);
> return r;
> diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c
> index e76883836e6e..1e701dd192d3 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo_util.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
> @@ -69,8 +69,8 @@ int ttm_bo_move_to_new_tt_mem(struct ttm_buffer_object *bo,
> }
> EXPORT_SYMBOL(ttm_bo_move_to_new_tt_mem);
>
> -static int ttm_bo_move_old_to_system(struct ttm_buffer_object *bo,
> - struct ttm_operation_ctx *ctx)
> +int ttm_bo_move_old_to_system(struct ttm_buffer_object *bo,
> + struct ttm_operation_ctx *ctx)
> {
> struct ttm_resource *old_mem = &bo->mem;
> int ret;
> @@ -90,6 +90,7 @@ static int ttm_bo_move_old_to_system(struct ttm_buffer_object *bo,
> old_mem->mem_type = TTM_PL_SYSTEM;
> return 0;
> }
> +EXPORT_SYMBOL(ttm_bo_move_old_to_system);
>
> int ttm_bo_move_ttm(struct ttm_buffer_object *bo,
> struct ttm_operation_ctx *ctx,
> diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
> index 6690ec5d90ec..65cf86b3ba0b 100644
> --- a/include/drm/ttm/ttm_bo_driver.h
> +++ b/include/drm/ttm/ttm_bo_driver.h
> @@ -605,6 +605,8 @@ int ttm_bo_move_ttm(struct ttm_buffer_object *bo,
> struct ttm_operation_ctx *ctx,
> struct ttm_resource *new_mem);
>
> +int ttm_bo_move_old_to_system(struct ttm_buffer_object *bo,
> + struct ttm_operation_ctx *ctx);
> int ttm_bo_move_to_new_tt_mem(struct ttm_buffer_object *bo,
> struct ttm_operation_ctx *ctx,
> struct ttm_resource *new_mem);
More information about the dri-devel
mailing list