ttm make move callback compulsory
Subsystems (5)
Dave Airlie
maintainercover ttm make move callback compulsory
I've just pulled out the few bits for making the move callback compulsory from my previous series.
The vmwgfx ones need acks/r-bs, I've booted them in vmplayer and they seem to work fine.
Dave.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerPATCH 2/5 drm/vmwgfx: move null mem checks outside move notifies
From: Dave Airlie <[email protected]>
Both fns checked mem == NULL, just move the check outside.
--- drivers/gpu/drm/vmwgfx/vmwgfx_bo.c | 3 --- drivers/gpu/drm/vmwgfx/vmwgfx_resource.c | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c | 2 ++ 3 files changed, 3 insertions(+), 4 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_bo.c +0 -3
@@ -1192,9 +1192,6 @@ void vmw_bo_move_notify(struct ttm_buffer_object *bo, {struct vmw_buffer_object *vbo; -if (mem ==NULL ) -return ; -/* Make sure @bo is embedded in a struct vmw_buffer_object? */ if (bo->destroy != vmw_bo_bo_free && bo->destroy != vmw_user_bo_destroy)
drivers/gpu/drm/vmwgfx/vmwgfx_resource.c +1 -1
@@ -867,7 +867,7 @@ void vmw_query_move_notify(struct ttm_buffer_object *bo,mutex_lock (&dev_priv->binding_mutex); dx_query_mob = container_of(bo, struct vmw_buffer_object, base); -if (mem ==NULL || !dx_query_mob || !dx_query_mob->dx_query_ctx) { +if (!dx_query_mob || !dx_query_mob->dx_query_ctx) {mutex_unlock (&dev_priv->binding_mutex);return ; }
drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c +2 -0
@@ -707,6 +707,8 @@ static void vmw_move_notify(struct ttm_buffer_object *bo, bool evict, struct ttm_resource *mem) { +if (!mem) +return ;vmw_bo_move_notify (bo, mem);vmw_query_move_notify (bo, mem); }
Signature · 6 lines
2.27.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerPATCH 1/5 drm/qxl: drop unused code (v2)
In reply to Dave AirlieFrom: Dave Airlie <[email protected]>
v2: drop the wrapper struct
--- drivers/gpu/drm/qxl/qxl_ttm.c | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-)
drivers/gpu/drm/qxl/qxl_ttm.c +8 -21
@@ -98,19 +98,11 @@ int qxl_ttm_io_mem_reserve(struct ttm_bo_device *bdev,/* * TTM backend functions. */ -struct qxl_ttm_tt { -struct ttm_tt ttm; -struct qxl_device *qdev; -u64 offset; -};static int qxl_ttm_backend_bind (struct ttm_bo_device *bdev,struct ttm_tt *ttm,struct ttm_resource *bo_mem) { -struct qxl_ttm_tt *gtt = (void *)ttm; - - gtt->offset = (unsigned long )(bo_mem->start <<PAGE_SHIFT );if (!ttm->num_pages) {WARN (1 ,"nothing to bind %lu pages for mreg %p back %p!\n" , ttm->num_pages, bo_mem, ttm);
@@ -128,29 +120,24 @@ static void qxl_ttm_backend_unbind(struct ttm_bo_device *bdev,static void qxl_ttm_backend_destroy (struct ttm_bo_device *bdev,struct ttm_tt *ttm) { -struct qxl_ttm_tt *gtt = (void *)ttm; -ttm_tt_destroy_common (bdev, ttm); -ttm_tt_fini (>t->ttm); -kfree (gtt); +ttm_tt_fini (ttm); +kfree (ttm); }static struct ttm_tt *qxl_ttm_tt_create (struct ttm_buffer_object *bo,uint32_t page_flags) { -struct qxl_device *qdev; -struct qxl_ttm_tt *gtt; +struct ttm_tt *ttm; - qdev =qxl_get_qdev (bo->bdev); - gtt =kzalloc (sizeof (struct qxl_ttm_tt ),GFP_KERNEL ); -if (gtt ==NULL ) + ttm =kzalloc (sizeof (struct ttm_tt ),GFP_KERNEL ); +if (ttm ==NULL )return NULL ; - gtt->qdev = qdev; -if (ttm_tt_init (>t->ttm, bo, page_flags)) { -kfree (gtt); +if (ttm_tt_init (ttm, bo, page_flags)) { +kfree (ttm);return NULL ; } -return >t->ttm; +return ttm; } static int qxl_bo_move(struct ttm_buffer_object *bo, bool evict,
Signature · 6 lines
2.27.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerPATCH 4/5 drm/vram_helper: implement a ttm move callback.
In reply to Dave AirlieFrom: Dave Airlie <[email protected]>
This will always do memcpy moves.
--- drivers/gpu/drm/drm_gem_vram_helper.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
drivers/gpu/drm/drm_gem_vram_helper.c +21 -0
@@ -588,6 +588,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 */
@@ -950,6 +958,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) {
@@ -974,6 +994,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, };
Signature · 6 lines
2.27.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerPATCH 3/5 drm/vmwgfx: add a move callback.
In reply to Dave AirlieFrom: Dave Airlie <[email protected]>
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.
--- drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)
drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c +18 -1
@@ -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,
Signature · 6 lines
2.27.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerPATCH 5/5 drm/ttm: make move callback compulstory
In reply to Dave AirlieFrom: Dave Airlie <[email protected]>
All drivers should have a move callback now so make it compulsory.
--- drivers/gpu/drm/ttm/ttm_bo.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-)
drivers/gpu/drm/ttm/ttm_bo.c +1 -12
@@ -270,18 +270,7 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,if (bdev->driver->move_notify) bdev->driver->move_notify (bo, evict, 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 { - ret =ttm_bo_move_memcpy (bo, ctx, mem); - } - + ret = bdev->driver->move (bo, evict, ctx, mem);if (ret) {if (bdev->driver->move_notify) {swap (*mem, bo->mem);
Signature · 6 lines
2.27.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Patches #1-#4 Acked-by: Christian König <[email protected]>
Patch #5 Reviewed-by: Christian König <[email protected]>
Am 06.10.20 um 02:06 schrieb Dave Airlie:
Quoted 9 lines
I've just pulled out the few bits for making the move callback compulsory from my previous series.
The vmwgfx ones need acks/r-bs, I've booted them in vmplayer and they seem to work fine.
Dave.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 2/5] drm/vmwgfx: move null mem checks outside move notifies
In reply to Dave AirlieQuoted 8 lines · Dave Airlie
From: Dave Airlie <[email protected]>
Both fns checked mem == NULL, just move the check outside.
Signed-off-by Dave Airlie <[email protected]>
That’s a nice cleanup.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 3/5] drm/vmwgfx: add a move callback.
In reply to Dave AirlieQuoted 9 lines · Dave Airlie
From: Dave Airlie <[email protected]>
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 <[email protected]>
What are your plans for it? i.e. how is it going to be different?
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerRe: [PATCH 3/5] drm/vmwgfx: add a move callback.
Quoted 4 lines · Zack Rusin
Quoted 4 lines · Dave Airlie
Quoted 8 lines
Quoted 6 lines
From: Dave Airlie <[email protected]>
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 <[email protected]>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.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 3/5] drm/vmwgfx: add a move callback.
In reply to Dave AirlieBoth vmwgxf patches look good to me too.
Am 06.10.20 um 02:06 schrieb Dave Airlie:
Quoted 40 lines
From: Dave Airlie <[email protected]>
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 <[email protected]>--- drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c +17
-0@@ -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,
drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c struct ttm_bo_driver vmw_bo_driver = { · line 758
Quoted 8 lines
drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c +1
-1@@ -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,
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel