diff mbox series

[08/45] drm/vram_helper: implement a ttm move callback.

Message ID 20200924051845.397177-9-airlied@gmail.com (mailing list archive)
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 will always do memcpy moves.

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/drm_gem_vram_helper.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

Comments

Christian König Sept. 24, 2020, 11:14 a.m. UTC | #1
Am 24.09.20 um 07:18 schrieb Dave Airlie:
> From: Dave Airlie <airlied@redhat.com>
>
> This will always do memcpy moves.
>
> Signed-off-by: Dave Airlie <airlied@redhat.com>

Acked-by: Christian König <christian.koenig@amd.com>

> ---
>   drivers/gpu/drm/drm_gem_vram_helper.c | 21 +++++++++++++++++++++
>   1 file changed, 21 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c b/drivers/gpu/drm/drm_gem_vram_helper.c
> index 171ea57b0311..9fd80a3643f6 100644
> --- a/drivers/gpu/drm/drm_gem_vram_helper.c
> +++ b/drivers/gpu/drm/drm_gem_vram_helper.c
> @@ -600,6 +600,14 @@ static void drm_gem_vram_bo_driver_move_notify(struct drm_gem_vram_object *gbo,
>   	kmap->virtual = NULL;
>   }
>   
> +static int drm_gem_vram_bo_driver_move(struct drm_gem_vram_object *gbo,
> +				       bool evict,
> +				       struct ttm_operation_ctx *ctx,
> +				       struct ttm_resource *new_mem)
> +{
> +	return ttm_bo_move_memcpy(&gbo->bo, ctx, new_mem);
> +}
> +
>   /*
>    * Helpers for struct drm_gem_object_funcs
>    */
> @@ -962,6 +970,18 @@ static void bo_driver_move_notify(struct ttm_buffer_object *bo,
>   	drm_gem_vram_bo_driver_move_notify(gbo, evict, new_mem);
>   }
>   
> +static int bo_driver_move(struct ttm_buffer_object *bo,
> +			  bool evict,
> +			  struct ttm_operation_ctx *ctx,
> +			  struct ttm_resource *new_mem)
> +{
> +	struct drm_gem_vram_object *gbo;
> +
> +	gbo = drm_gem_vram_of_bo(bo);
> +
> +	return drm_gem_vram_bo_driver_move(gbo, evict, ctx, new_mem);
> +}
> +
>   static int bo_driver_io_mem_reserve(struct ttm_bo_device *bdev,
>   				    struct ttm_resource *mem)
>   {
> @@ -986,6 +1006,7 @@ static struct ttm_bo_driver bo_driver = {
>   	.ttm_tt_destroy = bo_driver_ttm_tt_destroy,
>   	.eviction_valuable = ttm_bo_eviction_valuable,
>   	.evict_flags = bo_driver_evict_flags,
> +	.move = bo_driver_move,
>   	.move_notify = bo_driver_move_notify,
>   	.io_mem_reserve = bo_driver_io_mem_reserve,
>   };
diff mbox series

Patch

diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c b/drivers/gpu/drm/drm_gem_vram_helper.c
index 171ea57b0311..9fd80a3643f6 100644
--- a/drivers/gpu/drm/drm_gem_vram_helper.c
+++ b/drivers/gpu/drm/drm_gem_vram_helper.c
@@ -600,6 +600,14 @@  static void drm_gem_vram_bo_driver_move_notify(struct drm_gem_vram_object *gbo,
 	kmap->virtual = NULL;
 }
 
+static int drm_gem_vram_bo_driver_move(struct drm_gem_vram_object *gbo,
+				       bool evict,
+				       struct ttm_operation_ctx *ctx,
+				       struct ttm_resource *new_mem)
+{
+	return ttm_bo_move_memcpy(&gbo->bo, ctx, new_mem);
+}
+
 /*
  * Helpers for struct drm_gem_object_funcs
  */
@@ -962,6 +970,18 @@  static void bo_driver_move_notify(struct ttm_buffer_object *bo,
 	drm_gem_vram_bo_driver_move_notify(gbo, evict, new_mem);
 }
 
+static int bo_driver_move(struct ttm_buffer_object *bo,
+			  bool evict,
+			  struct ttm_operation_ctx *ctx,
+			  struct ttm_resource *new_mem)
+{
+	struct drm_gem_vram_object *gbo;
+
+	gbo = drm_gem_vram_of_bo(bo);
+
+	return drm_gem_vram_bo_driver_move(gbo, evict, ctx, new_mem);
+}
+
 static int bo_driver_io_mem_reserve(struct ttm_bo_device *bdev,
 				    struct ttm_resource *mem)
 {
@@ -986,6 +1006,7 @@  static struct ttm_bo_driver bo_driver = {
 	.ttm_tt_destroy = bo_driver_ttm_tt_destroy,
 	.eviction_valuable = ttm_bo_eviction_valuable,
 	.evict_flags = bo_driver_evict_flags,
+	.move = bo_driver_move,
 	.move_notify = bo_driver_move_notify,
 	.io_mem_reserve = bo_driver_io_mem_reserve,
 };