ttm driver cleanups and invert move
Subsystems (6)
Dave Airlie
maintainercover ttm driver cleanups and invert move
The first 5 patches are just cleanups to remove unused functions and handle ttm operation ctx nicer in driver move paths.
The last 5 patches have the goal to invert the operation of the move driver callback. Currently the core does some tt related moves itself and pass the drivers the rest. I'd like to have the driver decide things instead, so only use the fallback paths when a driver has no move callback.
Dave.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerPATCH 1/10 drm/radeon: kill radeon_bo_wait
From: Dave Airlie <[email protected]>
this is unused
--- drivers/gpu/drm/radeon/radeon_object.c | 15 --------------- drivers/gpu/drm/radeon/radeon_object.h | 3 --- 2 files changed, 18 deletions(-)
drivers/gpu/drm/radeon/radeon_object.c +0 -15
@@ -825,21 +825,6 @@ int radeon_bo_fault_reserve_notify(struct ttm_buffer_object *bo)return 0 ; } -int radeon_bo_wait (struct radeon_bo *bo,u32 *mem_type,bool no_wait) -{ -int r; - - r =ttm_bo_reserve (&bo->tbo, true, no_wait,NULL ); -if (unlikely (r !=0 )) -return r; -if (mem_type) - *mem_type = bo->tbo.mem.mem_type; - - r =ttm_bo_wait (&bo->tbo, true, no_wait); -ttm_bo_unreserve (&bo->tbo); -return r; -} -/** * radeon_bo_fence - add fence to buffer object *
drivers/gpu/drm/radeon/radeon_object.h +0 -3
@@ -133,9 +133,6 @@ static inline u64 radeon_bo_mmap_offset(struct radeon_bo *bo)return drm_vma_node_offset_addr (&bo->tbo.base.vma_node); } -extern int radeon_bo_wait (struct radeon_bo *bo,u32 *mem_type, -bool no_wait); - extern int radeon_bo_create(struct radeon_device *rdev, unsigned long size, int byte_align, bool kernel, u32 domain, u32 flags,
Signature · 6 lines
2.27.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 01/10] drm/radeon: kill radeon_bo_wait
Am 23.09.20 um 05:04 schrieb Dave Airlie:
Quoted 5 lines
From: Dave Airlie <[email protected]>
this is unused
Signed-off-by Dave Airlie <[email protected]>
Quoted 36 lines
--- drivers/gpu/drm/radeon/radeon_object.c | 15 --------------- drivers/gpu/drm/radeon/radeon_object.h | 3 --- 2 files changed, 18 deletions(-)drivers/gpu/drm/radeon/radeon_object.c +0
-15@@ -825,21 +825,6 @@ int radeon_bo_fault_reserve_notify(struct ttm_buffer_object *bo)return 0 ; } -int radeon_bo_wait (struct radeon_bo *bo,u32 *mem_type,bool no_wait) -{ -int r; - - r =ttm_bo_reserve (&bo->tbo, true, no_wait,NULL ); -if (unlikely (r !=0 )) -return r; -if (mem_type) - *mem_type = bo->tbo.mem.mem_type; - - r =ttm_bo_wait (&bo->tbo, true, no_wait); -ttm_bo_unreserve (&bo->tbo); -return r; -} -/** * radeon_bo_fence - add fence to buffer object * drivers/gpu/drm/radeon/radeon_object.h +0
-0
drivers/gpu/drm/radeon/radeon_object.h static inline u64 radeon_bo_mmap_offset(struct radeon_bo *bo) · line 138
Quoted 9 lines
drivers/gpu/drm/radeon/radeon_object.h +0
-3@@ -133,9 +133,6 @@ static inline u64 radeon_bo_mmap_offset(struct radeon_bo *bo)return drm_vma_node_offset_addr (&bo->tbo.base.vma_node); } -extern int radeon_bo_wait (struct radeon_bo *bo,u32 *mem_type, -bool no_wait); - extern int radeon_bo_create(struct radeon_device *rdev, unsigned long size, int byte_align, bool kernel, u32 domain, u32 flags,
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerPATCH 2/10 drm/qxl: kill unused bo wait wrapper
In reply to Dave AirlieFrom: Dave Airlie <[email protected]>
This wasn't used anywheere
--- drivers/gpu/drm/qxl/qxl_object.h | 23 ----------------------- 1 file changed, 23 deletions(-)
drivers/gpu/drm/qxl/qxl_object.h +0 -23
@@ -58,29 +58,6 @@ static inline u64 qxl_bo_mmap_offset(struct qxl_bo *bo)return drm_vma_node_offset_addr (&bo->tbo.base.vma_node); } -static inline int qxl_bo_wait (struct qxl_bo *bo,u32 *mem_type, -bool no_wait) -{ -int r; - - r =ttm_bo_reserve (&bo->tbo, true, no_wait,NULL ); -if (unlikely (r !=0 )) { -if (r != -ERESTARTSYS ) { -struct drm_device *ddev = bo->tbo.base.dev; - -dev_err (ddev->dev,"%p reserve failed for wait\n" , - bo); - } -return r; - } -if (mem_type) - *mem_type = bo->tbo.mem.mem_type; - - r =ttm_bo_wait (&bo->tbo, true, no_wait); -ttm_bo_unreserve (&bo->tbo); -return r; -} - extern int qxl_bo_create(struct qxl_device *qdev, unsigned long size, bool kernel, bool pinned, u32 domain,
Signature · 6 lines
2.27.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 02/10] drm/qxl: kill unused bo wait wrapper
Am 23.09.20 um 05:04 schrieb Dave Airlie:
Quoted 5 lines
From: Dave Airlie <[email protected]>
This wasn't used anywheere
Signed-off-by Dave Airlie <[email protected]>
Quoted 28 lines
--- drivers/gpu/drm/qxl/qxl_object.h | 23 ----------------------- 1 file changed, 23 deletions(-)drivers/gpu/drm/qxl/qxl_object.h +0
-16@@ -58,29 +58,6 @@ static inline u64 qxl_bo_mmap_offset(struct qxl_bo *bo)return drm_vma_node_offset_addr (&bo->tbo.base.vma_node); } -static inline int qxl_bo_wait (struct qxl_bo *bo,u32 *mem_type, -bool no_wait) -{ -int r; - - r =ttm_bo_reserve (&bo->tbo, true, no_wait,NULL ); -if (unlikely (r !=0 )) { -if (r != -ERESTARTSYS ) { -struct drm_device *ddev = bo->tbo.base.dev; - -dev_err (ddev->dev,"%p reserve failed for wait\n" , - bo); - } -return r; - } -if (mem_type)
drivers/gpu/drm/qxl/qxl_object.h static inline u64 qxl_bo_mmap_offset(struct qxl_bo *bo) · line 63
Quoted 10 lines
drivers/gpu/drm/qxl/qxl_object.h +0
-7- *mem_type = bo->tbo.mem.mem_type; - - r =ttm_bo_wait (&bo->tbo, true, no_wait); -ttm_bo_unreserve (&bo->tbo); -return r; -} - extern int qxl_bo_create(struct qxl_device *qdev, unsigned long size, bool kernel, bool pinned, u32 domain,
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerPATCH 3/10 drm/radeon: cleanup ttm operation ctx usage.
In reply to Dave AirlieFrom: Dave Airlie <[email protected]>
Just pass it around move, and remove unused pieces
--- drivers/gpu/drm/radeon/radeon_ttm.c | 34 +++++++++++++---------------- 1 file changed, 15 insertions(+), 19 deletions(-)
drivers/gpu/drm/radeon/radeon_ttm.c +15 -19
@@ -151,7 +151,7 @@ static int radeon_verify_access(struct ttm_buffer_object *bo, struct file *filp) }static int radeon_move_blit (struct ttm_buffer_object *bo, -bool evict,bool no_wait_gpu, +bool evict,struct ttm_resource *new_mem,struct ttm_resource *old_mem) {
@@ -206,11 +206,10 @@ static int radeon_move_blit(struct ttm_buffer_object *bo, }static int radeon_move_vram_ram (struct ttm_buffer_object *bo, -bool evict,bool interruptible, -bool no_wait_gpu, +bool evict, +struct ttm_operation_ctx *ctx,struct ttm_resource *new_mem) { -struct ttm_operation_ctx ctx = { interruptible, no_wait_gpu };struct ttm_resource *old_mem = &bo->mem;struct ttm_resource tmp_mem;struct ttm_place placements;
@@ -227,7 +226,7 @@ static int radeon_move_vram_ram(struct ttm_buffer_object *bo, placements.lpfn =0 ; placements.mem_type =TTM_PL_TT ; placements.flags =TTM_PL_MASK_CACHING ; - r =ttm_bo_mem_space (bo, &placement, &tmp_mem, &ctx); + r =ttm_bo_mem_space (bo, &placement, &tmp_mem, ctx);if (unlikely (r)) {return r; }
@@ -237,7 +236,7 @@ static int radeon_move_vram_ram(struct ttm_buffer_object *bo, goto out_cleanup; } - r =ttm_tt_populate (bo->bdev, bo->ttm, &ctx); + r =ttm_tt_populate (bo->bdev, bo->ttm, ctx);if (unlikely (r)) { goto out_cleanup; }
@@ -246,22 +245,21 @@ static int radeon_move_vram_ram(struct ttm_buffer_object *bo,if (unlikely (r)) { goto out_cleanup; } - r =radeon_move_blit (bo, true, no_wait_gpu, &tmp_mem, old_mem); + r =radeon_move_blit (bo, true, &tmp_mem, old_mem);if (unlikely (r)) { goto out_cleanup; } - r =ttm_bo_move_ttm (bo, &ctx, new_mem); + r =ttm_bo_move_ttm (bo, ctx, new_mem); out_cleanup:ttm_resource_free (bo, &tmp_mem);return r; }static int radeon_move_ram_vram (struct ttm_buffer_object *bo, -bool evict,bool interruptible, -bool no_wait_gpu, +bool evict, +struct ttm_operation_ctx *ctx,struct ttm_resource *new_mem) { -struct ttm_operation_ctx ctx = { interruptible, no_wait_gpu };struct ttm_resource *old_mem = &bo->mem;struct ttm_resource tmp_mem;struct ttm_placement placement;
@@ -278,15 +276,15 @@ static int radeon_move_ram_vram(struct ttm_buffer_object *bo, placements.lpfn =0 ; placements.mem_type =TTM_PL_TT ; placements.flags =TTM_PL_MASK_CACHING ; - r =ttm_bo_mem_space (bo, &placement, &tmp_mem, &ctx); + r =ttm_bo_mem_space (bo, &placement, &tmp_mem, ctx);if (unlikely (r)) {return r; } - r =ttm_bo_move_ttm (bo, &ctx, &tmp_mem); + r =ttm_bo_move_ttm (bo, ctx, &tmp_mem);if (unlikely (r)) { goto out_cleanup; } - r =radeon_move_blit (bo, true, no_wait_gpu, new_mem, old_mem); + r =radeon_move_blit (bo, true, new_mem, old_mem);if (unlikely (r)) { goto out_cleanup; }
@@ -334,14 +332,12 @@ static int radeon_bo_move(struct ttm_buffer_object *bo, bool evict,if (old_mem->mem_type ==TTM_PL_VRAM && new_mem->mem_type ==TTM_PL_SYSTEM ) { - r =radeon_move_vram_ram (bo, evict, ctx->interruptible, - ctx->no_wait_gpu, new_mem); + r =radeon_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 =radeon_move_ram_vram (bo, evict, ctx->interruptible, - ctx->no_wait_gpu, new_mem); + r =radeon_move_ram_vram (bo, evict, ctx, new_mem); }else { - r =radeon_move_blit (bo, evict, ctx->no_wait_gpu, + r =radeon_move_blit (bo, evict, new_mem, old_mem); }
Signature · 6 lines
2.27.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 03/10] drm/radeon: cleanup ttm operation ctx usage.
Am 23.09.20 um 05:04 schrieb Dave Airlie:
Quoted 5 lines
From: Dave Airlie <[email protected]>
Just pass it around move, and remove unused pieces
Signed-off-by Dave Airlie <[email protected]>
Quoted 103 lines
--- drivers/gpu/drm/radeon/radeon_ttm.c | 34 +++++++++++++---------------- 1 file changed, 15 insertions(+), 19 deletions(-)drivers/gpu/drm/radeon/radeon_ttm.c +13
-16@@ -151,7 +151,7 @@ static int radeon_verify_access(struct ttm_buffer_object *bo, struct file *filp) }static int radeon_move_blit (struct ttm_buffer_object *bo, -bool evict,bool no_wait_gpu, +bool evict,struct ttm_resource *new_mem,struct ttm_resource *old_mem) {@@ -206,11 +206,10 @@ static int radeon_move_blit(struct ttm_buffer_object *bo, }static int radeon_move_vram_ram (struct ttm_buffer_object *bo, -bool evict,bool interruptible, -bool no_wait_gpu, +bool evict, +struct ttm_operation_ctx *ctx,struct ttm_resource *new_mem) { -struct ttm_operation_ctx ctx = { interruptible, no_wait_gpu };struct ttm_resource *old_mem = &bo->mem;struct ttm_resource tmp_mem;struct ttm_place placements;@@ -227,7 +226,7 @@ static int radeon_move_vram_ram(struct ttm_buffer_object *bo, placements.lpfn =0 ; placements.mem_type =TTM_PL_TT ; placements.flags =TTM_PL_MASK_CACHING ; - r =ttm_bo_mem_space (bo, &placement, &tmp_mem, &ctx); + r =ttm_bo_mem_space (bo, &placement, &tmp_mem, ctx);if (unlikely (r)) {return r; }@@ -237,7 +236,7 @@ static int radeon_move_vram_ram(struct ttm_buffer_object *bo, goto out_cleanup; } - r =ttm_tt_populate (bo->bdev, bo->ttm, &ctx); + r =ttm_tt_populate (bo->bdev, bo->ttm, ctx);if (unlikely (r)) { goto out_cleanup; }@@ -246,22 +245,21 @@ static int radeon_move_vram_ram(struct ttm_buffer_object *bo,if (unlikely (r)) { goto out_cleanup; } - r =radeon_move_blit (bo, true, no_wait_gpu, &tmp_mem, old_mem); + r =radeon_move_blit (bo, true, &tmp_mem, old_mem);if (unlikely (r)) { goto out_cleanup; } - r =ttm_bo_move_ttm (bo, &ctx, new_mem); + r =ttm_bo_move_ttm (bo, ctx, new_mem); out_cleanup:ttm_resource_free (bo, &tmp_mem);return r; }static int radeon_move_ram_vram (struct ttm_buffer_object *bo, -bool evict,bool interruptible, -bool no_wait_gpu, +bool evict, +struct ttm_operation_ctx *ctx,struct ttm_resource *new_mem) { -struct ttm_operation_ctx ctx = { interruptible, no_wait_gpu };struct ttm_resource *old_mem = &bo->mem;struct ttm_resource tmp_mem;struct ttm_placement placement;@@ -278,15 +276,15 @@ static int radeon_move_ram_vram(struct ttm_buffer_object *bo, placements.lpfn =0 ; placements.mem_type =TTM_PL_TT ; placements.flags =TTM_PL_MASK_CACHING ; - r =ttm_bo_mem_space (bo, &placement, &tmp_mem, &ctx); + r =ttm_bo_mem_space (bo, &placement, &tmp_mem, ctx);if (unlikely (r)) {return r; } - r =ttm_bo_move_ttm (bo, &ctx, &tmp_mem); + r =ttm_bo_move_ttm (bo, ctx, &tmp_mem);if (unlikely (r)) { goto out_cleanup; } - r =radeon_move_blit (bo, true, no_wait_gpu, new_mem, old_mem); + r =radeon_move_blit (bo, true, new_mem, old_mem);if (unlikely (r)) { goto out_cleanup; }@@ -334,14 +332,12 @@ static int radeon_bo_move(struct ttm_buffer_object *bo, bool evict,if (old_mem->mem_type ==TTM_PL_VRAM && new_mem->mem_type ==TTM_PL_SYSTEM ) { - r =radeon_move_vram_ram (bo, evict, ctx->interruptible, - ctx->no_wait_gpu, new_mem); + r =radeon_move_vram_ram (bo, evict, ctx, new_mem); } else if (old_mem->mem_type == TTM_PL_SYSTEM &&
drivers/gpu/drm/radeon/radeon_ttm.c static int radeon_bo_move(struct ttm_buffer_object *bo, bool evict, · line 343
Quoted 10 lines
drivers/gpu/drm/radeon/radeon_ttm.c +2
-3new_mem->mem_type == TTM_PL_VRAM) { - r = radeon_move_ram_vram(bo, evict, ctx->interruptible, - ctx->no_wait_gpu, new_mem); + r = radeon_move_ram_vram(bo, evict, ctx, new_mem); } else { - r =radeon_move_blit (bo, evict, ctx->no_wait_gpu, + r =radeon_move_blit (bo, evict, new_mem, old_mem); }
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerPATCH 4/10 drm/nouveau/ttm: plumb ctx through move functions.
In reply to Dave AirlieFrom: Dave Airlie <[email protected]>
This just uses the ctx instead of passing bools and recreating it.
--- drivers/gpu/drm/nouveau/nouveau_bo.c | 48 +++++++++++++--------------- 1 file changed, 23 insertions(+), 25 deletions(-)
drivers/gpu/drm/nouveau/nouveau_bo.c +23 -25
@@ -772,8 +772,9 @@ nouveau_bo_move_prep(struct nouveau_drm *drm, struct ttm_buffer_object *bo, }static int -nouveau_bo_move_m2mf (struct ttm_buffer_object *bo,int evict,bool intr, -bool no_wait_gpu,struct ttm_resource *new_reg) +nouveau_bo_move_m2mf (struct ttm_buffer_object *bo,int evict, +struct ttm_operation_ctx *ctx, +struct ttm_resource *new_reg) {struct nouveau_drm *drm =nouveau_bdev (bo->bdev);struct nouveau_channel *chan = drm->ttm.chan;
@@ -792,7 +793,7 @@ nouveau_bo_move_m2mf(struct ttm_buffer_object *bo, int evict, bool intr, }mutex_lock_nested (&cli->mutex,SINGLE_DEPTH_NESTING ); - ret =nouveau_fence_sync (nouveau_bo (bo), chan, true, intr); + ret =nouveau_fence_sync (nouveau_bo (bo), chan, true, ctx->interruptible);if (ret ==0 ) { ret = drm->ttm.move (chan, bo, &bo->mem, new_reg);if (ret ==0 ) {
@@ -879,10 +880,10 @@ nouveau_bo_move_init(struct nouveau_drm *drm) }static int -nouveau_bo_move_flipd (struct ttm_buffer_object *bo,bool evict,bool intr, -bool no_wait_gpu,struct ttm_resource *new_reg) +nouveau_bo_move_flipd (struct ttm_buffer_object *bo,bool evict, +struct ttm_operation_ctx *ctx, +struct ttm_resource *new_reg) { -struct ttm_operation_ctx ctx = { intr, no_wait_gpu };struct ttm_place placement_memtype = { .fpfn =0 , .lpfn =0 ,
@@ -898,11 +899,11 @@ nouveau_bo_move_flipd(struct ttm_buffer_object *bo, bool evict, bool intr, tmp_reg = *new_reg; tmp_reg.mm_node =NULL ; - ret =ttm_bo_mem_space (bo, &placement, &tmp_reg, &ctx); + ret =ttm_bo_mem_space (bo, &placement, &tmp_reg, ctx);if (ret)return ret; - ret =ttm_tt_populate (bo->bdev, bo->ttm, &ctx); + ret =ttm_tt_populate (bo->bdev, bo->ttm, ctx);if (ret) goto out;
@@ -910,21 +911,21 @@ nouveau_bo_move_flipd(struct ttm_buffer_object *bo, bool evict, bool intr,if (ret) goto out; - ret =nouveau_bo_move_m2mf (bo, true, intr, no_wait_gpu, &tmp_reg); + ret =nouveau_bo_move_m2mf (bo, true, ctx, &tmp_reg);if (ret) goto out; - ret =ttm_bo_move_ttm (bo, &ctx, new_reg); + ret =ttm_bo_move_ttm (bo, ctx, new_reg); out:ttm_resource_free (bo, &tmp_reg);return ret; }static int -nouveau_bo_move_flips (struct ttm_buffer_object *bo,bool evict,bool intr, -bool no_wait_gpu,struct ttm_resource *new_reg) +nouveau_bo_move_flips (struct ttm_buffer_object *bo,bool evict, +struct ttm_operation_ctx *ctx, +struct ttm_resource *new_reg) { -struct ttm_operation_ctx ctx = { intr, no_wait_gpu };struct ttm_place placement_memtype = { .fpfn =0 , .lpfn =0 ,
@@ -940,15 +941,15 @@ nouveau_bo_move_flips(struct ttm_buffer_object *bo, bool evict, bool intr, tmp_reg = *new_reg; tmp_reg.mm_node =NULL ; - ret =ttm_bo_mem_space (bo, &placement, &tmp_reg, &ctx); + ret =ttm_bo_mem_space (bo, &placement, &tmp_reg, ctx);if (ret)return ret; - ret =ttm_bo_move_ttm (bo, &ctx, &tmp_reg); + ret =ttm_bo_move_ttm (bo, ctx, &tmp_reg);if (ret) goto out; - ret =nouveau_bo_move_m2mf (bo, true, intr, no_wait_gpu, new_reg); + ret =nouveau_bo_move_m2mf (bo, true, ctx, new_reg);if (ret) goto out;
@@ -1059,17 +1060,14 @@ nouveau_bo_move(struct ttm_buffer_object *bo, bool evict,/* Hardware assisted copy. */ if (drm->ttm.move) {if (new_reg->mem_type ==TTM_PL_SYSTEM ) - ret =nouveau_bo_move_flipd (bo, evict, - ctx->interruptible, - ctx->no_wait_gpu, new_reg); + ret =nouveau_bo_move_flipd (bo, evict, ctx, + new_reg);else if (old_reg->mem_type ==TTM_PL_SYSTEM ) - ret =nouveau_bo_move_flips (bo, evict, - ctx->interruptible, - ctx->no_wait_gpu, new_reg); + ret =nouveau_bo_move_flips (bo, evict, ctx, + new_reg);else - ret =nouveau_bo_move_m2mf (bo, evict, - ctx->interruptible, - ctx->no_wait_gpu, new_reg); + ret =nouveau_bo_move_m2mf (bo, evict, ctx, + new_reg);if (!ret) goto out; }
Signature · 6 lines
2.27.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 04/10] drm/nouveau/ttm: plumb ctx through move functions.
Am 23.09.20 um 05:04 schrieb Dave Airlie:
Quoted 5 lines
From: Dave Airlie <[email protected]>
This just uses the ctx instead of passing bools and recreating it.
Signed-off-by Dave Airlie <[email protected]>
Quoted 117 lines
--- drivers/gpu/drm/nouveau/nouveau_bo.c | 48 +++++++++++++--------------- 1 file changed, 23 insertions(+), 25 deletions(-)drivers/gpu/drm/nouveau/nouveau_bo.c +20
-22@@ -772,8 +772,9 @@ nouveau_bo_move_prep(struct nouveau_drm *drm, struct ttm_buffer_object *bo, }static int -nouveau_bo_move_m2mf (struct ttm_buffer_object *bo,int evict,bool intr, -bool no_wait_gpu,struct ttm_resource *new_reg) +nouveau_bo_move_m2mf (struct ttm_buffer_object *bo,int evict, +struct ttm_operation_ctx *ctx, +struct ttm_resource *new_reg) {struct nouveau_drm *drm =nouveau_bdev (bo->bdev);struct nouveau_channel *chan = drm->ttm.chan;@@ -792,7 +793,7 @@ nouveau_bo_move_m2mf(struct ttm_buffer_object *bo, int evict, bool intr, }mutex_lock_nested (&cli->mutex,SINGLE_DEPTH_NESTING ); - ret =nouveau_fence_sync (nouveau_bo (bo), chan, true, intr); + ret =nouveau_fence_sync (nouveau_bo (bo), chan, true, ctx->interruptible);if (ret ==0 ) { ret = drm->ttm.move (chan, bo, &bo->mem, new_reg);if (ret ==0 ) {@@ -879,10 +880,10 @@ nouveau_bo_move_init(struct nouveau_drm *drm) }static int -nouveau_bo_move_flipd (struct ttm_buffer_object *bo,bool evict,bool intr, -bool no_wait_gpu,struct ttm_resource *new_reg) +nouveau_bo_move_flipd (struct ttm_buffer_object *bo,bool evict, +struct ttm_operation_ctx *ctx, +struct ttm_resource *new_reg) { -struct ttm_operation_ctx ctx = { intr, no_wait_gpu };struct ttm_place placement_memtype = { .fpfn =0 , .lpfn =0 ,@@ -898,11 +899,11 @@ nouveau_bo_move_flipd(struct ttm_buffer_object *bo, bool evict, bool intr, tmp_reg = *new_reg; tmp_reg.mm_node =NULL ; - ret =ttm_bo_mem_space (bo, &placement, &tmp_reg, &ctx); + ret =ttm_bo_mem_space (bo, &placement, &tmp_reg, ctx);if (ret)return ret; - ret =ttm_tt_populate (bo->bdev, bo->ttm, &ctx); + ret =ttm_tt_populate (bo->bdev, bo->ttm, ctx);if (ret) goto out;@@ -910,21 +911,21 @@ nouveau_bo_move_flipd(struct ttm_buffer_object *bo, bool evict, bool intr,if (ret) goto out; - ret =nouveau_bo_move_m2mf (bo, true, intr, no_wait_gpu, &tmp_reg); + ret =nouveau_bo_move_m2mf (bo, true, ctx, &tmp_reg);if (ret) goto out; - ret =ttm_bo_move_ttm (bo, &ctx, new_reg); + ret =ttm_bo_move_ttm (bo, ctx, new_reg); out:ttm_resource_free (bo, &tmp_reg);return ret; }static int -nouveau_bo_move_flips (struct ttm_buffer_object *bo,bool evict,bool intr, -bool no_wait_gpu,struct ttm_resource *new_reg) +nouveau_bo_move_flips (struct ttm_buffer_object *bo,bool evict, +struct ttm_operation_ctx *ctx, +struct ttm_resource *new_reg) { -struct ttm_operation_ctx ctx = { intr, no_wait_gpu };struct ttm_place placement_memtype = { .fpfn =0 , .lpfn =0 ,@@ -940,15 +941,15 @@ nouveau_bo_move_flips(struct ttm_buffer_object *bo, bool evict, bool intr, tmp_reg = *new_reg; tmp_reg.mm_node =NULL ; - ret =ttm_bo_mem_space (bo, &placement, &tmp_reg, &ctx); + ret =ttm_bo_mem_space (bo, &placement, &tmp_reg, ctx);if (ret)return ret; - ret =ttm_bo_move_ttm (bo, &ctx, &tmp_reg); + ret =ttm_bo_move_ttm (bo, ctx, &tmp_reg);if (ret) goto out; - ret =nouveau_bo_move_m2mf (bo, true, intr, no_wait_gpu, new_reg); + ret =nouveau_bo_move_m2mf (bo, true, ctx, new_reg);if (ret) goto out;@@ -1059,17 +1060,14 @@ nouveau_bo_move(struct ttm_buffer_object *bo, bool evict,/* Hardware assisted copy. */ if (drm->ttm.move) {if (new_reg->mem_type ==TTM_PL_SYSTEM ) - ret =nouveau_bo_move_flipd (bo, evict, - ctx->interruptible, - ctx->no_wait_gpu, new_reg); + ret =nouveau_bo_move_flipd (bo, evict, ctx, + new_reg);else if (old_reg->mem_type ==TTM_PL_SYSTEM ) - ret =nouveau_bo_move_flips (bo, evict, - ctx->interruptible, - ctx->no_wait_gpu, new_reg); + ret = nouveau_bo_move_flips(bo, evict, ctx,
drivers/gpu/drm/nouveau/nouveau_bo.c nouveau_bo_move(struct ttm_buffer_object *bo, bool evict, · line 1073
Quoted 10 lines
drivers/gpu/drm/nouveau/nouveau_bo.c +3
-3+ new_reg); else - ret =nouveau_bo_move_m2mf (bo, evict, - ctx->interruptible, - ctx->no_wait_gpu, new_reg); + ret =nouveau_bo_move_m2mf (bo, evict, ctx, + new_reg);if (!ret) goto out; }
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerPATCH 5/10 drm/ttm: add bo wait that takes a ctx wrapper.
In reply to Dave AirlieFrom: Dave Airlie <[email protected]>
I'm thinking of pushing the wait into the drivers.
--- drivers/gpu/drm/nouveau/nouveau_bo.c | 4 ++-- drivers/gpu/drm/qxl/qxl_ttm.c | 2 +- drivers/gpu/drm/radeon/radeon_ttm.c | 2 +- drivers/gpu/drm/ttm/ttm_bo_util.c | 4 ++-- include/drm/ttm/ttm_bo_api.h | 5 +++++ 5 files changed, 11 insertions(+), 6 deletions(-)
drivers/gpu/drm/nouveau/nouveau_bo.c +2 -2
@@ -1038,7 +1038,7 @@ nouveau_bo_move(struct ttm_buffer_object *bo, bool evict,struct nouveau_drm_tile *new_tile =NULL ;int ret =0 ; - ret =ttm_bo_wait (bo, ctx->interruptible, ctx->no_wait_gpu); + ret =ttm_bo_wait_ctx (bo, ctx);if (ret)return ret;
@@ -1073,7 +1073,7 @@ nouveau_bo_move(struct ttm_buffer_object *bo, bool evict, }/* Fallback to software copy. */ - ret =ttm_bo_wait (bo, ctx->interruptible, ctx->no_wait_gpu); + ret =ttm_bo_wait_ctx (bo, ctx);if (ret ==0 ) ret =ttm_bo_move_memcpy (bo, ctx, new_reg);
drivers/gpu/drm/qxl/qxl_ttm.c +1 -1
@@ -160,7 +160,7 @@ static int qxl_bo_move(struct ttm_buffer_object *bo, bool evict,struct ttm_resource *old_mem = &bo->mem;int ret; - ret =ttm_bo_wait (bo, ctx->interruptible, ctx->no_wait_gpu); + ret =ttm_bo_wait_ctx (bo, ctx);if (ret)return ret;
drivers/gpu/drm/radeon/radeon_ttm.c +1 -1
@@ -302,7 +302,7 @@ static int radeon_bo_move(struct ttm_buffer_object *bo, bool evict,struct ttm_resource *old_mem = &bo->mem;int r; - r =ttm_bo_wait (bo, ctx->interruptible, ctx->no_wait_gpu); + r =ttm_bo_wait_ctx (bo, ctx);if (r)return r;
drivers/gpu/drm/ttm/ttm_bo_util.c +2 -2
@@ -59,7 +59,7 @@ int ttm_bo_move_ttm(struct ttm_buffer_object *bo,int ret;if (old_mem->mem_type !=TTM_PL_SYSTEM ) { - ret =ttm_bo_wait (bo, ctx->interruptible, ctx->no_wait_gpu); + ret =ttm_bo_wait_ctx (bo, ctx);if (unlikely (ret !=0 )) {if (ret != -ERESTARTSYS )
@@ -231,7 +231,7 @@ int ttm_bo_move_memcpy(struct ttm_buffer_object *bo,unsigned long add =0 ;int dir; - ret =ttm_bo_wait (bo, ctx->interruptible, ctx->no_wait_gpu); + ret =ttm_bo_wait_ctx (bo, ctx);if (ret)return ret;
include/drm/ttm/ttm_bo_api.h +5 -0
@@ -262,6 +262,11 @@ ttm_bo_get_unless_zero(struct ttm_buffer_object *bo)*/ int ttm_bo_wait (struct ttm_buffer_object *bo,bool interruptible,bool no_wait); +static inline int ttm_bo_wait_ctx (struct ttm_buffer_object *bo,struct ttm_operation_ctx *ctx) +{ +return ttm_bo_wait (bo, ctx->interruptible, ctx->no_wait_gpu); +} +/** * ttm_bo_mem_compat - Check if proposed placement is compatible with a bo *
Signature · 6 lines
2.27.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 05/10] drm/ttm: add bo wait that takes a ctx wrapper.
Am 23.09.20 um 05:04 schrieb Dave Airlie:
Quoted 5 lines
From: Dave Airlie <[email protected]>
I'm thinking of pushing the wait into the drivers.
Signed-off-by Dave Airlie <[email protected]>
Quoted 84 lines
--- drivers/gpu/drm/nouveau/nouveau_bo.c | 4 ++-- drivers/gpu/drm/qxl/qxl_ttm.c | 2 +- drivers/gpu/drm/radeon/radeon_ttm.c | 2 +- drivers/gpu/drm/ttm/ttm_bo_util.c | 4 ++-- include/drm/ttm/ttm_bo_api.h | 5 +++++ 5 files changed, 11 insertions(+), 6 deletions(-)drivers/gpu/drm/nouveau/nouveau_bo.c +2
-2@@ -1038,7 +1038,7 @@ nouveau_bo_move(struct ttm_buffer_object *bo, bool evict,struct nouveau_drm_tile *new_tile =NULL ;int ret =0 ; - ret =ttm_bo_wait (bo, ctx->interruptible, ctx->no_wait_gpu); + ret =ttm_bo_wait_ctx (bo, ctx);if (ret)return ret;@@ -1073,7 +1073,7 @@ nouveau_bo_move(struct ttm_buffer_object *bo, bool evict, }/* Fallback to software copy. */ - ret =ttm_bo_wait (bo, ctx->interruptible, ctx->no_wait_gpu); + ret =ttm_bo_wait_ctx (bo, ctx);if (ret ==0 ) ret =ttm_bo_move_memcpy (bo, ctx, new_reg);drivers/gpu/drm/qxl/qxl_ttm.c +1
-1@@ -160,7 +160,7 @@ static int qxl_bo_move(struct ttm_buffer_object *bo, bool evict,struct ttm_resource *old_mem = &bo->mem;int ret; - ret =ttm_bo_wait (bo, ctx->interruptible, ctx->no_wait_gpu); + ret =ttm_bo_wait_ctx (bo, ctx);if (ret)return ret;drivers/gpu/drm/radeon/radeon_ttm.c +1
-1@@ -302,7 +302,7 @@ static int radeon_bo_move(struct ttm_buffer_object *bo, bool evict,struct ttm_resource *old_mem = &bo->mem;int r; - r =ttm_bo_wait (bo, ctx->interruptible, ctx->no_wait_gpu); + r =ttm_bo_wait_ctx (bo, ctx);if (r)return r;drivers/gpu/drm/ttm/ttm_bo_util.c +2
-2@@ -59,7 +59,7 @@ int ttm_bo_move_ttm(struct ttm_buffer_object *bo,int ret;if (old_mem->mem_type !=TTM_PL_SYSTEM ) { - ret =ttm_bo_wait (bo, ctx->interruptible, ctx->no_wait_gpu); + ret =ttm_bo_wait_ctx (bo, ctx);if (unlikely (ret !=0 )) {if (ret != -ERESTARTSYS )@@ -231,7 +231,7 @@ int ttm_bo_move_memcpy(struct ttm_buffer_object *bo,unsigned long add =0 ;int dir; - ret =ttm_bo_wait (bo, ctx->interruptible, ctx->no_wait_gpu); + ret =ttm_bo_wait_ctx (bo, ctx);if (ret)return ret;include/drm/ttm/ttm_bo_api.h +0
-0@@ -262,6 +262,11 @@ ttm_bo_get_unless_zero(struct ttm_buffer_object *bo)*/
include/drm/ttm/ttm_bo_api.h ttm_bo_get_unless_zero(struct ttm_buffer_object *bo) · line 272
Quoted 10 lines
include/drm/ttm/ttm_bo_api.h +5
-0int ttm_bo_wait (struct ttm_buffer_object *bo,bool interruptible,bool no_wait); +static inline int ttm_bo_wait_ctx (struct ttm_buffer_object *bo,struct ttm_operation_ctx *ctx) +{ +return ttm_bo_wait (bo, ctx->interruptible, ctx->no_wait_gpu); +} +/** * ttm_bo_mem_compat - Check if proposed placement is compatible with a bo *
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerPATCH 6/10 drm/ttm: handle the SYSTEM->TT path in same place as others.
In reply to Dave AirlieFrom: Dave Airlie <[email protected]>
This just consolidates the code making the flow easier to understand and also helps when moving move to the driver side.
--- drivers/gpu/drm/ttm/ttm_bo.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-)
drivers/gpu/drm/ttm/ttm_bo.c +7 -10
@@ -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 ;
Signature · 6 lines
2.27.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerPATCH 7/10 drm/amdgpu/ttm: handle tt moves properly.
In reply to Dave AirlieFrom: Dave Airlie <[email protected]>
The core move code currently handles use_tt moves, for amdgpu this was being handled also in the driver, but not using the same paths.
If moving between TT/SYSTEM (all the use_tt paths on amdgpu) use the core move function.
Eventually the core will be flipped over to calling the driver.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +7 -5
@@ -671,14 +671,16 @@ static int amdgpu_bo_move(struct ttm_buffer_object *bo, bool evict,ttm_bo_move_null (bo, new_mem);return 0 ; } -if ((old_mem->mem_type ==TTM_PL_TT && - new_mem->mem_type ==TTM_PL_SYSTEM ) || - (old_mem->mem_type ==TTM_PL_SYSTEM && - new_mem->mem_type ==TTM_PL_TT )) { -/* bind is enough */ +if (old_mem->mem_type ==TTM_PL_SYSTEM && + new_mem->mem_type ==TTM_PL_TT ) {ttm_bo_move_null (bo, new_mem);return 0 ; } + +if (old_mem->mem_type ==TTM_PL_TT && + new_mem->mem_type ==TTM_PL_SYSTEM ) +return ttm_bo_move_ttm (bo, ctx, new_mem); + if (old_mem->mem_type == AMDGPU_PL_GDS || old_mem->mem_type == AMDGPU_PL_GWS || old_mem->mem_type == AMDGPU_PL_OA ||
Signature · 6 lines
2.27.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Christian König
maintainerRe: [PATCH 07/10] drm/amdgpu/ttm: handle tt moves properly.
Am 23.09.20 um 05:04 schrieb Dave Airlie:
Quoted 22 lines
From: Dave Airlie <[email protected]>
The core move code currently handles
use_ttmoves, for amdgpu this was being handled also in the driver, but not using the same paths.If moving between TT/SYSTEM (all the
use_ttpaths on amdgpu) use the core move function.Eventually the core will be flipped over to calling the driver.
Signed-off-by Dave Airlie <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0
-0@@ -671,14 +671,16 @@ static int amdgpu_bo_move(struct ttm_buffer_object *bo, bool evict,ttm_bo_move_null (bo, new_mem);
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static int amdgpu_bo_move(struct ttm_buffer_object *bo, bool evict, · line 676
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +2
-5return 0 ; } -if ((old_mem->mem_type ==TTM_PL_TT && - new_mem->mem_type ==TTM_PL_SYSTEM ) || - (old_mem->mem_type ==TTM_PL_SYSTEM && - new_mem->mem_type ==TTM_PL_TT )) { -/* bind is enough */ +if (old_mem->mem_type ==TTM_PL_SYSTEM && + new_mem->mem_type ==TTM_PL_TT ) {ttm_bo_move_null (bo, new_mem);
I would feel better if we nuke ttm_bo_move_null() and always use ttm_bo_move_ttm().
Christian.
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static int amdgpu_bo_move(struct ttm_buffer_object *bo, bool evict, · line 686
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +5
-0return 0 ; } + +if (old_mem->mem_type ==TTM_PL_TT && + new_mem->mem_type ==TTM_PL_SYSTEM ) +return ttm_bo_move_ttm (bo, ctx, new_mem); + if (old_mem->mem_type == AMDGPU_PL_GDS || old_mem->mem_type == AMDGPU_PL_GWS || old_mem->mem_type == AMDGPU_PL_OA ||
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerRe: [PATCH 07/10] drm/amdgpu/ttm: handle tt moves properly.
Quoted 29 lines · Christian König
Am 23.09.20 um 05:04 schrieb Dave Airlie:
Quoted 27 lines
From: Dave Airlie <[email protected]>
The core move code currently handles
use_ttmoves, for amdgpu this was being handled also in the driver, but not using the same paths.If moving between TT/SYSTEM (all the
use_ttpaths on amdgpu) use the core move function.Eventually the core will be flipped over to calling the driver.
Signed-off-by Dave Airlie <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0
-3@@ -671,14 +671,16 @@ static int amdgpu_bo_move(struct ttm_buffer_object *bo, bool evict,ttm_bo_move_null (bo, new_mem);return 0 ; } - if ((old_mem->mem_type == TTM_PL_TT && - new_mem->mem_type == TTM_PL_SYSTEM) || - (old_mem->mem_type == TTM_PL_SYSTEM &&
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static int amdgpu_bo_move(struct ttm_buffer_object *bo, bool evict, · line 676
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +2
-2- new_mem->mem_type == TTM_PL_TT)) { -/* bind is enough */ +if (old_mem->mem_type ==TTM_PL_SYSTEM && + new_mem->mem_type ==TTM_PL_TT ) {ttm_bo_move_null (bo, new_mem);I would feel better if we nuke
ttm_bo_move_null()and always usettm_bo_move_ttm().
Any reason? The code path in the current move code pretty much is this.
The current move paths are
if (new_tt && old_tt)
if old is system
move null
else
move ttm
else
call driver move.
So I wanted to maintain that order. calling the move ttm will just make a pointless caching, populate, bind step.
But I'm going to think about it a bit more.
Dave.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerRe: [PATCH 07/10] drm/amdgpu/ttm: handle tt moves properly.
Quoted 53 lines · Dave Airlie
Quoted 29 lines · Christian König
Am 23.09.20 um 05:04 schrieb Dave Airlie:
Quoted 27 lines
From: Dave Airlie <[email protected]>
The core move code currently handles
use_ttmoves, for amdgpu this was being handled also in the driver, but not using the same paths.If moving between TT/SYSTEM (all the
use_ttpaths on amdgpu) use the core move function.Eventually the core will be flipped over to calling the driver.
Signed-off-by Dave Airlie <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0
-3@@ -671,14 +671,16 @@ static int amdgpu_bo_move(struct ttm_buffer_object *bo, bool evict,ttm_bo_move_null (bo, new_mem);return 0 ; } - if ((old_mem->mem_type == TTM_PL_TT && - new_mem->mem_type == TTM_PL_SYSTEM) || - (old_mem->mem_type == TTM_PL_SYSTEM &&Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static int amdgpu_bo_move(struct ttm_buffer_object *bo, bool evict, · line 676
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +2
-2- new_mem->mem_type == TTM_PL_TT)) { -/* bind is enough */ +if (old_mem->mem_type ==TTM_PL_SYSTEM && + new_mem->mem_type ==TTM_PL_TT ) {ttm_bo_move_null (bo, new_mem);I would feel better if we nuke
ttm_bo_move_null()and always usettm_bo_move_ttm().Any reason? The code path in the current move code pretty much is this.
The current move paths are
if (
new_tt&&old_tt)
if old is system
move null
else
move ttm
else
call driver move.
Quoted 4 lines
So I wanted to maintain that order. calling the move ttm will just make a pointless caching, populate, bind step.
But I'm going to think about it a bit more.
I've looked into moving the code over to move_ttm to see if I could combine things better, but it doesn't really fall out that nicely.
I might try again on top of the refactoring once I'm gone further.
Dave.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Christian König
maintainerRe: [PATCH 07/10] drm/amdgpu/ttm: handle tt moves properly.
In reply to Dave AirlieAm 24.09.20 um 02:46 schrieb Dave Airlie:
Quoted 49 lines · Christian König
Quoted 27 lines
Am 23.09.20 um 05:04 schrieb Dave Airlie:
Quoted 26 lines
From: Dave Airlie <[email protected]>
The core move code currently handles
use_ttmoves, for amdgpu this was being handled also in the driver, but not using the same paths.If moving between TT/SYSTEM (all the
use_ttpaths on amdgpu) use the core move function.Eventually the core will be flipped over to calling the driver.
Signed-off-by Dave Airlie <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0
-2@@ -671,14 +671,16 @@ static int amdgpu_bo_move(struct ttm_buffer_object *bo, bool evict,ttm_bo_move_null (bo, new_mem);return 0 ; } - if ((old_mem->mem_type == TTM_PL_TT && - new_mem->mem_type == TTM_PL_SYSTEM) ||Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static int amdgpu_bo_move(struct ttm_buffer_object *bo, bool evict, · line 676
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +2
-3- (old_mem->mem_type == TTM_PL_SYSTEM && - new_mem->mem_type == TTM_PL_TT)) { -/* bind is enough */ +if (old_mem->mem_type ==TTM_PL_SYSTEM && + new_mem->mem_type ==TTM_PL_TT ) {ttm_bo_move_null (bo, new_mem);I would feel better if we nuke
ttm_bo_move_null()and always usettm_bo_move_ttm().Any reason? The code path in the current move code pretty much is this.
The current move paths are
if (
new_tt&&old_tt)
if old is system
move null
else
move ttm
else
call driver move.
Quoted 2 lines
So I wanted to maintain that order. calling the move ttm will just make a pointless caching, populate, bind step.
Well we want to get rid of the bind/unbind stuff in TTM.
And I'm seriously thinking about getting rid of all the caching stuff.
So all of this should just go away rather soon.
Christian.
Quoted 4 lines
But I'm going to think about it a bit more.
Dave.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerPATCH 8/10 drm/radeon/ttm: handle ttm moves properly
In reply to Dave AirlieFrom: Dave Airlie <[email protected]>
The core move code currently handles use_tt moves, for radeon this was being handled also in the driver, but not using the same paths.
If moving between TT/SYSTEM (all the use_tt paths on radeon) use the core move function.
Eventually the core will be flipped over to calling the driver.
--- drivers/gpu/drm/radeon/radeon_ttm.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/gpu/drm/radeon/radeon_ttm.c +7 -5
@@ -316,14 +316,16 @@ static int radeon_bo_move(struct ttm_buffer_object *bo, bool evict,ttm_bo_move_null (bo, new_mem);return 0 ; } -if ((old_mem->mem_type ==TTM_PL_TT && - new_mem->mem_type ==TTM_PL_SYSTEM ) || - (old_mem->mem_type ==TTM_PL_SYSTEM && - new_mem->mem_type ==TTM_PL_TT )) { -/* bind is enough */ +if (old_mem->mem_type ==TTM_PL_SYSTEM && + new_mem->mem_type ==TTM_PL_TT ) {ttm_bo_move_null (bo, new_mem);return 0 ; } + +if (old_mem->mem_type ==TTM_PL_TT && + new_mem->mem_type ==TTM_PL_SYSTEM ) +return ttm_bo_move_ttm (bo, ctx, new_mem); +if (!rdev->ring[radeon_copy_ring_index (rdev)].ready || rdev->asic->copy.copy ==NULL ) {/* use memcpy */
Signature · 6 lines
2.27.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerPATCH 9/10 drm/nouveau/ttm: handle ttm moves properly.
In reply to Dave AirlieFrom: Dave Airlie <[email protected]>
The idea is to flip the core over to calling the driver always, so add support for moves here.
--- drivers/gpu/drm/nouveau/nouveau_bo.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/gpu/drm/nouveau/nouveau_bo.c +12 -0
@@ -1057,6 +1057,18 @@ nouveau_bo_move(struct ttm_buffer_object *bo, bool evict, goto out; } +if (old_reg->mem_type ==TTM_PL_SYSTEM && + new_reg->mem_type ==TTM_PL_TT ) { +ttm_bo_move_null (bo, new_reg); + goto out; + } + +if (old_reg->mem_type ==TTM_PL_TT && + new_reg->mem_type ==TTM_PL_SYSTEM ) { + ret =ttm_bo_move_ttm (bo, ctx, new_reg); + goto out; + } +/* Hardware assisted copy. */ if (drm->ttm.move) {if (new_reg->mem_type ==TTM_PL_SYSTEM )
Signature · 6 lines
2.27.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerPATCH 10/10 drm/ttm: reverse move calling pattern.
In reply to Dave AirlieFrom: Dave Airlie <[email protected]>
Call the driver move function if it exists, otherwise use the fallback ttm/memcpy paths.
--- drivers/gpu/drm/ttm/ttm_bo.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-)
drivers/gpu/drm/ttm/ttm_bo.c +19 -9
@@ -229,6 +229,23 @@ void ttm_bo_bulk_move_lru_tail(struct ttm_lru_bulk_move *bulk) }EXPORT_SYMBOL (ttm_bo_bulk_move_lru_tail); +static int ttm_bo_move_fallback (struct ttm_buffer_object *bo, +struct ttm_operation_ctx *ctx, +struct ttm_resource *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, 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, mem); +return 0 ; + }else +return ttm_bo_move_ttm (bo, ctx, mem); + }else +return ttm_bo_move_memcpy (bo, ctx, mem); +} +static int ttm_bo_handle_move_mem (struct ttm_buffer_object *bo,struct ttm_resource *mem,bool evict,struct ttm_operation_ctx *ctx)
@@ -270,17 +287,10 @@ 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) +if (bdev->driver->move) ret = bdev->driver->move (bo, evict, ctx, mem);else - ret =ttm_bo_move_memcpy (bo, ctx, mem); + ret =ttm_bo_move_fallback (bo, ctx, mem);if (ret) {if (bdev->driver->move_notify) {
Signature · 6 lines
2.27.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Christian König
maintainerRe: [PATCH 10/10] drm/ttm: reverse move calling pattern.
Am 23.09.20 um 05:04 schrieb Dave Airlie:
Quoted 4 lines
From: Dave Airlie <[email protected]>
Call the driver move function if it exists, otherwise use the fallback ttm/memcpy paths.
I would rather like to see the move callback made mandatory instead.
Christian.
Quoted 44 lines
Signed-off-by Dave Airlie <[email protected]>--- drivers/gpu/drm/ttm/ttm_bo.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-)drivers/gpu/drm/ttm/ttm_bo.c +17
-6@@ -229,6 +229,23 @@ void ttm_bo_bulk_move_lru_tail(struct ttm_lru_bulk_move *bulk) }EXPORT_SYMBOL (ttm_bo_bulk_move_lru_tail); +static int ttm_bo_move_fallback (struct ttm_buffer_object *bo, +struct ttm_operation_ctx *ctx, +struct ttm_resource *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, 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, mem); +return 0 ; + }else +return ttm_bo_move_ttm (bo, ctx, mem); + }else +return ttm_bo_move_memcpy (bo, ctx, mem); +} +static int ttm_bo_handle_move_mem (struct ttm_buffer_object *bo,struct ttm_resource *mem,bool evict,struct ttm_operation_ctx *ctx)@@ -270,17 +287,10 @@ 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);
drivers/gpu/drm/ttm/ttm_bo.c static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo, · line 296
Quoted 10 lines
drivers/gpu/drm/ttm/ttm_bo.c +2
-3- } -else if (bdev->driver->move) +if (bdev->driver->move) ret = bdev->driver->move (bo, evict, ctx, mem);else - ret =ttm_bo_move_memcpy (bo, ctx, mem); + ret =ttm_bo_move_fallback (bo, ctx, mem);if (ret) {if (bdev->driver->move_notify) {
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerRe: [PATCH 10/10] drm/ttm: reverse move calling pattern.
Quoted 8 lines · Christian König
Am 23.09.20 um 05:04 schrieb Dave Airlie:
Quoted 4 lines
From: Dave Airlie <[email protected]>
Call the driver move function if it exists, otherwise use the fallback ttm/memcpy paths.
I would rather like to see the move callback made mandatory instead.
Indeed this makes some stuff just easier to deal with.
Dave.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel