diff mbox series

[2/4] drm/amdgpu/ttm: use multihop

Message ID 20201109005432.861936-3-airlied@gmail.com (mailing list archive)
State New, archived
Headers show
Series [1/4] drm/ttm: add multihop infrastrucutre (v2) | expand

Commit Message

Dave Airlie Nov. 9, 2020, 12:54 a.m. UTC
From: Dave Airlie <airlied@redhat.com>

This removes the code to move resources directly between
SYSTEM and VRAM in favour of using the core ttm mulithop code.

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 136 +++---------------------
 1 file changed, 13 insertions(+), 123 deletions(-)

Comments

Daniel Vetter Nov. 10, 2020, 2:38 p.m. UTC | #1
On Mon, Nov 09, 2020 at 10:54:30AM +1000, Dave Airlie wrote:
> From: Dave Airlie <airlied@redhat.com>
> 
> This removes the code to move resources directly between
> SYSTEM and VRAM in favour of using the core ttm mulithop code.
> 
> Signed-off-by: Dave Airlie <airlied@redhat.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 136 +++---------------------
>  1 file changed, 13 insertions(+), 123 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> index ce0d82802333..e1458d575aa9 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> @@ -512,119 +512,6 @@ static int amdgpu_move_blit(struct ttm_buffer_object *bo,
>  	return r;
>  }
>  
> -/**
> - * amdgpu_move_vram_ram - Copy VRAM buffer to RAM buffer
> - *
> - * Called by amdgpu_bo_move().
> - */
> -static int amdgpu_move_vram_ram(struct ttm_buffer_object *bo, bool evict,
> -				struct ttm_operation_ctx *ctx,
> -				struct ttm_resource *new_mem)
> -{
> -	struct ttm_resource *old_mem = &bo->mem;
> -	struct ttm_resource tmp_mem;
> -	struct ttm_place placements;
> -	struct ttm_placement placement;
> -	int r;
> -
> -	/* create space/pages for new_mem in GTT space */
> -	tmp_mem = *new_mem;
> -	tmp_mem.mm_node = NULL;
> -	placement.num_placement = 1;
> -	placement.placement = &placements;
> -	placement.num_busy_placement = 1;
> -	placement.busy_placement = &placements;
> -	placements.fpfn = 0;
> -	placements.lpfn = 0;
> -	placements.mem_type = TTM_PL_TT;
> -	placements.flags = 0;
> -	r = ttm_bo_mem_space(bo, &placement, &tmp_mem, ctx);
> -	if (unlikely(r)) {
> -		pr_err("Failed to find GTT space for blit from VRAM\n");
> -		return r;
> -	}
> -
> -	r = ttm_tt_populate(bo->bdev, bo->ttm, ctx);
> -	if (unlikely(r))
> -		goto out_cleanup;
> -
> -	/* Bind the memory to the GTT space */
> -	r = amdgpu_ttm_backend_bind(bo->bdev, bo->ttm, &tmp_mem);
> -	if (unlikely(r)) {
> -		goto out_cleanup;
> -	}
> -
> -	/* blit VRAM to GTT */
> -	r = amdgpu_move_blit(bo, evict, &tmp_mem, old_mem);
> -	if (unlikely(r)) {
> -		goto out_cleanup;
> -	}
> -
> -	r = ttm_bo_wait_ctx(bo, ctx);
> -	if (unlikely(r))
> -		goto out_cleanup;
> -
> -	amdgpu_ttm_backend_unbind(bo->bdev, bo->ttm);
> -	ttm_resource_free(bo, &bo->mem);
> -	ttm_bo_assign_mem(bo, new_mem);
> -out_cleanup:
> -	ttm_resource_free(bo, &tmp_mem);
> -	return r;
> -}
> -
> -/**
> - * amdgpu_move_ram_vram - Copy buffer from RAM to VRAM
> - *
> - * Called by amdgpu_bo_move().
> - */
> -static int amdgpu_move_ram_vram(struct ttm_buffer_object *bo, bool evict,
> -				struct ttm_operation_ctx *ctx,
> -				struct ttm_resource *new_mem)
> -{
> -	struct ttm_resource *old_mem = &bo->mem;
> -	struct ttm_resource tmp_mem;
> -	struct ttm_placement placement;
> -	struct ttm_place placements;
> -	int r;
> -
> -	/* make space in GTT for old_mem buffer */
> -	tmp_mem = *new_mem;
> -	tmp_mem.mm_node = NULL;
> -	placement.num_placement = 1;
> -	placement.placement = &placements;
> -	placement.num_busy_placement = 1;
> -	placement.busy_placement = &placements;
> -	placements.fpfn = 0;
> -	placements.lpfn = 0;
> -	placements.mem_type = TTM_PL_TT;
> -	placements.flags = 0;
> -	r = ttm_bo_mem_space(bo, &placement, &tmp_mem, ctx);
> -	if (unlikely(r)) {
> -		pr_err("Failed to find GTT space for blit to VRAM\n");
> -		return r;
> -	}
> -
> -	/* move/bind old memory to GTT space */
> -	r = ttm_tt_populate(bo->bdev, bo->ttm, ctx);
> -	if (unlikely(r))
> -		return r;
> -
> -	r = amdgpu_ttm_backend_bind(bo->bdev, bo->ttm, &tmp_mem);
> -	if (unlikely(r)) {
> -		goto out_cleanup;
> -	}
> -
> -	ttm_bo_assign_mem(bo, &tmp_mem);
> -	/* copy to VRAM */
> -	r = amdgpu_move_blit(bo, evict, new_mem, old_mem);
> -	if (unlikely(r)) {
> -		goto out_cleanup;
> -	}
> -out_cleanup:
> -	ttm_resource_free(bo, &tmp_mem);
> -	return r;
> -}
> -
>  /**
>   * amdgpu_mem_visible - Check that memory can be accessed by ttm_bo_move_memcpy
>   *
> @@ -664,6 +551,17 @@ static int amdgpu_bo_move(struct ttm_buffer_object *bo, bool evict,
>  	struct ttm_resource *old_mem = &bo->mem;
>  	int r;
>  
> +	if ((old_mem->mem_type == TTM_PL_SYSTEM &&
> +	     new_mem->mem_type == TTM_PL_VRAM) ||
> +	    (old_mem->mem_type == TTM_PL_VRAM &&
> +	     new_mem->mem_type == TTM_PL_SYSTEM)) {
> +		hop->fpfn = 0;
> +		hop->lpfn = 0;
> +		hop->mem_type = TTM_PL_TT;
> +		hop->flags = 0;
> +		return -EMULTIHOP;

Helper for this might be neat, but total overkill. Like ttm_insert_tt_hop
and you pass the 2 other mem_types. Or maybe fully parametrized with
ttm_insert_hop:

	if (ttm_insert_tt_hope(old_mem, new_mem, TTM_PL_SYSTEM,
			TTM_PL_VRAM, hope))
		return -EMULTIPHOP;

Anyway real big bikeshed this one :-) Since Christian already checked the
details for the 3 driver patches from me just

Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>

on those three.
-Daniel

> +	}
> +
>  	if (new_mem->mem_type == TTM_PL_TT) {
>  		r = amdgpu_ttm_backend_bind(bo->bdev, bo->ttm, new_mem);
>  		if (r)
> @@ -717,16 +615,8 @@ static int amdgpu_bo_move(struct ttm_buffer_object *bo, bool evict,
>  		goto memcpy;
>  	}
>  
> -	if (old_mem->mem_type == TTM_PL_VRAM &&
> -	    new_mem->mem_type == TTM_PL_SYSTEM) {
> -		r = amdgpu_move_vram_ram(bo, evict, ctx, new_mem);
> -	} else if (old_mem->mem_type == TTM_PL_SYSTEM &&
> -		   new_mem->mem_type == TTM_PL_VRAM) {
> -		r = amdgpu_move_ram_vram(bo, evict, ctx, new_mem);
> -	} else {
> -		r = amdgpu_move_blit(bo, evict,
> -				     new_mem, old_mem);
> -	}
> +	r = amdgpu_move_blit(bo, evict,
> +			     new_mem, old_mem);
>  
>  	if (r) {
>  memcpy:
> -- 
> 2.27.0
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
Christian König Nov. 11, 2020, 5:15 p.m. UTC | #2
Am 09.11.20 um 01:54 schrieb Dave Airlie:
> From: Dave Airlie <airlied@redhat.com>
>
> This removes the code to move resources directly between
> SYSTEM and VRAM in favour of using the core ttm mulithop code.
>
> Signed-off-by: Dave Airlie <airlied@redhat.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 136 +++---------------------
>   1 file changed, 13 insertions(+), 123 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> index ce0d82802333..e1458d575aa9 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> @@ -512,119 +512,6 @@ static int amdgpu_move_blit(struct ttm_buffer_object *bo,
>   	return r;
>   }
>   
> -/**
> - * amdgpu_move_vram_ram - Copy VRAM buffer to RAM buffer
> - *
> - * Called by amdgpu_bo_move().
> - */
> -static int amdgpu_move_vram_ram(struct ttm_buffer_object *bo, bool evict,
> -				struct ttm_operation_ctx *ctx,
> -				struct ttm_resource *new_mem)
> -{
> -	struct ttm_resource *old_mem = &bo->mem;
> -	struct ttm_resource tmp_mem;
> -	struct ttm_place placements;
> -	struct ttm_placement placement;
> -	int r;
> -
> -	/* create space/pages for new_mem in GTT space */
> -	tmp_mem = *new_mem;
> -	tmp_mem.mm_node = NULL;
> -	placement.num_placement = 1;
> -	placement.placement = &placements;
> -	placement.num_busy_placement = 1;
> -	placement.busy_placement = &placements;
> -	placements.fpfn = 0;
> -	placements.lpfn = 0;
> -	placements.mem_type = TTM_PL_TT;
> -	placements.flags = 0;
> -	r = ttm_bo_mem_space(bo, &placement, &tmp_mem, ctx);
> -	if (unlikely(r)) {
> -		pr_err("Failed to find GTT space for blit from VRAM\n");
> -		return r;
> -	}
> -
> -	r = ttm_tt_populate(bo->bdev, bo->ttm, ctx);
> -	if (unlikely(r))
> -		goto out_cleanup;
> -
> -	/* Bind the memory to the GTT space */
> -	r = amdgpu_ttm_backend_bind(bo->bdev, bo->ttm, &tmp_mem);
> -	if (unlikely(r)) {
> -		goto out_cleanup;
> -	}
> -
> -	/* blit VRAM to GTT */
> -	r = amdgpu_move_blit(bo, evict, &tmp_mem, old_mem);
> -	if (unlikely(r)) {
> -		goto out_cleanup;
> -	}
> -
> -	r = ttm_bo_wait_ctx(bo, ctx);
> -	if (unlikely(r))
> -		goto out_cleanup;
> -
> -	amdgpu_ttm_backend_unbind(bo->bdev, bo->ttm);
> -	ttm_resource_free(bo, &bo->mem);
> -	ttm_bo_assign_mem(bo, new_mem);
> -out_cleanup:
> -	ttm_resource_free(bo, &tmp_mem);
> -	return r;
> -}
> -
> -/**
> - * amdgpu_move_ram_vram - Copy buffer from RAM to VRAM
> - *
> - * Called by amdgpu_bo_move().
> - */
> -static int amdgpu_move_ram_vram(struct ttm_buffer_object *bo, bool evict,
> -				struct ttm_operation_ctx *ctx,
> -				struct ttm_resource *new_mem)
> -{
> -	struct ttm_resource *old_mem = &bo->mem;
> -	struct ttm_resource tmp_mem;
> -	struct ttm_placement placement;
> -	struct ttm_place placements;
> -	int r;
> -
> -	/* make space in GTT for old_mem buffer */
> -	tmp_mem = *new_mem;
> -	tmp_mem.mm_node = NULL;
> -	placement.num_placement = 1;
> -	placement.placement = &placements;
> -	placement.num_busy_placement = 1;
> -	placement.busy_placement = &placements;
> -	placements.fpfn = 0;
> -	placements.lpfn = 0;
> -	placements.mem_type = TTM_PL_TT;
> -	placements.flags = 0;
> -	r = ttm_bo_mem_space(bo, &placement, &tmp_mem, ctx);
> -	if (unlikely(r)) {
> -		pr_err("Failed to find GTT space for blit to VRAM\n");
> -		return r;
> -	}
> -
> -	/* move/bind old memory to GTT space */
> -	r = ttm_tt_populate(bo->bdev, bo->ttm, ctx);
> -	if (unlikely(r))
> -		return r;
> -
> -	r = amdgpu_ttm_backend_bind(bo->bdev, bo->ttm, &tmp_mem);
> -	if (unlikely(r)) {
> -		goto out_cleanup;
> -	}
> -
> -	ttm_bo_assign_mem(bo, &tmp_mem);
> -	/* copy to VRAM */
> -	r = amdgpu_move_blit(bo, evict, new_mem, old_mem);
> -	if (unlikely(r)) {
> -		goto out_cleanup;
> -	}
> -out_cleanup:
> -	ttm_resource_free(bo, &tmp_mem);
> -	return r;
> -}
> -
>   /**
>    * amdgpu_mem_visible - Check that memory can be accessed by ttm_bo_move_memcpy
>    *
> @@ -664,6 +551,17 @@ static int amdgpu_bo_move(struct ttm_buffer_object *bo, bool evict,
>   	struct ttm_resource *old_mem = &bo->mem;
>   	int r;
>   
> +	if ((old_mem->mem_type == TTM_PL_SYSTEM &&
> +	     new_mem->mem_type == TTM_PL_VRAM) ||
> +	    (old_mem->mem_type == TTM_PL_VRAM &&
> +	     new_mem->mem_type == TTM_PL_SYSTEM)) {
> +		hop->fpfn = 0;
> +		hop->lpfn = 0;
> +		hop->mem_type = TTM_PL_TT;
> +		hop->flags = 0;
> +		return -EMULTIHOP;
> +	}
> +
>   	if (new_mem->mem_type == TTM_PL_TT) {
>   		r = amdgpu_ttm_backend_bind(bo->bdev, bo->ttm, new_mem);
>   		if (r)
> @@ -717,16 +615,8 @@ static int amdgpu_bo_move(struct ttm_buffer_object *bo, bool evict,
>   		goto memcpy;
>   	}
>   
> -	if (old_mem->mem_type == TTM_PL_VRAM &&
> -	    new_mem->mem_type == TTM_PL_SYSTEM) {
> -		r = amdgpu_move_vram_ram(bo, evict, ctx, new_mem);
> -	} else if (old_mem->mem_type == TTM_PL_SYSTEM &&
> -		   new_mem->mem_type == TTM_PL_VRAM) {
> -		r = amdgpu_move_ram_vram(bo, evict, ctx, new_mem);
> -	} else {
> -		r = amdgpu_move_blit(bo, evict,
> -				     new_mem, old_mem);
> -	}
> +	r = amdgpu_move_blit(bo, evict,
> +			     new_mem, old_mem);

Only a nit pick, but that can now probably be on one line.

Apart from that great cleanup. With the nits fixed the whole series is 
Reviewed-by: Christian König <christian.koenig@amd.com>

Regards,
Christian.

>   
>   	if (r) {
>   memcpy:
Mike Lothian Dec. 13, 2020, 1:44 a.m. UTC | #3
Hi

This patch is causing issues for me on both a Raven system and a Tonga
(PRIME) system

https://gitlab.freedesktop.org/drm/amd/-/issues/1405

It's only recently been merged into agd5f's tree - which is why I'm
only just noticing it

I realise this has now been submitted for rc1 - please can someone take a look

Thanks

Mike

On Mon, 9 Nov 2020 at 00:54, Dave Airlie <airlied@gmail.com> wrote:
>
> From: Dave Airlie <airlied@redhat.com>
>
> This removes the code to move resources directly between
> SYSTEM and VRAM in favour of using the core ttm mulithop code.
>
> Signed-off-by: Dave Airlie <airlied@redhat.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 136 +++---------------------
>  1 file changed, 13 insertions(+), 123 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> index ce0d82802333..e1458d575aa9 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> @@ -512,119 +512,6 @@ static int amdgpu_move_blit(struct ttm_buffer_object *bo,
>         return r;
>  }
>
> -/**
> - * amdgpu_move_vram_ram - Copy VRAM buffer to RAM buffer
> - *
> - * Called by amdgpu_bo_move().
> - */
> -static int amdgpu_move_vram_ram(struct ttm_buffer_object *bo, bool evict,
> -                               struct ttm_operation_ctx *ctx,
> -                               struct ttm_resource *new_mem)
> -{
> -       struct ttm_resource *old_mem = &bo->mem;
> -       struct ttm_resource tmp_mem;
> -       struct ttm_place placements;
> -       struct ttm_placement placement;
> -       int r;
> -
> -       /* create space/pages for new_mem in GTT space */
> -       tmp_mem = *new_mem;
> -       tmp_mem.mm_node = NULL;
> -       placement.num_placement = 1;
> -       placement.placement = &placements;
> -       placement.num_busy_placement = 1;
> -       placement.busy_placement = &placements;
> -       placements.fpfn = 0;
> -       placements.lpfn = 0;
> -       placements.mem_type = TTM_PL_TT;
> -       placements.flags = 0;
> -       r = ttm_bo_mem_space(bo, &placement, &tmp_mem, ctx);
> -       if (unlikely(r)) {
> -               pr_err("Failed to find GTT space for blit from VRAM\n");
> -               return r;
> -       }
> -
> -       r = ttm_tt_populate(bo->bdev, bo->ttm, ctx);
> -       if (unlikely(r))
> -               goto out_cleanup;
> -
> -       /* Bind the memory to the GTT space */
> -       r = amdgpu_ttm_backend_bind(bo->bdev, bo->ttm, &tmp_mem);
> -       if (unlikely(r)) {
> -               goto out_cleanup;
> -       }
> -
> -       /* blit VRAM to GTT */
> -       r = amdgpu_move_blit(bo, evict, &tmp_mem, old_mem);
> -       if (unlikely(r)) {
> -               goto out_cleanup;
> -       }
> -
> -       r = ttm_bo_wait_ctx(bo, ctx);
> -       if (unlikely(r))
> -               goto out_cleanup;
> -
> -       amdgpu_ttm_backend_unbind(bo->bdev, bo->ttm);
> -       ttm_resource_free(bo, &bo->mem);
> -       ttm_bo_assign_mem(bo, new_mem);
> -out_cleanup:
> -       ttm_resource_free(bo, &tmp_mem);
> -       return r;
> -}
> -
> -/**
> - * amdgpu_move_ram_vram - Copy buffer from RAM to VRAM
> - *
> - * Called by amdgpu_bo_move().
> - */
> -static int amdgpu_move_ram_vram(struct ttm_buffer_object *bo, bool evict,
> -                               struct ttm_operation_ctx *ctx,
> -                               struct ttm_resource *new_mem)
> -{
> -       struct ttm_resource *old_mem = &bo->mem;
> -       struct ttm_resource tmp_mem;
> -       struct ttm_placement placement;
> -       struct ttm_place placements;
> -       int r;
> -
> -       /* make space in GTT for old_mem buffer */
> -       tmp_mem = *new_mem;
> -       tmp_mem.mm_node = NULL;
> -       placement.num_placement = 1;
> -       placement.placement = &placements;
> -       placement.num_busy_placement = 1;
> -       placement.busy_placement = &placements;
> -       placements.fpfn = 0;
> -       placements.lpfn = 0;
> -       placements.mem_type = TTM_PL_TT;
> -       placements.flags = 0;
> -       r = ttm_bo_mem_space(bo, &placement, &tmp_mem, ctx);
> -       if (unlikely(r)) {
> -               pr_err("Failed to find GTT space for blit to VRAM\n");
> -               return r;
> -       }
> -
> -       /* move/bind old memory to GTT space */
> -       r = ttm_tt_populate(bo->bdev, bo->ttm, ctx);
> -       if (unlikely(r))
> -               return r;
> -
> -       r = amdgpu_ttm_backend_bind(bo->bdev, bo->ttm, &tmp_mem);
> -       if (unlikely(r)) {
> -               goto out_cleanup;
> -       }
> -
> -       ttm_bo_assign_mem(bo, &tmp_mem);
> -       /* copy to VRAM */
> -       r = amdgpu_move_blit(bo, evict, new_mem, old_mem);
> -       if (unlikely(r)) {
> -               goto out_cleanup;
> -       }
> -out_cleanup:
> -       ttm_resource_free(bo, &tmp_mem);
> -       return r;
> -}
> -
>  /**
>   * amdgpu_mem_visible - Check that memory can be accessed by ttm_bo_move_memcpy
>   *
> @@ -664,6 +551,17 @@ static int amdgpu_bo_move(struct ttm_buffer_object *bo, bool evict,
>         struct ttm_resource *old_mem = &bo->mem;
>         int r;
>
> +       if ((old_mem->mem_type == TTM_PL_SYSTEM &&
> +            new_mem->mem_type == TTM_PL_VRAM) ||
> +           (old_mem->mem_type == TTM_PL_VRAM &&
> +            new_mem->mem_type == TTM_PL_SYSTEM)) {
> +               hop->fpfn = 0;
> +               hop->lpfn = 0;
> +               hop->mem_type = TTM_PL_TT;
> +               hop->flags = 0;
> +               return -EMULTIHOP;
> +       }
> +
>         if (new_mem->mem_type == TTM_PL_TT) {
>                 r = amdgpu_ttm_backend_bind(bo->bdev, bo->ttm, new_mem);
>                 if (r)
> @@ -717,16 +615,8 @@ static int amdgpu_bo_move(struct ttm_buffer_object *bo, bool evict,
>                 goto memcpy;
>         }
>
> -       if (old_mem->mem_type == TTM_PL_VRAM &&
> -           new_mem->mem_type == TTM_PL_SYSTEM) {
> -               r = amdgpu_move_vram_ram(bo, evict, ctx, new_mem);
> -       } else if (old_mem->mem_type == TTM_PL_SYSTEM &&
> -                  new_mem->mem_type == TTM_PL_VRAM) {
> -               r = amdgpu_move_ram_vram(bo, evict, ctx, new_mem);
> -       } else {
> -               r = amdgpu_move_blit(bo, evict,
> -                                    new_mem, old_mem);
> -       }
> +       r = amdgpu_move_blit(bo, evict,
> +                            new_mem, old_mem);
>
>         if (r) {
>  memcpy:
> --
> 2.27.0
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
Daniel Vetter Dec. 14, 2020, 9:08 a.m. UTC | #4
On Sun, Dec 13, 2020 at 2:44 AM Mike Lothian <mike@fireburn.co.uk> wrote:
>
> Hi
>
> This patch is causing issues for me on both a Raven system and a Tonga
> (PRIME) system
>
> https://gitlab.freedesktop.org/drm/amd/-/issues/1405
>
> It's only recently been merged into agd5f's tree - which is why I'm
> only just noticing it
>
> I realise this has now been submitted for rc1 - please can someone take a look

Can you pls cherry-pick this one from drm-misc-next?

commit 9afdda82ee7f69b25cb5e6968e2d3d63e2313d12
Author: Christian König <christian.koenig@amd.com>
Date:   Wed Nov 25 15:32:23 2020 +0100

   drm/radeon: fix check order in radeon_bo_move

Christian, I think this fix should be cherry-picked to
drm-misc-next-fixes to make it into the merge window. It should have
been there from the start, but drm-misc-next-fixes wasn't ready yet I
think. Also adding Thomas to make sure the pull train goes out.
-Daniel

> Thanks
>
> Mike
>
> On Mon, 9 Nov 2020 at 00:54, Dave Airlie <airlied@gmail.com> wrote:
> >
> > From: Dave Airlie <airlied@redhat.com>
> >
> > This removes the code to move resources directly between
> > SYSTEM and VRAM in favour of using the core ttm mulithop code.
> >
> > Signed-off-by: Dave Airlie <airlied@redhat.com>
> > ---
> >  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 136 +++---------------------
> >  1 file changed, 13 insertions(+), 123 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> > index ce0d82802333..e1458d575aa9 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> > @@ -512,119 +512,6 @@ static int amdgpu_move_blit(struct ttm_buffer_object *bo,
> >         return r;
> >  }
> >
> > -/**
> > - * amdgpu_move_vram_ram - Copy VRAM buffer to RAM buffer
> > - *
> > - * Called by amdgpu_bo_move().
> > - */
> > -static int amdgpu_move_vram_ram(struct ttm_buffer_object *bo, bool evict,
> > -                               struct ttm_operation_ctx *ctx,
> > -                               struct ttm_resource *new_mem)
> > -{
> > -       struct ttm_resource *old_mem = &bo->mem;
> > -       struct ttm_resource tmp_mem;
> > -       struct ttm_place placements;
> > -       struct ttm_placement placement;
> > -       int r;
> > -
> > -       /* create space/pages for new_mem in GTT space */
> > -       tmp_mem = *new_mem;
> > -       tmp_mem.mm_node = NULL;
> > -       placement.num_placement = 1;
> > -       placement.placement = &placements;
> > -       placement.num_busy_placement = 1;
> > -       placement.busy_placement = &placements;
> > -       placements.fpfn = 0;
> > -       placements.lpfn = 0;
> > -       placements.mem_type = TTM_PL_TT;
> > -       placements.flags = 0;
> > -       r = ttm_bo_mem_space(bo, &placement, &tmp_mem, ctx);
> > -       if (unlikely(r)) {
> > -               pr_err("Failed to find GTT space for blit from VRAM\n");
> > -               return r;
> > -       }
> > -
> > -       r = ttm_tt_populate(bo->bdev, bo->ttm, ctx);
> > -       if (unlikely(r))
> > -               goto out_cleanup;
> > -
> > -       /* Bind the memory to the GTT space */
> > -       r = amdgpu_ttm_backend_bind(bo->bdev, bo->ttm, &tmp_mem);
> > -       if (unlikely(r)) {
> > -               goto out_cleanup;
> > -       }
> > -
> > -       /* blit VRAM to GTT */
> > -       r = amdgpu_move_blit(bo, evict, &tmp_mem, old_mem);
> > -       if (unlikely(r)) {
> > -               goto out_cleanup;
> > -       }
> > -
> > -       r = ttm_bo_wait_ctx(bo, ctx);
> > -       if (unlikely(r))
> > -               goto out_cleanup;
> > -
> > -       amdgpu_ttm_backend_unbind(bo->bdev, bo->ttm);
> > -       ttm_resource_free(bo, &bo->mem);
> > -       ttm_bo_assign_mem(bo, new_mem);
> > -out_cleanup:
> > -       ttm_resource_free(bo, &tmp_mem);
> > -       return r;
> > -}
> > -
> > -/**
> > - * amdgpu_move_ram_vram - Copy buffer from RAM to VRAM
> > - *
> > - * Called by amdgpu_bo_move().
> > - */
> > -static int amdgpu_move_ram_vram(struct ttm_buffer_object *bo, bool evict,
> > -                               struct ttm_operation_ctx *ctx,
> > -                               struct ttm_resource *new_mem)
> > -{
> > -       struct ttm_resource *old_mem = &bo->mem;
> > -       struct ttm_resource tmp_mem;
> > -       struct ttm_placement placement;
> > -       struct ttm_place placements;
> > -       int r;
> > -
> > -       /* make space in GTT for old_mem buffer */
> > -       tmp_mem = *new_mem;
> > -       tmp_mem.mm_node = NULL;
> > -       placement.num_placement = 1;
> > -       placement.placement = &placements;
> > -       placement.num_busy_placement = 1;
> > -       placement.busy_placement = &placements;
> > -       placements.fpfn = 0;
> > -       placements.lpfn = 0;
> > -       placements.mem_type = TTM_PL_TT;
> > -       placements.flags = 0;
> > -       r = ttm_bo_mem_space(bo, &placement, &tmp_mem, ctx);
> > -       if (unlikely(r)) {
> > -               pr_err("Failed to find GTT space for blit to VRAM\n");
> > -               return r;
> > -       }
> > -
> > -       /* move/bind old memory to GTT space */
> > -       r = ttm_tt_populate(bo->bdev, bo->ttm, ctx);
> > -       if (unlikely(r))
> > -               return r;
> > -
> > -       r = amdgpu_ttm_backend_bind(bo->bdev, bo->ttm, &tmp_mem);
> > -       if (unlikely(r)) {
> > -               goto out_cleanup;
> > -       }
> > -
> > -       ttm_bo_assign_mem(bo, &tmp_mem);
> > -       /* copy to VRAM */
> > -       r = amdgpu_move_blit(bo, evict, new_mem, old_mem);
> > -       if (unlikely(r)) {
> > -               goto out_cleanup;
> > -       }
> > -out_cleanup:
> > -       ttm_resource_free(bo, &tmp_mem);
> > -       return r;
> > -}
> > -
> >  /**
> >   * amdgpu_mem_visible - Check that memory can be accessed by ttm_bo_move_memcpy
> >   *
> > @@ -664,6 +551,17 @@ static int amdgpu_bo_move(struct ttm_buffer_object *bo, bool evict,
> >         struct ttm_resource *old_mem = &bo->mem;
> >         int r;
> >
> > +       if ((old_mem->mem_type == TTM_PL_SYSTEM &&
> > +            new_mem->mem_type == TTM_PL_VRAM) ||
> > +           (old_mem->mem_type == TTM_PL_VRAM &&
> > +            new_mem->mem_type == TTM_PL_SYSTEM)) {
> > +               hop->fpfn = 0;
> > +               hop->lpfn = 0;
> > +               hop->mem_type = TTM_PL_TT;
> > +               hop->flags = 0;
> > +               return -EMULTIHOP;
> > +       }
> > +
> >         if (new_mem->mem_type == TTM_PL_TT) {
> >                 r = amdgpu_ttm_backend_bind(bo->bdev, bo->ttm, new_mem);
> >                 if (r)
> > @@ -717,16 +615,8 @@ static int amdgpu_bo_move(struct ttm_buffer_object *bo, bool evict,
> >                 goto memcpy;
> >         }
> >
> > -       if (old_mem->mem_type == TTM_PL_VRAM &&
> > -           new_mem->mem_type == TTM_PL_SYSTEM) {
> > -               r = amdgpu_move_vram_ram(bo, evict, ctx, new_mem);
> > -       } else if (old_mem->mem_type == TTM_PL_SYSTEM &&
> > -                  new_mem->mem_type == TTM_PL_VRAM) {
> > -               r = amdgpu_move_ram_vram(bo, evict, ctx, new_mem);
> > -       } else {
> > -               r = amdgpu_move_blit(bo, evict,
> > -                                    new_mem, old_mem);
> > -       }
> > +       r = amdgpu_move_blit(bo, evict,
> > +                            new_mem, old_mem);
> >
> >         if (r) {
> >  memcpy:
> > --
> > 2.27.0
> >
> > _______________________________________________
> > dri-devel mailing list
> > dri-devel@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/dri-devel
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
Alex Deucher Dec. 14, 2020, 8:37 p.m. UTC | #5
On Mon, Dec 14, 2020 at 4:08 AM Daniel Vetter <daniel@ffwll.ch> wrote:
>
> On Sun, Dec 13, 2020 at 2:44 AM Mike Lothian <mike@fireburn.co.uk> wrote:
> >
> > Hi
> >
> > This patch is causing issues for me on both a Raven system and a Tonga
> > (PRIME) system
> >
> > https://gitlab.freedesktop.org/drm/amd/-/issues/1405
> >
> > It's only recently been merged into agd5f's tree - which is why I'm
> > only just noticing it
> >
> > I realise this has now been submitted for rc1 - please can someone take a look
>
> Can you pls cherry-pick this one from drm-misc-next?
>
> commit 9afdda82ee7f69b25cb5e6968e2d3d63e2313d12
> Author: Christian König <christian.koenig@amd.com>
> Date:   Wed Nov 25 15:32:23 2020 +0100
>
>    drm/radeon: fix check order in radeon_bo_move
>
> Christian, I think this fix should be cherry-picked to
> drm-misc-next-fixes to make it into the merge window. It should have
> been there from the start, but drm-misc-next-fixes wasn't ready yet I
> think. Also adding Thomas to make sure the pull train goes out.

Looks like it's already in drm-misc-next-fixes:
https://cgit.freedesktop.org/drm/drm-misc/commit/?h=drm-misc-next-fixes&id=aefec40938e4a0e1214f9121520aba4d51697cd9

commit aefec40938e4a0e1214f9121520aba4d51697cd9
Author: Christian König <christian.koenig@amd.com>
Date:   Mon Nov 16 20:12:03 2020 +0100

    drm/amdgpu: fix check order in amdgpu_bo_move

    Reorder the code to fix checking if blitting is available.

    Signed-off-by: Christian König <christian.koenig@amd.com>
    Acked-by: Alex Deucher <alexander.deucher@amd.com>
    Link: https://patchwork.freedesktop.org/patch/401019/

Alex

> -Daniel
>
> > Thanks
> >
> > Mike
> >
> > On Mon, 9 Nov 2020 at 00:54, Dave Airlie <airlied@gmail.com> wrote:
> > >
> > > From: Dave Airlie <airlied@redhat.com>
> > >
> > > This removes the code to move resources directly between
> > > SYSTEM and VRAM in favour of using the core ttm mulithop code.
> > >
> > > Signed-off-by: Dave Airlie <airlied@redhat.com>
> > > ---
> > >  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 136 +++---------------------
> > >  1 file changed, 13 insertions(+), 123 deletions(-)
> > >
> > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> > > index ce0d82802333..e1458d575aa9 100644
> > > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> > > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> > > @@ -512,119 +512,6 @@ static int amdgpu_move_blit(struct ttm_buffer_object *bo,
> > >         return r;
> > >  }
> > >
> > > -/**
> > > - * amdgpu_move_vram_ram - Copy VRAM buffer to RAM buffer
> > > - *
> > > - * Called by amdgpu_bo_move().
> > > - */
> > > -static int amdgpu_move_vram_ram(struct ttm_buffer_object *bo, bool evict,
> > > -                               struct ttm_operation_ctx *ctx,
> > > -                               struct ttm_resource *new_mem)
> > > -{
> > > -       struct ttm_resource *old_mem = &bo->mem;
> > > -       struct ttm_resource tmp_mem;
> > > -       struct ttm_place placements;
> > > -       struct ttm_placement placement;
> > > -       int r;
> > > -
> > > -       /* create space/pages for new_mem in GTT space */
> > > -       tmp_mem = *new_mem;
> > > -       tmp_mem.mm_node = NULL;
> > > -       placement.num_placement = 1;
> > > -       placement.placement = &placements;
> > > -       placement.num_busy_placement = 1;
> > > -       placement.busy_placement = &placements;
> > > -       placements.fpfn = 0;
> > > -       placements.lpfn = 0;
> > > -       placements.mem_type = TTM_PL_TT;
> > > -       placements.flags = 0;
> > > -       r = ttm_bo_mem_space(bo, &placement, &tmp_mem, ctx);
> > > -       if (unlikely(r)) {
> > > -               pr_err("Failed to find GTT space for blit from VRAM\n");
> > > -               return r;
> > > -       }
> > > -
> > > -       r = ttm_tt_populate(bo->bdev, bo->ttm, ctx);
> > > -       if (unlikely(r))
> > > -               goto out_cleanup;
> > > -
> > > -       /* Bind the memory to the GTT space */
> > > -       r = amdgpu_ttm_backend_bind(bo->bdev, bo->ttm, &tmp_mem);
> > > -       if (unlikely(r)) {
> > > -               goto out_cleanup;
> > > -       }
> > > -
> > > -       /* blit VRAM to GTT */
> > > -       r = amdgpu_move_blit(bo, evict, &tmp_mem, old_mem);
> > > -       if (unlikely(r)) {
> > > -               goto out_cleanup;
> > > -       }
> > > -
> > > -       r = ttm_bo_wait_ctx(bo, ctx);
> > > -       if (unlikely(r))
> > > -               goto out_cleanup;
> > > -
> > > -       amdgpu_ttm_backend_unbind(bo->bdev, bo->ttm);
> > > -       ttm_resource_free(bo, &bo->mem);
> > > -       ttm_bo_assign_mem(bo, new_mem);
> > > -out_cleanup:
> > > -       ttm_resource_free(bo, &tmp_mem);
> > > -       return r;
> > > -}
> > > -
> > > -/**
> > > - * amdgpu_move_ram_vram - Copy buffer from RAM to VRAM
> > > - *
> > > - * Called by amdgpu_bo_move().
> > > - */
> > > -static int amdgpu_move_ram_vram(struct ttm_buffer_object *bo, bool evict,
> > > -                               struct ttm_operation_ctx *ctx,
> > > -                               struct ttm_resource *new_mem)
> > > -{
> > > -       struct ttm_resource *old_mem = &bo->mem;
> > > -       struct ttm_resource tmp_mem;
> > > -       struct ttm_placement placement;
> > > -       struct ttm_place placements;
> > > -       int r;
> > > -
> > > -       /* make space in GTT for old_mem buffer */
> > > -       tmp_mem = *new_mem;
> > > -       tmp_mem.mm_node = NULL;
> > > -       placement.num_placement = 1;
> > > -       placement.placement = &placements;
> > > -       placement.num_busy_placement = 1;
> > > -       placement.busy_placement = &placements;
> > > -       placements.fpfn = 0;
> > > -       placements.lpfn = 0;
> > > -       placements.mem_type = TTM_PL_TT;
> > > -       placements.flags = 0;
> > > -       r = ttm_bo_mem_space(bo, &placement, &tmp_mem, ctx);
> > > -       if (unlikely(r)) {
> > > -               pr_err("Failed to find GTT space for blit to VRAM\n");
> > > -               return r;
> > > -       }
> > > -
> > > -       /* move/bind old memory to GTT space */
> > > -       r = ttm_tt_populate(bo->bdev, bo->ttm, ctx);
> > > -       if (unlikely(r))
> > > -               return r;
> > > -
> > > -       r = amdgpu_ttm_backend_bind(bo->bdev, bo->ttm, &tmp_mem);
> > > -       if (unlikely(r)) {
> > > -               goto out_cleanup;
> > > -       }
> > > -
> > > -       ttm_bo_assign_mem(bo, &tmp_mem);
> > > -       /* copy to VRAM */
> > > -       r = amdgpu_move_blit(bo, evict, new_mem, old_mem);
> > > -       if (unlikely(r)) {
> > > -               goto out_cleanup;
> > > -       }
> > > -out_cleanup:
> > > -       ttm_resource_free(bo, &tmp_mem);
> > > -       return r;
> > > -}
> > > -
> > >  /**
> > >   * amdgpu_mem_visible - Check that memory can be accessed by ttm_bo_move_memcpy
> > >   *
> > > @@ -664,6 +551,17 @@ static int amdgpu_bo_move(struct ttm_buffer_object *bo, bool evict,
> > >         struct ttm_resource *old_mem = &bo->mem;
> > >         int r;
> > >
> > > +       if ((old_mem->mem_type == TTM_PL_SYSTEM &&
> > > +            new_mem->mem_type == TTM_PL_VRAM) ||
> > > +           (old_mem->mem_type == TTM_PL_VRAM &&
> > > +            new_mem->mem_type == TTM_PL_SYSTEM)) {
> > > +               hop->fpfn = 0;
> > > +               hop->lpfn = 0;
> > > +               hop->mem_type = TTM_PL_TT;
> > > +               hop->flags = 0;
> > > +               return -EMULTIHOP;
> > > +       }
> > > +
> > >         if (new_mem->mem_type == TTM_PL_TT) {
> > >                 r = amdgpu_ttm_backend_bind(bo->bdev, bo->ttm, new_mem);
> > >                 if (r)
> > > @@ -717,16 +615,8 @@ static int amdgpu_bo_move(struct ttm_buffer_object *bo, bool evict,
> > >                 goto memcpy;
> > >         }
> > >
> > > -       if (old_mem->mem_type == TTM_PL_VRAM &&
> > > -           new_mem->mem_type == TTM_PL_SYSTEM) {
> > > -               r = amdgpu_move_vram_ram(bo, evict, ctx, new_mem);
> > > -       } else if (old_mem->mem_type == TTM_PL_SYSTEM &&
> > > -                  new_mem->mem_type == TTM_PL_VRAM) {
> > > -               r = amdgpu_move_ram_vram(bo, evict, ctx, new_mem);
> > > -       } else {
> > > -               r = amdgpu_move_blit(bo, evict,
> > > -                                    new_mem, old_mem);
> > > -       }
> > > +       r = amdgpu_move_blit(bo, evict,
> > > +                            new_mem, old_mem);
> > >
> > >         if (r) {
> > >  memcpy:
> > > --
> > > 2.27.0
> > >
> > > _______________________________________________
> > > dri-devel mailing list
> > > dri-devel@lists.freedesktop.org
> > > https://lists.freedesktop.org/mailman/listinfo/dri-devel
> > _______________________________________________
> > dri-devel mailing list
> > dri-devel@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/dri-devel
>
>
>
> --
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
diff mbox series

Patch

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index ce0d82802333..e1458d575aa9 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -512,119 +512,6 @@  static int amdgpu_move_blit(struct ttm_buffer_object *bo,
 	return r;
 }
 
-/**
- * amdgpu_move_vram_ram - Copy VRAM buffer to RAM buffer
- *
- * Called by amdgpu_bo_move().
- */
-static int amdgpu_move_vram_ram(struct ttm_buffer_object *bo, bool evict,
-				struct ttm_operation_ctx *ctx,
-				struct ttm_resource *new_mem)
-{
-	struct ttm_resource *old_mem = &bo->mem;
-	struct ttm_resource tmp_mem;
-	struct ttm_place placements;
-	struct ttm_placement placement;
-	int r;
-
-	/* create space/pages for new_mem in GTT space */
-	tmp_mem = *new_mem;
-	tmp_mem.mm_node = NULL;
-	placement.num_placement = 1;
-	placement.placement = &placements;
-	placement.num_busy_placement = 1;
-	placement.busy_placement = &placements;
-	placements.fpfn = 0;
-	placements.lpfn = 0;
-	placements.mem_type = TTM_PL_TT;
-	placements.flags = 0;
-	r = ttm_bo_mem_space(bo, &placement, &tmp_mem, ctx);
-	if (unlikely(r)) {
-		pr_err("Failed to find GTT space for blit from VRAM\n");
-		return r;
-	}
-
-	r = ttm_tt_populate(bo->bdev, bo->ttm, ctx);
-	if (unlikely(r))
-		goto out_cleanup;
-
-	/* Bind the memory to the GTT space */
-	r = amdgpu_ttm_backend_bind(bo->bdev, bo->ttm, &tmp_mem);
-	if (unlikely(r)) {
-		goto out_cleanup;
-	}
-
-	/* blit VRAM to GTT */
-	r = amdgpu_move_blit(bo, evict, &tmp_mem, old_mem);
-	if (unlikely(r)) {
-		goto out_cleanup;
-	}
-
-	r = ttm_bo_wait_ctx(bo, ctx);
-	if (unlikely(r))
-		goto out_cleanup;
-
-	amdgpu_ttm_backend_unbind(bo->bdev, bo->ttm);
-	ttm_resource_free(bo, &bo->mem);
-	ttm_bo_assign_mem(bo, new_mem);
-out_cleanup:
-	ttm_resource_free(bo, &tmp_mem);
-	return r;
-}
-
-/**
- * amdgpu_move_ram_vram - Copy buffer from RAM to VRAM
- *
- * Called by amdgpu_bo_move().
- */
-static int amdgpu_move_ram_vram(struct ttm_buffer_object *bo, bool evict,
-				struct ttm_operation_ctx *ctx,
-				struct ttm_resource *new_mem)
-{
-	struct ttm_resource *old_mem = &bo->mem;
-	struct ttm_resource tmp_mem;
-	struct ttm_placement placement;
-	struct ttm_place placements;
-	int r;
-
-	/* make space in GTT for old_mem buffer */
-	tmp_mem = *new_mem;
-	tmp_mem.mm_node = NULL;
-	placement.num_placement = 1;
-	placement.placement = &placements;
-	placement.num_busy_placement = 1;
-	placement.busy_placement = &placements;
-	placements.fpfn = 0;
-	placements.lpfn = 0;
-	placements.mem_type = TTM_PL_TT;
-	placements.flags = 0;
-	r = ttm_bo_mem_space(bo, &placement, &tmp_mem, ctx);
-	if (unlikely(r)) {
-		pr_err("Failed to find GTT space for blit to VRAM\n");
-		return r;
-	}
-
-	/* move/bind old memory to GTT space */
-	r = ttm_tt_populate(bo->bdev, bo->ttm, ctx);
-	if (unlikely(r))
-		return r;
-
-	r = amdgpu_ttm_backend_bind(bo->bdev, bo->ttm, &tmp_mem);
-	if (unlikely(r)) {
-		goto out_cleanup;
-	}
-
-	ttm_bo_assign_mem(bo, &tmp_mem);
-	/* copy to VRAM */
-	r = amdgpu_move_blit(bo, evict, new_mem, old_mem);
-	if (unlikely(r)) {
-		goto out_cleanup;
-	}
-out_cleanup:
-	ttm_resource_free(bo, &tmp_mem);
-	return r;
-}
-
 /**
  * amdgpu_mem_visible - Check that memory can be accessed by ttm_bo_move_memcpy
  *
@@ -664,6 +551,17 @@  static int amdgpu_bo_move(struct ttm_buffer_object *bo, bool evict,
 	struct ttm_resource *old_mem = &bo->mem;
 	int r;
 
+	if ((old_mem->mem_type == TTM_PL_SYSTEM &&
+	     new_mem->mem_type == TTM_PL_VRAM) ||
+	    (old_mem->mem_type == TTM_PL_VRAM &&
+	     new_mem->mem_type == TTM_PL_SYSTEM)) {
+		hop->fpfn = 0;
+		hop->lpfn = 0;
+		hop->mem_type = TTM_PL_TT;
+		hop->flags = 0;
+		return -EMULTIHOP;
+	}
+
 	if (new_mem->mem_type == TTM_PL_TT) {
 		r = amdgpu_ttm_backend_bind(bo->bdev, bo->ttm, new_mem);
 		if (r)
@@ -717,16 +615,8 @@  static int amdgpu_bo_move(struct ttm_buffer_object *bo, bool evict,
 		goto memcpy;
 	}
 
-	if (old_mem->mem_type == TTM_PL_VRAM &&
-	    new_mem->mem_type == TTM_PL_SYSTEM) {
-		r = amdgpu_move_vram_ram(bo, evict, ctx, new_mem);
-	} else if (old_mem->mem_type == TTM_PL_SYSTEM &&
-		   new_mem->mem_type == TTM_PL_VRAM) {
-		r = amdgpu_move_ram_vram(bo, evict, ctx, new_mem);
-	} else {
-		r = amdgpu_move_blit(bo, evict,
-				     new_mem, old_mem);
-	}
+	r = amdgpu_move_blit(bo, evict,
+			     new_mem, old_mem);
 
 	if (r) {
 memcpy: