diff mbox series

[3/5] drm/vmwgfx: add a move callback.

Message ID 20201006000644.1005758-4-airlied@gmail.com (mailing list archive)
State New, archived
Headers show
Series ttm make move callback compulsory | expand

Commit Message

Dave Airlie Oct. 6, 2020, 12:06 a.m. UTC
From: Dave Airlie <airlied@redhat.com>

This just copies the fallback to vmwgfx, I'm going to iterate on this
a bit until it's not the same as the fallback path.

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

Comments

Zack Rusin Oct. 8, 2020, 3:41 a.m. UTC | #1
> On Oct 5, 2020, at 20:06, Dave Airlie <airlied@gmail.com> wrote:
> 
> From: Dave Airlie <airlied@redhat.com>
> 
> This just copies the fallback to vmwgfx, I'm going to iterate on this
> a bit until it's not the same as the fallback path.
> 
> Signed-off-by: Dave Airlie <airlied@redhat.com>

What are your plans for it? i.e. how is it going to be different?

Reviewed-by: Zack Rusin <zackr@vmware.com>
Dave Airlie Oct. 8, 2020, 4:02 a.m. UTC | #2
On Thu, 8 Oct 2020 at 13:41, Zack Rusin <zackr@vmware.com> wrote:
>
>
> > On Oct 5, 2020, at 20:06, Dave Airlie <airlied@gmail.com> wrote:
> >
> > From: Dave Airlie <airlied@redhat.com>
> >
> > This just copies the fallback to vmwgfx, I'm going to iterate on this
> > a bit until it's not the same as the fallback path.
> >
> > Signed-off-by: Dave Airlie <airlied@redhat.com>
>
> What are your plans for it? i.e. how is it going to be different?

Initial plan is to put move_notify inside the move callback, then
eventually get rid of the ttm bind/unbind callback and let the driver
do that itself if needed.

I've got most of it in a branch (and I posted a 45 patch series a week
or two ago), but I need to rebase and clean it up for reposting.

Dave.
Roland Scheidegger Oct. 8, 2020, 3:35 p.m. UTC | #3
Both vmwgxf patches look good to me too.
Reviewed-by: Roland Scheidegger <sroland@vmware.com>

Am 06.10.20 um 02:06 schrieb Dave Airlie:
> From: Dave Airlie <airlied@redhat.com>
> 
> This just copies the fallback to vmwgfx, I'm going to iterate on this
> a bit until it's not the same as the fallback path.
> 
> Signed-off-by: Dave Airlie <airlied@redhat.com>
> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c | 19 ++++++++++++++++++-
>  1 file changed, 18 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
> index 2f88d2d79f9a..6e36fc932aeb 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
> @@ -725,6 +725,23 @@ static void vmw_swap_notify(struct ttm_buffer_object *bo)
>  	(void) ttm_bo_wait(bo, false, false);
>  }
>  
> +static int vmw_move(struct ttm_buffer_object *bo,
> +		     bool evict,
> +		     struct ttm_operation_ctx *ctx,
> +		     struct ttm_resource *new_mem)
> +{
> +	struct ttm_resource_manager *old_man = ttm_manager_type(bo->bdev, bo->mem.mem_type);
> +	struct ttm_resource_manager *new_man = ttm_manager_type(bo->bdev, new_mem->mem_type);
> +
> +	if (old_man->use_tt && new_man->use_tt) {
> +		if (bo->mem.mem_type == TTM_PL_SYSTEM) {
> +			ttm_bo_assign_mem(bo, new_mem);
> +			return 0;
> +		}
> +		return ttm_bo_move_ttm(bo, ctx, new_mem);
> +	} else
> +		return ttm_bo_move_memcpy(bo, ctx, new_mem);
> +}
>  
>  struct ttm_bo_driver vmw_bo_driver = {
>  	.ttm_tt_create = &vmw_ttm_tt_create,
> @@ -735,7 +752,7 @@ struct ttm_bo_driver vmw_bo_driver = {
>  	.ttm_tt_destroy = &vmw_ttm_destroy,
>  	.eviction_valuable = ttm_bo_eviction_valuable,
>  	.evict_flags = vmw_evict_flags,
> -	.move = NULL,
> +	.move = vmw_move,
>  	.verify_access = vmw_verify_access,
>  	.move_notify = vmw_move_notify,
>  	.swap_notify = vmw_swap_notify,
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
index 2f88d2d79f9a..6e36fc932aeb 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
@@ -725,6 +725,23 @@  static void vmw_swap_notify(struct ttm_buffer_object *bo)
 	(void) ttm_bo_wait(bo, false, false);
 }
 
+static int vmw_move(struct ttm_buffer_object *bo,
+		     bool evict,
+		     struct ttm_operation_ctx *ctx,
+		     struct ttm_resource *new_mem)
+{
+	struct ttm_resource_manager *old_man = ttm_manager_type(bo->bdev, bo->mem.mem_type);
+	struct ttm_resource_manager *new_man = ttm_manager_type(bo->bdev, new_mem->mem_type);
+
+	if (old_man->use_tt && new_man->use_tt) {
+		if (bo->mem.mem_type == TTM_PL_SYSTEM) {
+			ttm_bo_assign_mem(bo, new_mem);
+			return 0;
+		}
+		return ttm_bo_move_ttm(bo, ctx, new_mem);
+	} else
+		return ttm_bo_move_memcpy(bo, ctx, new_mem);
+}
 
 struct ttm_bo_driver vmw_bo_driver = {
 	.ttm_tt_create = &vmw_ttm_tt_create,
@@ -735,7 +752,7 @@  struct ttm_bo_driver vmw_bo_driver = {
 	.ttm_tt_destroy = &vmw_ttm_destroy,
 	.eviction_valuable = ttm_bo_eviction_valuable,
 	.evict_flags = vmw_evict_flags,
-	.move = NULL,
+	.move = vmw_move,
 	.verify_access = vmw_verify_access,
 	.move_notify = vmw_move_notify,
 	.swap_notify = vmw_swap_notify,