diff mbox series

[02/45] drm/ttm: handle the SYSTEM->TT path in same place as others.

Message ID 20200924051845.397177-3-airlied@gmail.com
State New, archived
Headers show
Series TTM move refactoring | expand

Commit Message

Dave Airlie Sept. 24, 2020, 5:18 a.m. UTC
From: Dave Airlie <airlied@redhat.com>

This just consolidates the code making the flow easier to understand
and also helps when moving move to the driver side.

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/ttm/ttm_bo.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

Comments

Christian König Sept. 24, 2020, 10:24 a.m. UTC | #1
Am 24.09.20 um 07:18 schrieb Dave Airlie:
> From: Dave Airlie <airlied@redhat.com>
>
> This just consolidates the code making the flow easier to understand
> and also helps when moving move to the driver side.
>
> Signed-off-by: Dave Airlie <airlied@redhat.com>
> ---
>   drivers/gpu/drm/ttm/ttm_bo.c | 17 +++++++----------
>   1 file changed, 7 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> index c342bfc2b4c1..6d1520255fc1 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -265,20 +265,18 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
>   			if (ret)
>   				goto out_err;
>   		}
> -
> -		if (bo->mem.mem_type == TTM_PL_SYSTEM) {
> -			if (bdev->driver->move_notify)
> -				bdev->driver->move_notify(bo, evict, mem);
> -			bo->mem = *mem;
> -			goto moved;
> -		}
>   	}
>   
>   	if (bdev->driver->move_notify)
>   		bdev->driver->move_notify(bo, evict, mem);
>   
> -	if (old_man->use_tt && new_man->use_tt)
> -		ret = ttm_bo_move_ttm(bo, ctx, mem);
> +	if (old_man->use_tt && new_man->use_tt) {
> +		if (bo->mem.mem_type == TTM_PL_SYSTEM) {
> +			ttm_bo_assign_mem(bo, mem);
> +			ret = 0;
> +		} else
> +			ret = ttm_bo_move_ttm(bo, ctx, mem);
> +	}
>   	else if (bdev->driver->move)

This should then use "} else if (...) {", apart from that the patch is 
Reviewed-by: Christian König <christian.koenig@amd.com>.

Christian.

>   		ret = bdev->driver->move(bo, evict, ctx, mem);
>   	else
> @@ -294,7 +292,6 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
>   		goto out_err;
>   	}
>   
> -moved:
>   	ctx->bytes_moved += bo->num_pages << PAGE_SHIFT;
>   	return 0;
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index c342bfc2b4c1..6d1520255fc1 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -265,20 +265,18 @@  static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
 			if (ret)
 				goto out_err;
 		}
-
-		if (bo->mem.mem_type == TTM_PL_SYSTEM) {
-			if (bdev->driver->move_notify)
-				bdev->driver->move_notify(bo, evict, mem);
-			bo->mem = *mem;
-			goto moved;
-		}
 	}
 
 	if (bdev->driver->move_notify)
 		bdev->driver->move_notify(bo, evict, mem);
 
-	if (old_man->use_tt && new_man->use_tt)
-		ret = ttm_bo_move_ttm(bo, ctx, mem);
+	if (old_man->use_tt && new_man->use_tt) {
+		if (bo->mem.mem_type == TTM_PL_SYSTEM) {
+			ttm_bo_assign_mem(bo, mem);
+			ret = 0;
+		} else
+			ret = ttm_bo_move_ttm(bo, ctx, mem);
+	}
 	else if (bdev->driver->move)
 		ret = bdev->driver->move(bo, evict, ctx, mem);
 	else
@@ -294,7 +292,6 @@  static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
 		goto out_err;
 	}
 
-moved:
 	ctx->bytes_moved += bo->num_pages << PAGE_SHIFT;
 	return 0;