* [PATCH 1/7] drm/ttm: move some move binds into the drivers
2020-10-20 1:03 [PATCH 0/7] drm/ttm: get rid of bind/unbind Dave Airlie
@ 2020-10-20 1:03 ` Dave Airlie
2020-10-20 10:20 ` Christian König
2020-10-20 1:03 ` [PATCH 2/7] drm/ttm: minor cleanup to move to system Dave Airlie
` (5 subsequent siblings)
6 siblings, 1 reply; 15+ messages in thread
From: Dave Airlie @ 2020-10-20 1:03 UTC (permalink / raw)
To: dri-devel; +Cc: christian.koenig
From: Dave Airlie <airlied@redhat.com>
This just gives the driver control over some of the bind paths.
Signed-off-by: Dave Airlie <airlied@redhat.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 7 ++++++-
drivers/gpu/drm/nouveau/nouveau_bo.c | 10 +++++++---
drivers/gpu/drm/radeon/radeon_ttm.c | 11 ++++++++---
drivers/gpu/drm/ttm/ttm_bo_util.c | 1 -
4 files changed, 21 insertions(+), 8 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index 91b20aa2294d..4af4891264e1 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -605,10 +605,15 @@ static int amdgpu_move_ram_vram(struct ttm_buffer_object *bo, bool evict,
}
/* move/bind old memory to GTT space */
- r = ttm_bo_move_to_new_tt_mem(bo, ctx, &tmp_mem);
+ r = ttm_tt_populate(bo->bdev, bo->ttm, ctx);
+ if (unlikely(r))
+ return r;
+
+ r = amdgpu_ttm_backend_bind(bo->bdev, bo->ttm, &tmp_mem);
if (unlikely(r)) {
goto out_cleanup;
}
+
ttm_bo_assign_mem(bo, &tmp_mem);
/* copy to VRAM */
r = amdgpu_move_blit(bo, evict, new_mem, old_mem);
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
index fec7a901865e..7e604340b780 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -931,9 +931,13 @@ nouveau_bo_move_flips(struct ttm_buffer_object *bo, bool evict,
if (ret)
return ret;
- ret = ttm_bo_move_to_new_tt_mem(bo, ctx, &tmp_reg);
- if (ret)
- goto out;
+ ret = ttm_tt_populate(bo->bdev, bo->ttm, ctx);
+ if (unlikely(ret != 0))
+ return ret;
+
+ ret = nouveau_ttm_tt_bind(bo->bdev, bo->ttm, &tmp_reg);
+ if (unlikely(ret != 0))
+ return ret;
ttm_bo_assign_mem(bo, &tmp_reg);
ret = nouveau_bo_move_m2mf(bo, true, ctx, new_reg);
diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
index ec713f0e55e5..24ef25665249 100644
--- a/drivers/gpu/drm/radeon/radeon_ttm.c
+++ b/drivers/gpu/drm/radeon/radeon_ttm.c
@@ -279,10 +279,15 @@ static int radeon_move_ram_vram(struct ttm_buffer_object *bo,
if (unlikely(r)) {
return r;
}
- r = ttm_bo_move_to_new_tt_mem(bo, ctx, &tmp_mem);
- if (unlikely(r)) {
+
+ r = ttm_tt_populate(bo->bdev, bo->ttm, ctx);
+ if (unlikely(r))
goto out_cleanup;
- }
+
+ r = radeon_ttm_tt_bind(bo->bdev, bo->ttm, &tmp_mem);
+ if (unlikely(r))
+ goto out_cleanup;
+
ttm_bo_assign_mem(bo, &tmp_mem);
r = radeon_move_blit(bo, true, new_mem, old_mem);
if (unlikely(r)) {
diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c
index e4bd381a8962..c8ca6694cc1c 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_util.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
@@ -64,7 +64,6 @@ int ttm_bo_move_to_new_tt_mem(struct ttm_buffer_object *bo,
return 0;
}
-EXPORT_SYMBOL(ttm_bo_move_to_new_tt_mem);
int ttm_bo_move_to_system(struct ttm_buffer_object *bo,
struct ttm_operation_ctx *ctx)
--
2.27.0
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [PATCH 1/7] drm/ttm: move some move binds into the drivers
2020-10-20 1:03 ` [PATCH 1/7] drm/ttm: move some move binds into the drivers Dave Airlie
@ 2020-10-20 10:20 ` Christian König
0 siblings, 0 replies; 15+ messages in thread
From: Christian König @ 2020-10-20 10:20 UTC (permalink / raw)
To: Dave Airlie, dri-devel
Am 20.10.20 um 03:03 schrieb Dave Airlie:
> From: Dave Airlie <airlied@redhat.com>
>
> This just gives the driver control over some of the bind paths.
>
> Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 7 ++++++-
> drivers/gpu/drm/nouveau/nouveau_bo.c | 10 +++++++---
> drivers/gpu/drm/radeon/radeon_ttm.c | 11 ++++++++---
> drivers/gpu/drm/ttm/ttm_bo_util.c | 1 -
> 4 files changed, 21 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> index 91b20aa2294d..4af4891264e1 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> @@ -605,10 +605,15 @@ static int amdgpu_move_ram_vram(struct ttm_buffer_object *bo, bool evict,
> }
>
> /* move/bind old memory to GTT space */
> - r = ttm_bo_move_to_new_tt_mem(bo, ctx, &tmp_mem);
> + r = ttm_tt_populate(bo->bdev, bo->ttm, ctx);
> + if (unlikely(r))
> + return r;
> +
> + r = amdgpu_ttm_backend_bind(bo->bdev, bo->ttm, &tmp_mem);
> if (unlikely(r)) {
> goto out_cleanup;
> }
> +
> ttm_bo_assign_mem(bo, &tmp_mem);
> /* copy to VRAM */
> r = amdgpu_move_blit(bo, evict, new_mem, old_mem);
> diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
> index fec7a901865e..7e604340b780 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_bo.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
> @@ -931,9 +931,13 @@ nouveau_bo_move_flips(struct ttm_buffer_object *bo, bool evict,
> if (ret)
> return ret;
>
> - ret = ttm_bo_move_to_new_tt_mem(bo, ctx, &tmp_reg);
> - if (ret)
> - goto out;
> + ret = ttm_tt_populate(bo->bdev, bo->ttm, ctx);
> + if (unlikely(ret != 0))
> + return ret;
> +
> + ret = nouveau_ttm_tt_bind(bo->bdev, bo->ttm, &tmp_reg);
> + if (unlikely(ret != 0))
> + return ret;
>
> ttm_bo_assign_mem(bo, &tmp_reg);
> ret = nouveau_bo_move_m2mf(bo, true, ctx, new_reg);
> diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
> index ec713f0e55e5..24ef25665249 100644
> --- a/drivers/gpu/drm/radeon/radeon_ttm.c
> +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
> @@ -279,10 +279,15 @@ static int radeon_move_ram_vram(struct ttm_buffer_object *bo,
> if (unlikely(r)) {
> return r;
> }
> - r = ttm_bo_move_to_new_tt_mem(bo, ctx, &tmp_mem);
> - if (unlikely(r)) {
> +
> + r = ttm_tt_populate(bo->bdev, bo->ttm, ctx);
> + if (unlikely(r))
> goto out_cleanup;
> - }
> +
> + r = radeon_ttm_tt_bind(bo->bdev, bo->ttm, &tmp_mem);
> + if (unlikely(r))
> + goto out_cleanup;
> +
> ttm_bo_assign_mem(bo, &tmp_mem);
> r = radeon_move_blit(bo, true, new_mem, old_mem);
> if (unlikely(r)) {
> diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c
> index e4bd381a8962..c8ca6694cc1c 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo_util.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
> @@ -64,7 +64,6 @@ int ttm_bo_move_to_new_tt_mem(struct ttm_buffer_object *bo,
>
> return 0;
> }
> -EXPORT_SYMBOL(ttm_bo_move_to_new_tt_mem);
>
> int ttm_bo_move_to_system(struct ttm_buffer_object *bo,
> struct ttm_operation_ctx *ctx)
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 2/7] drm/ttm: minor cleanup to move to system
2020-10-20 1:03 [PATCH 0/7] drm/ttm: get rid of bind/unbind Dave Airlie
2020-10-20 1:03 ` [PATCH 1/7] drm/ttm: move some move binds into the drivers Dave Airlie
@ 2020-10-20 1:03 ` Dave Airlie
2020-10-20 10:22 ` Christian König
2020-10-20 1:03 ` [PATCH 3/7] drm/ttm: add move to system into drivers Dave Airlie
` (4 subsequent siblings)
6 siblings, 1 reply; 15+ messages in thread
From: Dave Airlie @ 2020-10-20 1:03 UTC (permalink / raw)
To: dri-devel; +Cc: christian.koenig
From: Dave Airlie <airlied@redhat.com>
resource free already sets the domain to system, and old_mem
isn't really needed.
Signed-off-by: Dave Airlie <airlied@redhat.com>
---
drivers/gpu/drm/ttm/ttm_bo_util.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c
index c8ca6694cc1c..b730e624a220 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_util.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
@@ -68,10 +68,9 @@ int ttm_bo_move_to_new_tt_mem(struct ttm_buffer_object *bo,
int ttm_bo_move_to_system(struct ttm_buffer_object *bo,
struct ttm_operation_ctx *ctx)
{
- struct ttm_resource *old_mem = &bo->mem;
int ret;
- if (old_mem->mem_type == TTM_PL_SYSTEM)
+ if (bo->mem.mem_type == TTM_PL_SYSTEM)
return 0;
ret = ttm_bo_wait_ctx(bo, ctx);
@@ -83,7 +82,6 @@ int ttm_bo_move_to_system(struct ttm_buffer_object *bo,
ttm_bo_tt_unbind(bo);
ttm_resource_free(bo, &bo->mem);
- old_mem->mem_type = TTM_PL_SYSTEM;
return 0;
}
EXPORT_SYMBOL(ttm_bo_move_to_system);
--
2.27.0
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [PATCH 2/7] drm/ttm: minor cleanup to move to system
2020-10-20 1:03 ` [PATCH 2/7] drm/ttm: minor cleanup to move to system Dave Airlie
@ 2020-10-20 10:22 ` Christian König
0 siblings, 0 replies; 15+ messages in thread
From: Christian König @ 2020-10-20 10:22 UTC (permalink / raw)
To: Dave Airlie, dri-devel
Am 20.10.20 um 03:03 schrieb Dave Airlie:
> From: Dave Airlie <airlied@redhat.com>
>
> resource free already sets the domain to system, and old_mem
> isn't really needed.
>
> Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
> ---
> drivers/gpu/drm/ttm/ttm_bo_util.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c
> index c8ca6694cc1c..b730e624a220 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo_util.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
> @@ -68,10 +68,9 @@ int ttm_bo_move_to_new_tt_mem(struct ttm_buffer_object *bo,
> int ttm_bo_move_to_system(struct ttm_buffer_object *bo,
> struct ttm_operation_ctx *ctx)
> {
> - struct ttm_resource *old_mem = &bo->mem;
> int ret;
>
> - if (old_mem->mem_type == TTM_PL_SYSTEM)
> + if (bo->mem.mem_type == TTM_PL_SYSTEM)
> return 0;
>
> ret = ttm_bo_wait_ctx(bo, ctx);
> @@ -83,7 +82,6 @@ int ttm_bo_move_to_system(struct ttm_buffer_object *bo,
>
> ttm_bo_tt_unbind(bo);
> ttm_resource_free(bo, &bo->mem);
> - old_mem->mem_type = TTM_PL_SYSTEM;
> return 0;
> }
> EXPORT_SYMBOL(ttm_bo_move_to_system);
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 3/7] drm/ttm: add move to system into drivers
2020-10-20 1:03 [PATCH 0/7] drm/ttm: get rid of bind/unbind Dave Airlie
2020-10-20 1:03 ` [PATCH 1/7] drm/ttm: move some move binds into the drivers Dave Airlie
2020-10-20 1:03 ` [PATCH 2/7] drm/ttm: minor cleanup to move to system Dave Airlie
@ 2020-10-20 1:03 ` Dave Airlie
2020-10-20 12:03 ` Christian König
2020-10-20 1:03 ` [PATCH 4/7] drm/ttm: drop unbind callback Dave Airlie
` (3 subsequent siblings)
6 siblings, 1 reply; 15+ messages in thread
From: Dave Airlie @ 2020-10-20 1:03 UTC (permalink / raw)
To: dri-devel; +Cc: christian.koenig
From: Dave Airlie <airlied@redhat.com>
This moves the to system move into the drivers, and moves all
the unbinds in the move path under driver control
Note: radeon/nouveau already wait so don't duplicate it.
Signed-off-by: Dave Airlie <airlied@redhat.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 12 +++++++++---
drivers/gpu/drm/nouveau/nouveau_bo.c | 10 ++++++----
drivers/gpu/drm/radeon/radeon_ttm.c | 12 +++++++-----
drivers/gpu/drm/ttm/ttm_bo_util.c | 21 ---------------------
drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c | 5 ++++-
include/drm/ttm/ttm_bo_driver.h | 2 --
6 files changed, 26 insertions(+), 36 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index 4af4891264e1..fcec99aea019 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -66,6 +66,8 @@
static int amdgpu_ttm_backend_bind(struct ttm_bo_device *bdev,
struct ttm_tt *ttm,
struct ttm_resource *bo_mem);
+static void amdgpu_ttm_backend_unbind(struct ttm_bo_device *bdev,
+ struct ttm_tt *ttm);
static int amdgpu_ttm_init_on_chip(struct amdgpu_device *adev,
unsigned int type,
@@ -561,11 +563,12 @@ static int amdgpu_move_vram_ram(struct ttm_buffer_object *bo, bool evict,
goto out_cleanup;
}
- /* move BO (in tmp_mem) to new_mem */
- r = ttm_bo_move_to_system(bo, ctx);
+ r = ttm_bo_wait_ctx(bo, ctx);
if (unlikely(r))
goto out_cleanup;
+ amdgpu_ttm_backend_unbind(bo->bdev, bo->ttm);
+ ttm_resource_free(bo, &bo->mem);
ttm_bo_assign_mem(bo, new_mem);
out_cleanup:
ttm_resource_free(bo, &tmp_mem);
@@ -682,9 +685,12 @@ static int amdgpu_bo_move(struct ttm_buffer_object *bo, bool evict,
if (old_mem->mem_type == TTM_PL_TT &&
new_mem->mem_type == TTM_PL_SYSTEM) {
- r = ttm_bo_move_to_system(bo, ctx);
+ r = ttm_bo_wait_ctx(bo, ctx);
if (r)
return r;
+
+ amdgpu_ttm_backend_unbind(bo->bdev, bo->ttm);
+ ttm_resource_free(bo, &bo->mem);
ttm_bo_assign_mem(bo, new_mem);
return 0;
}
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
index 7e604340b780..c58c8951f72f 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -46,6 +46,7 @@
static int nouveau_ttm_tt_bind(struct ttm_bo_device *bdev, struct ttm_tt *ttm,
struct ttm_resource *reg);
+static void nouveau_ttm_tt_unbind(struct ttm_bo_device *bdev, struct ttm_tt *ttm);
/*
* NV10-NV40 tiling helpers
@@ -897,10 +898,12 @@ nouveau_bo_move_flipd(struct ttm_buffer_object *bo, bool evict,
if (ret)
goto out;
- ret = ttm_bo_move_to_system(bo, ctx);
+ ret = ttm_bo_wait_ctx(bo, ctx);
if (ret)
goto out;
+ nouveau_ttm_tt_unbind(bo->bdev, bo->ttm);
+ ttm_resource_free(bo, &bo->mem);
ttm_bo_assign_mem(bo, &tmp_reg);
out:
ttm_resource_free(bo, &tmp_reg);
@@ -1056,9 +1059,8 @@ nouveau_bo_move(struct ttm_buffer_object *bo, bool evict,
if (old_reg->mem_type == TTM_PL_TT &&
new_reg->mem_type == TTM_PL_SYSTEM) {
- ret = ttm_bo_move_to_system(bo, ctx);
- if (ret)
- return ret;
+ nouveau_ttm_tt_unbind(bo->bdev, bo->ttm);
+ ttm_resource_free(bo, &bo->mem);
ttm_bo_assign_mem(bo, new_reg);
goto out;
}
diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
index 24ef25665249..d3d39823b69f 100644
--- a/drivers/gpu/drm/radeon/radeon_ttm.c
+++ b/drivers/gpu/drm/radeon/radeon_ttm.c
@@ -59,6 +59,8 @@ static void radeon_ttm_debugfs_fini(struct radeon_device *rdev);
static int radeon_ttm_tt_bind(struct ttm_bo_device *bdev,
struct ttm_tt *ttm,
struct ttm_resource *bo_mem);
+static void radeon_ttm_tt_unbind(struct ttm_bo_device *bdev,
+ struct ttm_tt *ttm);
struct radeon_device *radeon_get_rdev(struct ttm_bo_device *bdev)
{
@@ -244,10 +246,12 @@ static int radeon_move_vram_ram(struct ttm_buffer_object *bo,
if (unlikely(r)) {
goto out_cleanup;
}
- r = ttm_bo_move_to_system(bo, ctx);
+ r = ttm_bo_wait_ctx(bo, ctx);
if (unlikely(r))
goto out_cleanup;
+ radeon_ttm_tt_unbind(bo->bdev, bo->ttm);
+ ttm_resource_free(bo, &bo->mem);
ttm_bo_assign_mem(bo, new_mem);
out_cleanup:
ttm_resource_free(bo, &tmp_mem);
@@ -329,10 +333,8 @@ static int radeon_bo_move(struct ttm_buffer_object *bo, bool evict,
if (old_mem->mem_type == TTM_PL_TT &&
new_mem->mem_type == TTM_PL_SYSTEM) {
- r = ttm_bo_move_to_system(bo, ctx);
- if (r)
- return r;
-
+ radeon_ttm_tt_unbind(bo->bdev, bo->ttm);
+ ttm_resource_free(bo, &bo->mem);
ttm_bo_assign_mem(bo, new_mem);
return 0;
}
diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c
index b730e624a220..21811bbda2e4 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_util.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
@@ -65,27 +65,6 @@ int ttm_bo_move_to_new_tt_mem(struct ttm_buffer_object *bo,
return 0;
}
-int ttm_bo_move_to_system(struct ttm_buffer_object *bo,
- struct ttm_operation_ctx *ctx)
-{
- int ret;
-
- if (bo->mem.mem_type == TTM_PL_SYSTEM)
- return 0;
-
- ret = ttm_bo_wait_ctx(bo, ctx);
- if (unlikely(ret != 0)) {
- if (ret != -ERESTARTSYS)
- pr_err("Failed to expire sync object before unbinding TTM\n");
- return ret;
- }
-
- ttm_bo_tt_unbind(bo);
- ttm_resource_free(bo, &bo->mem);
- return 0;
-}
-EXPORT_SYMBOL(ttm_bo_move_to_system);
-
int ttm_mem_io_reserve(struct ttm_bo_device *bdev,
struct ttm_resource *mem)
{
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
index c5cf81c09971..1d220a9794e6 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
@@ -742,9 +742,12 @@ static int vmw_move(struct ttm_buffer_object *bo,
ttm_bo_assign_mem(bo, new_mem);
return 0;
}
- ret = ttm_bo_move_to_system(bo, ctx);
+ ret = ttm_bo_wait_ctx(bo, ctx);
if (ret)
return ret;
+
+ vmw_ttm_unbind(bo->bdev, bo->ttm);
+ ttm_resource_free(bo, &bo->mem);
ttm_bo_assign_mem(bo, new_mem);
return 0;
} else {
diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
index a89728cb9a23..81a1618b9535 100644
--- a/include/drm/ttm/ttm_bo_driver.h
+++ b/include/drm/ttm/ttm_bo_driver.h
@@ -574,8 +574,6 @@ void ttm_mem_io_free(struct ttm_bo_device *bdev,
int ttm_bo_move_to_new_tt_mem(struct ttm_buffer_object *bo,
struct ttm_operation_ctx *ctx,
struct ttm_resource *new_mem);
-int ttm_bo_move_to_system(struct ttm_buffer_object *bo,
- struct ttm_operation_ctx *ctx);
/**
* ttm_bo_move_memcpy
--
2.27.0
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [PATCH 3/7] drm/ttm: add move to system into drivers
2020-10-20 1:03 ` [PATCH 3/7] drm/ttm: add move to system into drivers Dave Airlie
@ 2020-10-20 12:03 ` Christian König
0 siblings, 0 replies; 15+ messages in thread
From: Christian König @ 2020-10-20 12:03 UTC (permalink / raw)
To: Dave Airlie, dri-devel
Am 20.10.20 um 03:03 schrieb Dave Airlie:
> From: Dave Airlie <airlied@redhat.com>
>
> This moves the to system move into the drivers, and moves all
> the unbinds in the move path under driver control
>
> Note: radeon/nouveau already wait so don't duplicate it.
>
> Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 12 +++++++++---
> drivers/gpu/drm/nouveau/nouveau_bo.c | 10 ++++++----
> drivers/gpu/drm/radeon/radeon_ttm.c | 12 +++++++-----
> drivers/gpu/drm/ttm/ttm_bo_util.c | 21 ---------------------
> drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c | 5 ++++-
> include/drm/ttm/ttm_bo_driver.h | 2 --
> 6 files changed, 26 insertions(+), 36 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> index 4af4891264e1..fcec99aea019 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> @@ -66,6 +66,8 @@
> static int amdgpu_ttm_backend_bind(struct ttm_bo_device *bdev,
> struct ttm_tt *ttm,
> struct ttm_resource *bo_mem);
> +static void amdgpu_ttm_backend_unbind(struct ttm_bo_device *bdev,
> + struct ttm_tt *ttm);
>
> static int amdgpu_ttm_init_on_chip(struct amdgpu_device *adev,
> unsigned int type,
> @@ -561,11 +563,12 @@ static int amdgpu_move_vram_ram(struct ttm_buffer_object *bo, bool evict,
> goto out_cleanup;
> }
>
> - /* move BO (in tmp_mem) to new_mem */
> - r = ttm_bo_move_to_system(bo, ctx);
> + r = ttm_bo_wait_ctx(bo, ctx);
> if (unlikely(r))
> goto out_cleanup;
>
> + amdgpu_ttm_backend_unbind(bo->bdev, bo->ttm);
> + ttm_resource_free(bo, &bo->mem);
> ttm_bo_assign_mem(bo, new_mem);
> out_cleanup:
> ttm_resource_free(bo, &tmp_mem);
> @@ -682,9 +685,12 @@ static int amdgpu_bo_move(struct ttm_buffer_object *bo, bool evict,
>
> if (old_mem->mem_type == TTM_PL_TT &&
> new_mem->mem_type == TTM_PL_SYSTEM) {
> - r = ttm_bo_move_to_system(bo, ctx);
> + r = ttm_bo_wait_ctx(bo, ctx);
> if (r)
> return r;
> +
> + amdgpu_ttm_backend_unbind(bo->bdev, bo->ttm);
> + ttm_resource_free(bo, &bo->mem);
> ttm_bo_assign_mem(bo, new_mem);
> return 0;
> }
> diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
> index 7e604340b780..c58c8951f72f 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_bo.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
> @@ -46,6 +46,7 @@
>
> static int nouveau_ttm_tt_bind(struct ttm_bo_device *bdev, struct ttm_tt *ttm,
> struct ttm_resource *reg);
> +static void nouveau_ttm_tt_unbind(struct ttm_bo_device *bdev, struct ttm_tt *ttm);
>
> /*
> * NV10-NV40 tiling helpers
> @@ -897,10 +898,12 @@ nouveau_bo_move_flipd(struct ttm_buffer_object *bo, bool evict,
> if (ret)
> goto out;
>
> - ret = ttm_bo_move_to_system(bo, ctx);
> + ret = ttm_bo_wait_ctx(bo, ctx);
> if (ret)
> goto out;
>
> + nouveau_ttm_tt_unbind(bo->bdev, bo->ttm);
> + ttm_resource_free(bo, &bo->mem);
> ttm_bo_assign_mem(bo, &tmp_reg);
> out:
> ttm_resource_free(bo, &tmp_reg);
> @@ -1056,9 +1059,8 @@ nouveau_bo_move(struct ttm_buffer_object *bo, bool evict,
>
> if (old_reg->mem_type == TTM_PL_TT &&
> new_reg->mem_type == TTM_PL_SYSTEM) {
> - ret = ttm_bo_move_to_system(bo, ctx);
> - if (ret)
> - return ret;
> + nouveau_ttm_tt_unbind(bo->bdev, bo->ttm);
> + ttm_resource_free(bo, &bo->mem);
> ttm_bo_assign_mem(bo, new_reg);
> goto out;
> }
> diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
> index 24ef25665249..d3d39823b69f 100644
> --- a/drivers/gpu/drm/radeon/radeon_ttm.c
> +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
> @@ -59,6 +59,8 @@ static void radeon_ttm_debugfs_fini(struct radeon_device *rdev);
> static int radeon_ttm_tt_bind(struct ttm_bo_device *bdev,
> struct ttm_tt *ttm,
> struct ttm_resource *bo_mem);
> +static void radeon_ttm_tt_unbind(struct ttm_bo_device *bdev,
> + struct ttm_tt *ttm);
>
> struct radeon_device *radeon_get_rdev(struct ttm_bo_device *bdev)
> {
> @@ -244,10 +246,12 @@ static int radeon_move_vram_ram(struct ttm_buffer_object *bo,
> if (unlikely(r)) {
> goto out_cleanup;
> }
> - r = ttm_bo_move_to_system(bo, ctx);
> + r = ttm_bo_wait_ctx(bo, ctx);
> if (unlikely(r))
> goto out_cleanup;
>
> + radeon_ttm_tt_unbind(bo->bdev, bo->ttm);
> + ttm_resource_free(bo, &bo->mem);
> ttm_bo_assign_mem(bo, new_mem);
> out_cleanup:
> ttm_resource_free(bo, &tmp_mem);
> @@ -329,10 +333,8 @@ static int radeon_bo_move(struct ttm_buffer_object *bo, bool evict,
>
> if (old_mem->mem_type == TTM_PL_TT &&
> new_mem->mem_type == TTM_PL_SYSTEM) {
> - r = ttm_bo_move_to_system(bo, ctx);
> - if (r)
> - return r;
> -
> + radeon_ttm_tt_unbind(bo->bdev, bo->ttm);
> + ttm_resource_free(bo, &bo->mem);
> ttm_bo_assign_mem(bo, new_mem);
> return 0;
> }
> diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c
> index b730e624a220..21811bbda2e4 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo_util.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
> @@ -65,27 +65,6 @@ int ttm_bo_move_to_new_tt_mem(struct ttm_buffer_object *bo,
> return 0;
> }
>
> -int ttm_bo_move_to_system(struct ttm_buffer_object *bo,
> - struct ttm_operation_ctx *ctx)
> -{
> - int ret;
> -
> - if (bo->mem.mem_type == TTM_PL_SYSTEM)
> - return 0;
> -
> - ret = ttm_bo_wait_ctx(bo, ctx);
> - if (unlikely(ret != 0)) {
> - if (ret != -ERESTARTSYS)
> - pr_err("Failed to expire sync object before unbinding TTM\n");
> - return ret;
> - }
> -
> - ttm_bo_tt_unbind(bo);
> - ttm_resource_free(bo, &bo->mem);
> - return 0;
> -}
> -EXPORT_SYMBOL(ttm_bo_move_to_system);
> -
> int ttm_mem_io_reserve(struct ttm_bo_device *bdev,
> struct ttm_resource *mem)
> {
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
> index c5cf81c09971..1d220a9794e6 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
> @@ -742,9 +742,12 @@ static int vmw_move(struct ttm_buffer_object *bo,
> ttm_bo_assign_mem(bo, new_mem);
> return 0;
> }
> - ret = ttm_bo_move_to_system(bo, ctx);
> + ret = ttm_bo_wait_ctx(bo, ctx);
> if (ret)
> return ret;
> +
> + vmw_ttm_unbind(bo->bdev, bo->ttm);
> + ttm_resource_free(bo, &bo->mem);
> ttm_bo_assign_mem(bo, new_mem);
> return 0;
> } else {
> diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
> index a89728cb9a23..81a1618b9535 100644
> --- a/include/drm/ttm/ttm_bo_driver.h
> +++ b/include/drm/ttm/ttm_bo_driver.h
> @@ -574,8 +574,6 @@ void ttm_mem_io_free(struct ttm_bo_device *bdev,
> int ttm_bo_move_to_new_tt_mem(struct ttm_buffer_object *bo,
> struct ttm_operation_ctx *ctx,
> struct ttm_resource *new_mem);
> -int ttm_bo_move_to_system(struct ttm_buffer_object *bo,
> - struct ttm_operation_ctx *ctx);
>
> /**
> * ttm_bo_move_memcpy
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 4/7] drm/ttm: drop unbind callback.
2020-10-20 1:03 [PATCH 0/7] drm/ttm: get rid of bind/unbind Dave Airlie
` (2 preceding siblings ...)
2020-10-20 1:03 ` [PATCH 3/7] drm/ttm: add move to system into drivers Dave Airlie
@ 2020-10-20 1:03 ` Dave Airlie
2020-10-20 12:04 ` Christian König
2020-10-20 1:03 ` [PATCH 5/7] drm/ttm: remove move to new and inline into remainging place Dave Airlie
` (2 subsequent siblings)
6 siblings, 1 reply; 15+ messages in thread
From: Dave Airlie @ 2020-10-20 1:03 UTC (permalink / raw)
To: dri-devel; +Cc: christian.koenig
From: Dave Airlie <airlied@redhat.com>
The drivers now control this, so drop unbinding.
Signed-off-by: Dave Airlie <airlied@redhat.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 1 -
drivers/gpu/drm/nouveau/nouveau_bo.c | 1 -
drivers/gpu/drm/qxl/qxl_ttm.c | 7 -------
drivers/gpu/drm/radeon/radeon_ttm.c | 1 -
drivers/gpu/drm/ttm/ttm_bo.c | 5 -----
drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c | 1 -
include/drm/ttm/ttm_bo_driver.h | 18 ------------------
7 files changed, 34 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index fcec99aea019..ac93a537f2e2 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -1722,7 +1722,6 @@ static struct ttm_bo_driver amdgpu_bo_driver = {
.ttm_tt_populate = &amdgpu_ttm_tt_populate,
.ttm_tt_unpopulate = &amdgpu_ttm_tt_unpopulate,
.ttm_tt_bind = &amdgpu_ttm_backend_bind,
- .ttm_tt_unbind = &amdgpu_ttm_backend_unbind,
.ttm_tt_destroy = &amdgpu_ttm_backend_destroy,
.eviction_valuable = amdgpu_ttm_bo_eviction_valuable,
.evict_flags = &amdgpu_evict_flags,
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
index c58c8951f72f..7fb65b87f815 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -1394,7 +1394,6 @@ struct ttm_bo_driver nouveau_bo_driver = {
.ttm_tt_populate = &nouveau_ttm_tt_populate,
.ttm_tt_unpopulate = &nouveau_ttm_tt_unpopulate,
.ttm_tt_bind = &nouveau_ttm_tt_bind,
- .ttm_tt_unbind = &nouveau_ttm_tt_unbind,
.ttm_tt_destroy = &nouveau_ttm_tt_destroy,
.eviction_valuable = ttm_bo_eviction_valuable,
.evict_flags = nouveau_bo_evict_flags,
diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
index e3ed20215f18..95c4f2c7ab79 100644
--- a/drivers/gpu/drm/qxl/qxl_ttm.c
+++ b/drivers/gpu/drm/qxl/qxl_ttm.c
@@ -113,12 +113,6 @@ static int qxl_ttm_backend_bind(struct ttm_bo_device *bdev,
return -1;
}
-static void qxl_ttm_backend_unbind(struct ttm_bo_device *bdev,
- struct ttm_tt *ttm)
-{
- /* Not implemented */
-}
-
static void qxl_ttm_backend_destroy(struct ttm_bo_device *bdev,
struct ttm_tt *ttm)
{
@@ -180,7 +174,6 @@ static struct ttm_bo_driver qxl_bo_driver = {
.ttm_tt_create = &qxl_ttm_tt_create,
.ttm_tt_bind = &qxl_ttm_backend_bind,
.ttm_tt_destroy = &qxl_ttm_backend_destroy,
- .ttm_tt_unbind = &qxl_ttm_backend_unbind,
.eviction_valuable = ttm_bo_eviction_valuable,
.evict_flags = &qxl_evict_flags,
.move = &qxl_bo_move,
diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
index d3d39823b69f..7fe4a98ece54 100644
--- a/drivers/gpu/drm/radeon/radeon_ttm.c
+++ b/drivers/gpu/drm/radeon/radeon_ttm.c
@@ -817,7 +817,6 @@ static struct ttm_bo_driver radeon_bo_driver = {
.ttm_tt_populate = &radeon_ttm_tt_populate,
.ttm_tt_unpopulate = &radeon_ttm_tt_unpopulate,
.ttm_tt_bind = &radeon_ttm_tt_bind,
- .ttm_tt_unbind = &radeon_ttm_tt_unbind,
.ttm_tt_destroy = &radeon_ttm_tt_destroy,
.eviction_valuable = ttm_bo_eviction_valuable,
.evict_flags = &radeon_evict_flags,
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 7602d7734d38..358d09ef852a 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -1493,8 +1493,3 @@ int ttm_bo_tt_bind(struct ttm_buffer_object *bo, struct ttm_resource *mem)
{
return bo->bdev->driver->ttm_tt_bind(bo->bdev, bo->ttm, mem);
}
-
-void ttm_bo_tt_unbind(struct ttm_buffer_object *bo)
-{
- bo->bdev->driver->ttm_tt_unbind(bo->bdev, bo->ttm);
-}
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
index 1d220a9794e6..6e07ea982961 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
@@ -760,7 +760,6 @@ struct ttm_bo_driver vmw_bo_driver = {
.ttm_tt_populate = &vmw_ttm_populate,
.ttm_tt_unpopulate = &vmw_ttm_unpopulate,
.ttm_tt_bind = &vmw_ttm_bind,
- .ttm_tt_unbind = &vmw_ttm_unbind,
.ttm_tt_destroy = &vmw_ttm_destroy,
.eviction_valuable = ttm_bo_eviction_valuable,
.evict_flags = vmw_evict_flags,
diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
index 81a1618b9535..fbbcf10670c1 100644
--- a/include/drm/ttm/ttm_bo_driver.h
+++ b/include/drm/ttm/ttm_bo_driver.h
@@ -104,17 +104,6 @@ struct ttm_bo_driver {
*/
int (*ttm_tt_bind)(struct ttm_bo_device *bdev, struct ttm_tt *ttm, struct ttm_resource *bo_mem);
- /**
- * ttm_tt_unbind
- *
- * @bdev: Pointer to a ttm device
- * @ttm: Pointer to a struct ttm_tt.
- *
- * Unbind previously bound backend pages. This function should be
- * able to handle differences between aperture and system page sizes.
- */
- void (*ttm_tt_unbind)(struct ttm_bo_device *bdev, struct ttm_tt *ttm);
-
/**
* ttm_tt_destroy
*
@@ -647,13 +636,6 @@ pgprot_t ttm_io_prot(struct ttm_buffer_object *bo, struct ttm_resource *res,
*/
int ttm_bo_tt_bind(struct ttm_buffer_object *bo, struct ttm_resource *mem);
-/**
- * ttm_bo_tt_bind
- *
- * Unbind the object tt from a memory resource.
- */
-void ttm_bo_tt_unbind(struct ttm_buffer_object *bo);
-
/**
* ttm_bo_tt_destroy.
*/
--
2.27.0
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [PATCH 4/7] drm/ttm: drop unbind callback.
2020-10-20 1:03 ` [PATCH 4/7] drm/ttm: drop unbind callback Dave Airlie
@ 2020-10-20 12:04 ` Christian König
0 siblings, 0 replies; 15+ messages in thread
From: Christian König @ 2020-10-20 12:04 UTC (permalink / raw)
To: Dave Airlie, dri-devel
Am 20.10.20 um 03:03 schrieb Dave Airlie:
> From: Dave Airlie <airlied@redhat.com>
>
> The drivers now control this, so drop unbinding.
>
> Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 1 -
> drivers/gpu/drm/nouveau/nouveau_bo.c | 1 -
> drivers/gpu/drm/qxl/qxl_ttm.c | 7 -------
> drivers/gpu/drm/radeon/radeon_ttm.c | 1 -
> drivers/gpu/drm/ttm/ttm_bo.c | 5 -----
> drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c | 1 -
> include/drm/ttm/ttm_bo_driver.h | 18 ------------------
> 7 files changed, 34 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> index fcec99aea019..ac93a537f2e2 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> @@ -1722,7 +1722,6 @@ static struct ttm_bo_driver amdgpu_bo_driver = {
> .ttm_tt_populate = &amdgpu_ttm_tt_populate,
> .ttm_tt_unpopulate = &amdgpu_ttm_tt_unpopulate,
> .ttm_tt_bind = &amdgpu_ttm_backend_bind,
> - .ttm_tt_unbind = &amdgpu_ttm_backend_unbind,
> .ttm_tt_destroy = &amdgpu_ttm_backend_destroy,
> .eviction_valuable = amdgpu_ttm_bo_eviction_valuable,
> .evict_flags = &amdgpu_evict_flags,
> diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
> index c58c8951f72f..7fb65b87f815 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_bo.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
> @@ -1394,7 +1394,6 @@ struct ttm_bo_driver nouveau_bo_driver = {
> .ttm_tt_populate = &nouveau_ttm_tt_populate,
> .ttm_tt_unpopulate = &nouveau_ttm_tt_unpopulate,
> .ttm_tt_bind = &nouveau_ttm_tt_bind,
> - .ttm_tt_unbind = &nouveau_ttm_tt_unbind,
> .ttm_tt_destroy = &nouveau_ttm_tt_destroy,
> .eviction_valuable = ttm_bo_eviction_valuable,
> .evict_flags = nouveau_bo_evict_flags,
> diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
> index e3ed20215f18..95c4f2c7ab79 100644
> --- a/drivers/gpu/drm/qxl/qxl_ttm.c
> +++ b/drivers/gpu/drm/qxl/qxl_ttm.c
> @@ -113,12 +113,6 @@ static int qxl_ttm_backend_bind(struct ttm_bo_device *bdev,
> return -1;
> }
>
> -static void qxl_ttm_backend_unbind(struct ttm_bo_device *bdev,
> - struct ttm_tt *ttm)
> -{
> - /* Not implemented */
> -}
> -
> static void qxl_ttm_backend_destroy(struct ttm_bo_device *bdev,
> struct ttm_tt *ttm)
> {
> @@ -180,7 +174,6 @@ static struct ttm_bo_driver qxl_bo_driver = {
> .ttm_tt_create = &qxl_ttm_tt_create,
> .ttm_tt_bind = &qxl_ttm_backend_bind,
> .ttm_tt_destroy = &qxl_ttm_backend_destroy,
> - .ttm_tt_unbind = &qxl_ttm_backend_unbind,
> .eviction_valuable = ttm_bo_eviction_valuable,
> .evict_flags = &qxl_evict_flags,
> .move = &qxl_bo_move,
> diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
> index d3d39823b69f..7fe4a98ece54 100644
> --- a/drivers/gpu/drm/radeon/radeon_ttm.c
> +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
> @@ -817,7 +817,6 @@ static struct ttm_bo_driver radeon_bo_driver = {
> .ttm_tt_populate = &radeon_ttm_tt_populate,
> .ttm_tt_unpopulate = &radeon_ttm_tt_unpopulate,
> .ttm_tt_bind = &radeon_ttm_tt_bind,
> - .ttm_tt_unbind = &radeon_ttm_tt_unbind,
> .ttm_tt_destroy = &radeon_ttm_tt_destroy,
> .eviction_valuable = ttm_bo_eviction_valuable,
> .evict_flags = &radeon_evict_flags,
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> index 7602d7734d38..358d09ef852a 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -1493,8 +1493,3 @@ int ttm_bo_tt_bind(struct ttm_buffer_object *bo, struct ttm_resource *mem)
> {
> return bo->bdev->driver->ttm_tt_bind(bo->bdev, bo->ttm, mem);
> }
> -
> -void ttm_bo_tt_unbind(struct ttm_buffer_object *bo)
> -{
> - bo->bdev->driver->ttm_tt_unbind(bo->bdev, bo->ttm);
> -}
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
> index 1d220a9794e6..6e07ea982961 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
> @@ -760,7 +760,6 @@ struct ttm_bo_driver vmw_bo_driver = {
> .ttm_tt_populate = &vmw_ttm_populate,
> .ttm_tt_unpopulate = &vmw_ttm_unpopulate,
> .ttm_tt_bind = &vmw_ttm_bind,
> - .ttm_tt_unbind = &vmw_ttm_unbind,
> .ttm_tt_destroy = &vmw_ttm_destroy,
> .eviction_valuable = ttm_bo_eviction_valuable,
> .evict_flags = vmw_evict_flags,
> diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
> index 81a1618b9535..fbbcf10670c1 100644
> --- a/include/drm/ttm/ttm_bo_driver.h
> +++ b/include/drm/ttm/ttm_bo_driver.h
> @@ -104,17 +104,6 @@ struct ttm_bo_driver {
> */
> int (*ttm_tt_bind)(struct ttm_bo_device *bdev, struct ttm_tt *ttm, struct ttm_resource *bo_mem);
>
> - /**
> - * ttm_tt_unbind
> - *
> - * @bdev: Pointer to a ttm device
> - * @ttm: Pointer to a struct ttm_tt.
> - *
> - * Unbind previously bound backend pages. This function should be
> - * able to handle differences between aperture and system page sizes.
> - */
> - void (*ttm_tt_unbind)(struct ttm_bo_device *bdev, struct ttm_tt *ttm);
> -
> /**
> * ttm_tt_destroy
> *
> @@ -647,13 +636,6 @@ pgprot_t ttm_io_prot(struct ttm_buffer_object *bo, struct ttm_resource *res,
> */
> int ttm_bo_tt_bind(struct ttm_buffer_object *bo, struct ttm_resource *mem);
>
> -/**
> - * ttm_bo_tt_bind
> - *
> - * Unbind the object tt from a memory resource.
> - */
> -void ttm_bo_tt_unbind(struct ttm_buffer_object *bo);
> -
> /**
> * ttm_bo_tt_destroy.
> */
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 5/7] drm/ttm: remove move to new and inline into remainging place.
2020-10-20 1:03 [PATCH 0/7] drm/ttm: get rid of bind/unbind Dave Airlie
` (3 preceding siblings ...)
2020-10-20 1:03 ` [PATCH 4/7] drm/ttm: drop unbind callback Dave Airlie
@ 2020-10-20 1:03 ` Dave Airlie
2020-10-20 12:06 ` Christian König
2020-10-20 1:03 ` [PATCH 6/7] drm/ttm: drop move notify around move Dave Airlie
2020-10-20 1:03 ` [PATCH 7/7] drm/ttm: move last binding into the drivers Dave Airlie
6 siblings, 1 reply; 15+ messages in thread
From: Dave Airlie @ 2020-10-20 1:03 UTC (permalink / raw)
To: dri-devel; +Cc: christian.koenig
From: Dave Airlie <airlied@redhat.com>
This show the remaining bind callback, which my next series of
patches will aim to remove.
Signed-off-by: Dave Airlie <airlied@redhat.com>
---
drivers/gpu/drm/ttm/ttm_bo.c | 16 +++++++++-------
drivers/gpu/drm/ttm/ttm_bo_util.c | 20 --------------------
include/drm/ttm/ttm_bo_driver.h | 4 ----
3 files changed, 9 insertions(+), 31 deletions(-)
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 358d09ef852a..705ea3ef91f9 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -252,9 +252,15 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
if (ret)
goto out_err;
- ret = ttm_bo_move_to_new_tt_mem(bo, ctx, mem);
- if (ret)
- goto out_err;
+ if (mem->mem_type != TTM_PL_SYSTEM) {
+ ret = ttm_tt_populate(bo->bdev, bo->ttm, ctx);
+ if (ret)
+ goto out_err;
+
+ ret = bdev->driver->ttm_tt_bind(bo->bdev, bo->ttm, mem);
+ if (ret)
+ goto out_err;
+ }
}
if (bdev->driver->move_notify)
@@ -1489,7 +1495,3 @@ void ttm_bo_tt_destroy(struct ttm_buffer_object *bo)
bo->ttm = NULL;
}
-int ttm_bo_tt_bind(struct ttm_buffer_object *bo, struct ttm_resource *mem)
-{
- return bo->bdev->driver->ttm_tt_bind(bo->bdev, bo->ttm, mem);
-}
diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c
index 21811bbda2e4..fae31f7f5c35 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_util.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
@@ -45,26 +45,6 @@ struct ttm_transfer_obj {
struct ttm_buffer_object *bo;
};
-int ttm_bo_move_to_new_tt_mem(struct ttm_buffer_object *bo,
- struct ttm_operation_ctx *ctx,
- struct ttm_resource *new_mem)
-{
- int ret;
-
- if (new_mem->mem_type == TTM_PL_SYSTEM)
- return 0;
-
- ret = ttm_tt_populate(bo->bdev, bo->ttm, ctx);
- if (unlikely(ret != 0))
- return ret;
-
- ret = ttm_bo_tt_bind(bo, new_mem);
- if (unlikely(ret != 0))
- return ret;
-
- return 0;
-}
-
int ttm_mem_io_reserve(struct ttm_bo_device *bdev,
struct ttm_resource *mem)
{
diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
index fbbcf10670c1..0c4efc169f46 100644
--- a/include/drm/ttm/ttm_bo_driver.h
+++ b/include/drm/ttm/ttm_bo_driver.h
@@ -560,10 +560,6 @@ int ttm_mem_io_reserve(struct ttm_bo_device *bdev,
void ttm_mem_io_free(struct ttm_bo_device *bdev,
struct ttm_resource *mem);
-int ttm_bo_move_to_new_tt_mem(struct ttm_buffer_object *bo,
- struct ttm_operation_ctx *ctx,
- struct ttm_resource *new_mem);
-
/**
* ttm_bo_move_memcpy
*
--
2.27.0
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [PATCH 5/7] drm/ttm: remove move to new and inline into remainging place.
2020-10-20 1:03 ` [PATCH 5/7] drm/ttm: remove move to new and inline into remainging place Dave Airlie
@ 2020-10-20 12:06 ` Christian König
0 siblings, 0 replies; 15+ messages in thread
From: Christian König @ 2020-10-20 12:06 UTC (permalink / raw)
To: Dave Airlie, dri-devel
Am 20.10.20 um 03:03 schrieb Dave Airlie:
> From: Dave Airlie <airlied@redhat.com>
>
> This show the remaining bind callback, which my next series of
> patches will aim to remove.
>
> Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
> ---
> drivers/gpu/drm/ttm/ttm_bo.c | 16 +++++++++-------
> drivers/gpu/drm/ttm/ttm_bo_util.c | 20 --------------------
> include/drm/ttm/ttm_bo_driver.h | 4 ----
> 3 files changed, 9 insertions(+), 31 deletions(-)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> index 358d09ef852a..705ea3ef91f9 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -252,9 +252,15 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
> if (ret)
> goto out_err;
>
> - ret = ttm_bo_move_to_new_tt_mem(bo, ctx, mem);
> - if (ret)
> - goto out_err;
> + if (mem->mem_type != TTM_PL_SYSTEM) {
> + ret = ttm_tt_populate(bo->bdev, bo->ttm, ctx);
> + if (ret)
> + goto out_err;
> +
> + ret = bdev->driver->ttm_tt_bind(bo->bdev, bo->ttm, mem);
> + if (ret)
> + goto out_err;
> + }
> }
>
> if (bdev->driver->move_notify)
> @@ -1489,7 +1495,3 @@ void ttm_bo_tt_destroy(struct ttm_buffer_object *bo)
> bo->ttm = NULL;
> }
>
> -int ttm_bo_tt_bind(struct ttm_buffer_object *bo, struct ttm_resource *mem)
> -{
> - return bo->bdev->driver->ttm_tt_bind(bo->bdev, bo->ttm, mem);
> -}
> diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c
> index 21811bbda2e4..fae31f7f5c35 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo_util.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
> @@ -45,26 +45,6 @@ struct ttm_transfer_obj {
> struct ttm_buffer_object *bo;
> };
>
> -int ttm_bo_move_to_new_tt_mem(struct ttm_buffer_object *bo,
> - struct ttm_operation_ctx *ctx,
> - struct ttm_resource *new_mem)
> -{
> - int ret;
> -
> - if (new_mem->mem_type == TTM_PL_SYSTEM)
> - return 0;
> -
> - ret = ttm_tt_populate(bo->bdev, bo->ttm, ctx);
> - if (unlikely(ret != 0))
> - return ret;
> -
> - ret = ttm_bo_tt_bind(bo, new_mem);
> - if (unlikely(ret != 0))
> - return ret;
> -
> - return 0;
> -}
> -
> int ttm_mem_io_reserve(struct ttm_bo_device *bdev,
> struct ttm_resource *mem)
> {
> diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
> index fbbcf10670c1..0c4efc169f46 100644
> --- a/include/drm/ttm/ttm_bo_driver.h
> +++ b/include/drm/ttm/ttm_bo_driver.h
> @@ -560,10 +560,6 @@ int ttm_mem_io_reserve(struct ttm_bo_device *bdev,
> void ttm_mem_io_free(struct ttm_bo_device *bdev,
> struct ttm_resource *mem);
>
> -int ttm_bo_move_to_new_tt_mem(struct ttm_buffer_object *bo,
> - struct ttm_operation_ctx *ctx,
> - struct ttm_resource *new_mem);
> -
> /**
> * ttm_bo_move_memcpy
> *
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 6/7] drm/ttm: drop move notify around move.
2020-10-20 1:03 [PATCH 0/7] drm/ttm: get rid of bind/unbind Dave Airlie
` (4 preceding siblings ...)
2020-10-20 1:03 ` [PATCH 5/7] drm/ttm: remove move to new and inline into remainging place Dave Airlie
@ 2020-10-20 1:03 ` Dave Airlie
2020-10-20 12:15 ` Christian König
2020-10-20 1:03 ` [PATCH 7/7] drm/ttm: move last binding into the drivers Dave Airlie
6 siblings, 1 reply; 15+ messages in thread
From: Dave Airlie @ 2020-10-20 1:03 UTC (permalink / raw)
To: dri-devel; +Cc: christian.koenig
From: Dave Airlie <airlied@redhat.com>
The drivers now do this in the move callback.
move_notify is still needed in the destroy path.
Signed-off-by: Dave Airlie <airlied@redhat.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 13 +++++--
drivers/gpu/drm/drm_gem_vram_helper.c | 11 +++++-
drivers/gpu/drm/nouveau/nouveau_bo.c | 12 ++++--
drivers/gpu/drm/qxl/qxl_ttm.c | 45 +++++++++++++---------
drivers/gpu/drm/radeon/radeon_ttm.c | 11 +++++-
drivers/gpu/drm/ttm/ttm_bo.c | 12 +-----
drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c | 14 ++++++-
7 files changed, 78 insertions(+), 40 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index ac93a537f2e2..9aba34b57e60 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -666,6 +666,8 @@ static int amdgpu_bo_move(struct ttm_buffer_object *bo, bool evict,
struct ttm_resource *old_mem = &bo->mem;
int r;
+ amdgpu_bo_move_notify(bo, evict, new_mem);
+
/* Can't move a pinned BO */
abo = ttm_to_amdgpu_bo(bo);
if (WARN_ON_ONCE(abo->tbo.pin_count > 0))
@@ -687,7 +689,7 @@ static int amdgpu_bo_move(struct ttm_buffer_object *bo, bool evict,
new_mem->mem_type == TTM_PL_SYSTEM) {
r = ttm_bo_wait_ctx(bo, ctx);
if (r)
- return r;
+ goto fail;
amdgpu_ttm_backend_unbind(bo->bdev, bo->ttm);
ttm_resource_free(bo, &bo->mem);
@@ -728,12 +730,12 @@ static int amdgpu_bo_move(struct ttm_buffer_object *bo, bool evict,
if (!amdgpu_mem_visible(adev, old_mem) ||
!amdgpu_mem_visible(adev, new_mem)) {
pr_err("Move buffer fallback to memcpy unavailable\n");
- return r;
+ goto fail;
}
r = ttm_bo_move_memcpy(bo, ctx, new_mem);
if (r)
- return r;
+ goto fail;
}
if (bo->type == ttm_bo_type_device &&
@@ -748,6 +750,11 @@ static int amdgpu_bo_move(struct ttm_buffer_object *bo, bool evict,
/* update statistics */
atomic64_add((u64)bo->mem.num_pages << PAGE_SHIFT, &adev->num_bytes_moved);
return 0;
+fail:
+ swap(*new_mem, bo->mem);
+ amdgpu_bo_move_notify(bo, false, new_mem);
+ swap(*new_mem, bo->mem);
+ return r;
}
/**
diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c b/drivers/gpu/drm/drm_gem_vram_helper.c
index e99782bc13f1..b4b419732676 100644
--- a/drivers/gpu/drm/drm_gem_vram_helper.c
+++ b/drivers/gpu/drm/drm_gem_vram_helper.c
@@ -590,7 +590,16 @@ static int drm_gem_vram_bo_driver_move(struct drm_gem_vram_object *gbo,
struct ttm_operation_ctx *ctx,
struct ttm_resource *new_mem)
{
- return ttm_bo_move_memcpy(&gbo->bo, ctx, new_mem);
+ int ret;
+
+ drm_gem_vram_bo_driver_move_notify(gbo, evict, new_mem);
+ ret = ttm_bo_move_memcpy(&gbo->bo, ctx, new_mem);
+ if (ret) {
+ swap(*new_mem, gbo->bo.mem);
+ drm_gem_vram_bo_driver_move_notify(gbo, false, new_mem);
+ swap(*new_mem, gbo->bo.mem);
+ }
+ return ret;
}
/*
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
index 7fb65b87f815..ad0493c5103b 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -1032,9 +1032,10 @@ nouveau_bo_move(struct ttm_buffer_object *bo, bool evict,
struct nouveau_drm_tile *new_tile = NULL;
int ret = 0;
+ nouveau_bo_move_ntfy(bo, evict, new_reg);
ret = ttm_bo_wait_ctx(bo, ctx);
if (ret)
- return ret;
+ goto out_ntfy;
if (nvbo->bo.pin_count)
NV_WARN(drm, "Moving pinned object %p!\n", nvbo);
@@ -1042,7 +1043,7 @@ nouveau_bo_move(struct ttm_buffer_object *bo, bool evict,
if (drm->client.device.info.family < NV_DEVICE_INFO_V0_TESLA) {
ret = nouveau_bo_vm_bind(bo, new_reg, &new_tile);
if (ret)
- return ret;
+ goto out_ntfy;
}
/* Fake bo copy. */
@@ -1090,7 +1091,12 @@ nouveau_bo_move(struct ttm_buffer_object *bo, bool evict,
else
nouveau_bo_vm_cleanup(bo, new_tile, &nvbo->tile);
}
-
+out_ntfy:
+ if (ret) {
+ swap(*new_reg, bo->mem);
+ nouveau_bo_move_ntfy(bo, false, new_reg);
+ swap(*new_reg, bo->mem);
+ }
return ret;
}
diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
index 95c4f2c7ab79..a6149e3cc3d2 100644
--- a/drivers/gpu/drm/qxl/qxl_ttm.c
+++ b/drivers/gpu/drm/qxl/qxl_ttm.c
@@ -136,24 +136,6 @@ static struct ttm_tt *qxl_ttm_tt_create(struct ttm_buffer_object *bo,
return ttm;
}
-static int qxl_bo_move(struct ttm_buffer_object *bo, bool evict,
- struct ttm_operation_ctx *ctx,
- struct ttm_resource *new_mem)
-{
- struct ttm_resource *old_mem = &bo->mem;
- int ret;
-
- ret = ttm_bo_wait_ctx(bo, ctx);
- if (ret)
- return ret;
-
- if (old_mem->mem_type == TTM_PL_SYSTEM && bo->ttm == NULL) {
- ttm_bo_move_null(bo, new_mem);
- return 0;
- }
- return ttm_bo_move_memcpy(bo, ctx, new_mem);
-}
-
static void qxl_bo_move_notify(struct ttm_buffer_object *bo,
bool evict,
struct ttm_resource *new_mem)
@@ -170,6 +152,33 @@ static void qxl_bo_move_notify(struct ttm_buffer_object *bo,
qxl_surface_evict(qdev, qbo, new_mem ? true : false);
}
+static int qxl_bo_move(struct ttm_buffer_object *bo, bool evict,
+ struct ttm_operation_ctx *ctx,
+ struct ttm_resource *new_mem)
+{
+ struct ttm_resource *old_mem = &bo->mem;
+ int ret;
+
+ qxl_bo_move_notify(bo, evict, new_mem);
+
+ ret = ttm_bo_wait_ctx(bo, ctx);
+ if (ret)
+ goto out;
+
+ if (old_mem->mem_type == TTM_PL_SYSTEM && bo->ttm == NULL) {
+ ttm_bo_move_null(bo, new_mem);
+ return 0;
+ }
+ ret = ttm_bo_move_memcpy(bo, ctx, new_mem);
+out:
+ if (ret) {
+ swap(*new_mem, bo->mem);
+ qxl_bo_move_notify(bo, false, new_mem);
+ swap(*new_mem, bo->mem);
+ }
+ return ret;
+}
+
static struct ttm_bo_driver qxl_bo_driver = {
.ttm_tt_create = &qxl_ttm_tt_create,
.ttm_tt_bind = &qxl_ttm_backend_bind,
diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
index 7fe4a98ece54..e427194b0b50 100644
--- a/drivers/gpu/drm/radeon/radeon_ttm.c
+++ b/drivers/gpu/drm/radeon/radeon_ttm.c
@@ -311,9 +311,11 @@ static int radeon_bo_move(struct ttm_buffer_object *bo, bool evict,
struct ttm_resource *old_mem = &bo->mem;
int r;
+ radeon_bo_move_notify(bo, evict, new_mem);
+
r = ttm_bo_wait_ctx(bo, ctx);
if (r)
- return r;
+ goto fail;
/* Can't move a pinned BO */
rbo = container_of(bo, struct radeon_bo, tbo);
@@ -359,13 +361,18 @@ static int radeon_bo_move(struct ttm_buffer_object *bo, bool evict,
memcpy:
r = ttm_bo_move_memcpy(bo, ctx, new_mem);
if (r) {
- return r;
+ goto fail;
}
}
/* update statistics */
atomic64_add((u64)bo->mem.num_pages << PAGE_SHIFT, &rdev->num_bytes_moved);
return 0;
+fail:
+ swap(*new_mem, bo->mem);
+ radeon_bo_move_notify(bo, false, new_mem);
+ swap(*new_mem, bo->mem);
+ return r;
}
static int radeon_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_resource *mem)
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 705ea3ef91f9..e8ac3bc45d95 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -263,19 +263,9 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
}
}
- if (bdev->driver->move_notify)
- bdev->driver->move_notify(bo, evict, mem);
-
ret = bdev->driver->move(bo, evict, ctx, mem);
- if (ret) {
- if (bdev->driver->move_notify) {
- swap(*mem, bo->mem);
- bdev->driver->move_notify(bo, false, mem);
- swap(*mem, bo->mem);
- }
-
+ if (ret)
goto out_err;
- }
ctx->bytes_moved += bo->mem.num_pages << PAGE_SHIFT;
return 0;
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
index 6e07ea982961..fd82c9ba2d77 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
@@ -737,6 +737,8 @@ static int vmw_move(struct ttm_buffer_object *bo,
struct ttm_resource_manager *new_man = ttm_manager_type(bo->bdev, new_mem->mem_type);
int ret;
+ vmw_move_notify(bo, evict, new_mem);
+
if (old_man->use_tt && new_man->use_tt) {
if (bo->mem.mem_type == TTM_PL_SYSTEM) {
ttm_bo_assign_mem(bo, new_mem);
@@ -744,15 +746,23 @@ static int vmw_move(struct ttm_buffer_object *bo,
}
ret = ttm_bo_wait_ctx(bo, ctx);
if (ret)
- return ret;
+ goto fail;
vmw_ttm_unbind(bo->bdev, bo->ttm);
ttm_resource_free(bo, &bo->mem);
ttm_bo_assign_mem(bo, new_mem);
return 0;
} else {
- return ttm_bo_move_memcpy(bo, ctx, new_mem);
+ ret = ttm_bo_move_memcpy(bo, ctx, new_mem);
+ if (ret)
+ goto fail;
}
+ return 0;
+fail:
+ swap(*new_mem, bo->mem);
+ vmw_move_notify(bo, false, new_mem);
+ swap(*new_mem, bo->mem);
+ return ret;
}
struct ttm_bo_driver vmw_bo_driver = {
--
2.27.0
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [PATCH 6/7] drm/ttm: drop move notify around move.
2020-10-20 1:03 ` [PATCH 6/7] drm/ttm: drop move notify around move Dave Airlie
@ 2020-10-20 12:15 ` Christian König
0 siblings, 0 replies; 15+ messages in thread
From: Christian König @ 2020-10-20 12:15 UTC (permalink / raw)
To: Dave Airlie, dri-devel
Am 20.10.20 um 03:03 schrieb Dave Airlie:
> From: Dave Airlie <airlied@redhat.com>
>
> The drivers now do this in the move callback.
>
> move_notify is still needed in the destroy path.
>
> Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 13 +++++--
> drivers/gpu/drm/drm_gem_vram_helper.c | 11 +++++-
> drivers/gpu/drm/nouveau/nouveau_bo.c | 12 ++++--
> drivers/gpu/drm/qxl/qxl_ttm.c | 45 +++++++++++++---------
> drivers/gpu/drm/radeon/radeon_ttm.c | 11 +++++-
> drivers/gpu/drm/ttm/ttm_bo.c | 12 +-----
> drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c | 14 ++++++-
> 7 files changed, 78 insertions(+), 40 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> index ac93a537f2e2..9aba34b57e60 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> @@ -666,6 +666,8 @@ static int amdgpu_bo_move(struct ttm_buffer_object *bo, bool evict,
> struct ttm_resource *old_mem = &bo->mem;
> int r;
>
> + amdgpu_bo_move_notify(bo, evict, new_mem);
> +
> /* Can't move a pinned BO */
> abo = ttm_to_amdgpu_bo(bo);
> if (WARN_ON_ONCE(abo->tbo.pin_count > 0))
> @@ -687,7 +689,7 @@ static int amdgpu_bo_move(struct ttm_buffer_object *bo, bool evict,
> new_mem->mem_type == TTM_PL_SYSTEM) {
> r = ttm_bo_wait_ctx(bo, ctx);
> if (r)
> - return r;
> + goto fail;
>
> amdgpu_ttm_backend_unbind(bo->bdev, bo->ttm);
> ttm_resource_free(bo, &bo->mem);
> @@ -728,12 +730,12 @@ static int amdgpu_bo_move(struct ttm_buffer_object *bo, bool evict,
> if (!amdgpu_mem_visible(adev, old_mem) ||
> !amdgpu_mem_visible(adev, new_mem)) {
> pr_err("Move buffer fallback to memcpy unavailable\n");
> - return r;
> + goto fail;
> }
>
> r = ttm_bo_move_memcpy(bo, ctx, new_mem);
> if (r)
> - return r;
> + goto fail;
> }
>
> if (bo->type == ttm_bo_type_device &&
> @@ -748,6 +750,11 @@ static int amdgpu_bo_move(struct ttm_buffer_object *bo, bool evict,
> /* update statistics */
> atomic64_add((u64)bo->mem.num_pages << PAGE_SHIFT, &adev->num_bytes_moved);
> return 0;
> +fail:
> + swap(*new_mem, bo->mem);
> + amdgpu_bo_move_notify(bo, false, new_mem);
> + swap(*new_mem, bo->mem);
> + return r;
> }
>
> /**
> diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c b/drivers/gpu/drm/drm_gem_vram_helper.c
> index e99782bc13f1..b4b419732676 100644
> --- a/drivers/gpu/drm/drm_gem_vram_helper.c
> +++ b/drivers/gpu/drm/drm_gem_vram_helper.c
> @@ -590,7 +590,16 @@ static int drm_gem_vram_bo_driver_move(struct drm_gem_vram_object *gbo,
> struct ttm_operation_ctx *ctx,
> struct ttm_resource *new_mem)
> {
> - return ttm_bo_move_memcpy(&gbo->bo, ctx, new_mem);
> + int ret;
> +
> + drm_gem_vram_bo_driver_move_notify(gbo, evict, new_mem);
> + ret = ttm_bo_move_memcpy(&gbo->bo, ctx, new_mem);
> + if (ret) {
> + swap(*new_mem, gbo->bo.mem);
> + drm_gem_vram_bo_driver_move_notify(gbo, false, new_mem);
> + swap(*new_mem, gbo->bo.mem);
> + }
> + return ret;
> }
>
> /*
> diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
> index 7fb65b87f815..ad0493c5103b 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_bo.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
> @@ -1032,9 +1032,10 @@ nouveau_bo_move(struct ttm_buffer_object *bo, bool evict,
> struct nouveau_drm_tile *new_tile = NULL;
> int ret = 0;
>
> + nouveau_bo_move_ntfy(bo, evict, new_reg);
> ret = ttm_bo_wait_ctx(bo, ctx);
> if (ret)
> - return ret;
> + goto out_ntfy;
>
> if (nvbo->bo.pin_count)
> NV_WARN(drm, "Moving pinned object %p!\n", nvbo);
> @@ -1042,7 +1043,7 @@ nouveau_bo_move(struct ttm_buffer_object *bo, bool evict,
> if (drm->client.device.info.family < NV_DEVICE_INFO_V0_TESLA) {
> ret = nouveau_bo_vm_bind(bo, new_reg, &new_tile);
> if (ret)
> - return ret;
> + goto out_ntfy;
> }
>
> /* Fake bo copy. */
> @@ -1090,7 +1091,12 @@ nouveau_bo_move(struct ttm_buffer_object *bo, bool evict,
> else
> nouveau_bo_vm_cleanup(bo, new_tile, &nvbo->tile);
> }
> -
> +out_ntfy:
> + if (ret) {
> + swap(*new_reg, bo->mem);
> + nouveau_bo_move_ntfy(bo, false, new_reg);
> + swap(*new_reg, bo->mem);
> + }
> return ret;
> }
>
> diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
> index 95c4f2c7ab79..a6149e3cc3d2 100644
> --- a/drivers/gpu/drm/qxl/qxl_ttm.c
> +++ b/drivers/gpu/drm/qxl/qxl_ttm.c
> @@ -136,24 +136,6 @@ static struct ttm_tt *qxl_ttm_tt_create(struct ttm_buffer_object *bo,
> return ttm;
> }
>
> -static int qxl_bo_move(struct ttm_buffer_object *bo, bool evict,
> - struct ttm_operation_ctx *ctx,
> - struct ttm_resource *new_mem)
> -{
> - struct ttm_resource *old_mem = &bo->mem;
> - int ret;
> -
> - ret = ttm_bo_wait_ctx(bo, ctx);
> - if (ret)
> - return ret;
> -
> - if (old_mem->mem_type == TTM_PL_SYSTEM && bo->ttm == NULL) {
> - ttm_bo_move_null(bo, new_mem);
> - return 0;
> - }
> - return ttm_bo_move_memcpy(bo, ctx, new_mem);
> -}
> -
> static void qxl_bo_move_notify(struct ttm_buffer_object *bo,
> bool evict,
> struct ttm_resource *new_mem)
> @@ -170,6 +152,33 @@ static void qxl_bo_move_notify(struct ttm_buffer_object *bo,
> qxl_surface_evict(qdev, qbo, new_mem ? true : false);
> }
>
> +static int qxl_bo_move(struct ttm_buffer_object *bo, bool evict,
> + struct ttm_operation_ctx *ctx,
> + struct ttm_resource *new_mem)
> +{
> + struct ttm_resource *old_mem = &bo->mem;
> + int ret;
> +
> + qxl_bo_move_notify(bo, evict, new_mem);
> +
> + ret = ttm_bo_wait_ctx(bo, ctx);
> + if (ret)
> + goto out;
> +
> + if (old_mem->mem_type == TTM_PL_SYSTEM && bo->ttm == NULL) {
> + ttm_bo_move_null(bo, new_mem);
> + return 0;
> + }
> + ret = ttm_bo_move_memcpy(bo, ctx, new_mem);
> +out:
> + if (ret) {
> + swap(*new_mem, bo->mem);
> + qxl_bo_move_notify(bo, false, new_mem);
> + swap(*new_mem, bo->mem);
> + }
> + return ret;
> +}
> +
> static struct ttm_bo_driver qxl_bo_driver = {
> .ttm_tt_create = &qxl_ttm_tt_create,
> .ttm_tt_bind = &qxl_ttm_backend_bind,
> diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
> index 7fe4a98ece54..e427194b0b50 100644
> --- a/drivers/gpu/drm/radeon/radeon_ttm.c
> +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
> @@ -311,9 +311,11 @@ static int radeon_bo_move(struct ttm_buffer_object *bo, bool evict,
> struct ttm_resource *old_mem = &bo->mem;
> int r;
>
> + radeon_bo_move_notify(bo, evict, new_mem);
> +
> r = ttm_bo_wait_ctx(bo, ctx);
> if (r)
> - return r;
> + goto fail;
>
> /* Can't move a pinned BO */
> rbo = container_of(bo, struct radeon_bo, tbo);
> @@ -359,13 +361,18 @@ static int radeon_bo_move(struct ttm_buffer_object *bo, bool evict,
> memcpy:
> r = ttm_bo_move_memcpy(bo, ctx, new_mem);
> if (r) {
> - return r;
> + goto fail;
> }
> }
>
> /* update statistics */
> atomic64_add((u64)bo->mem.num_pages << PAGE_SHIFT, &rdev->num_bytes_moved);
> return 0;
> +fail:
> + swap(*new_mem, bo->mem);
> + radeon_bo_move_notify(bo, false, new_mem);
> + swap(*new_mem, bo->mem);
> + return r;
> }
>
> static int radeon_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_resource *mem)
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> index 705ea3ef91f9..e8ac3bc45d95 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -263,19 +263,9 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
> }
> }
>
> - if (bdev->driver->move_notify)
> - bdev->driver->move_notify(bo, evict, mem);
> -
> ret = bdev->driver->move(bo, evict, ctx, mem);
> - if (ret) {
> - if (bdev->driver->move_notify) {
> - swap(*mem, bo->mem);
> - bdev->driver->move_notify(bo, false, mem);
> - swap(*mem, bo->mem);
> - }
> -
> + if (ret)
> goto out_err;
> - }
>
> ctx->bytes_moved += bo->mem.num_pages << PAGE_SHIFT;
> return 0;
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
> index 6e07ea982961..fd82c9ba2d77 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
> @@ -737,6 +737,8 @@ static int vmw_move(struct ttm_buffer_object *bo,
> struct ttm_resource_manager *new_man = ttm_manager_type(bo->bdev, new_mem->mem_type);
> int ret;
>
> + vmw_move_notify(bo, evict, new_mem);
> +
> if (old_man->use_tt && new_man->use_tt) {
> if (bo->mem.mem_type == TTM_PL_SYSTEM) {
> ttm_bo_assign_mem(bo, new_mem);
> @@ -744,15 +746,23 @@ static int vmw_move(struct ttm_buffer_object *bo,
> }
> ret = ttm_bo_wait_ctx(bo, ctx);
> if (ret)
> - return ret;
> + goto fail;
>
> vmw_ttm_unbind(bo->bdev, bo->ttm);
> ttm_resource_free(bo, &bo->mem);
> ttm_bo_assign_mem(bo, new_mem);
> return 0;
> } else {
> - return ttm_bo_move_memcpy(bo, ctx, new_mem);
> + ret = ttm_bo_move_memcpy(bo, ctx, new_mem);
> + if (ret)
> + goto fail;
> }
> + return 0;
> +fail:
> + swap(*new_mem, bo->mem);
> + vmw_move_notify(bo, false, new_mem);
> + swap(*new_mem, bo->mem);
> + return ret;
> }
>
> struct ttm_bo_driver vmw_bo_driver = {
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 7/7] drm/ttm: move last binding into the drivers.
2020-10-20 1:03 [PATCH 0/7] drm/ttm: get rid of bind/unbind Dave Airlie
` (5 preceding siblings ...)
2020-10-20 1:03 ` [PATCH 6/7] drm/ttm: drop move notify around move Dave Airlie
@ 2020-10-20 1:03 ` Dave Airlie
2020-10-20 12:16 ` Christian König
6 siblings, 1 reply; 15+ messages in thread
From: Dave Airlie @ 2020-10-20 1:03 UTC (permalink / raw)
To: dri-devel; +Cc: christian.koenig
From: Dave Airlie <airlied@redhat.com>
This moves the call to tt binding into the driver move,
and drops the driver callback.
Signed-off-by: Dave Airlie <airlied@redhat.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 7 ++++++-
drivers/gpu/drm/nouveau/nouveau_bo.c | 7 ++++++-
drivers/gpu/drm/qxl/qxl_ttm.c | 14 --------------
drivers/gpu/drm/radeon/radeon_ttm.c | 6 +++++-
drivers/gpu/drm/ttm/ttm_bo.c | 4 ----
drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c | 7 ++++++-
include/drm/ttm/ttm_bo_driver.h | 14 --------------
7 files changed, 23 insertions(+), 36 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index 9aba34b57e60..d1d1bd656153 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -666,6 +666,12 @@ static int amdgpu_bo_move(struct ttm_buffer_object *bo, bool evict,
struct ttm_resource *old_mem = &bo->mem;
int r;
+ if (new_mem->mem_type == TTM_PL_TT) {
+ r = amdgpu_ttm_backend_bind(bo->bdev, bo->ttm, new_mem);
+ if (r)
+ return r;
+ }
+
amdgpu_bo_move_notify(bo, evict, new_mem);
/* Can't move a pinned BO */
@@ -1728,7 +1734,6 @@ static struct ttm_bo_driver amdgpu_bo_driver = {
.ttm_tt_create = &amdgpu_ttm_tt_create,
.ttm_tt_populate = &amdgpu_ttm_tt_populate,
.ttm_tt_unpopulate = &amdgpu_ttm_tt_unpopulate,
- .ttm_tt_bind = &amdgpu_ttm_backend_bind,
.ttm_tt_destroy = &amdgpu_ttm_backend_destroy,
.eviction_valuable = amdgpu_ttm_bo_eviction_valuable,
.evict_flags = &amdgpu_evict_flags,
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
index ad0493c5103b..a69bd4098984 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -1032,6 +1032,12 @@ nouveau_bo_move(struct ttm_buffer_object *bo, bool evict,
struct nouveau_drm_tile *new_tile = NULL;
int ret = 0;
+ if (new_reg->mem_type == TTM_PL_TT) {
+ ret = nouveau_ttm_tt_bind(bo->bdev, bo->ttm, new_reg);
+ if (ret)
+ return ret;
+ }
+
nouveau_bo_move_ntfy(bo, evict, new_reg);
ret = ttm_bo_wait_ctx(bo, ctx);
if (ret)
@@ -1399,7 +1405,6 @@ struct ttm_bo_driver nouveau_bo_driver = {
.ttm_tt_create = &nouveau_ttm_tt_create,
.ttm_tt_populate = &nouveau_ttm_tt_populate,
.ttm_tt_unpopulate = &nouveau_ttm_tt_unpopulate,
- .ttm_tt_bind = &nouveau_ttm_tt_bind,
.ttm_tt_destroy = &nouveau_ttm_tt_destroy,
.eviction_valuable = ttm_bo_eviction_valuable,
.evict_flags = nouveau_bo_evict_flags,
diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
index a6149e3cc3d2..1cc3c14bc684 100644
--- a/drivers/gpu/drm/qxl/qxl_ttm.c
+++ b/drivers/gpu/drm/qxl/qxl_ttm.c
@@ -100,19 +100,6 @@ int qxl_ttm_io_mem_reserve(struct ttm_bo_device *bdev,
/*
* TTM backend functions.
*/
-
-static int qxl_ttm_backend_bind(struct ttm_bo_device *bdev,
- struct ttm_tt *ttm,
- struct ttm_resource *bo_mem)
-{
- if (!ttm->num_pages) {
- WARN(1, "nothing to bind %lu pages for mreg %p back %p!\n",
- ttm->num_pages, bo_mem, ttm);
- }
- /* Not implemented */
- return -1;
-}
-
static void qxl_ttm_backend_destroy(struct ttm_bo_device *bdev,
struct ttm_tt *ttm)
{
@@ -181,7 +168,6 @@ static int qxl_bo_move(struct ttm_buffer_object *bo, bool evict,
static struct ttm_bo_driver qxl_bo_driver = {
.ttm_tt_create = &qxl_ttm_tt_create,
- .ttm_tt_bind = &qxl_ttm_backend_bind,
.ttm_tt_destroy = &qxl_ttm_backend_destroy,
.eviction_valuable = ttm_bo_eviction_valuable,
.evict_flags = &qxl_evict_flags,
diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
index e427194b0b50..ac916fdd54d1 100644
--- a/drivers/gpu/drm/radeon/radeon_ttm.c
+++ b/drivers/gpu/drm/radeon/radeon_ttm.c
@@ -311,6 +311,11 @@ static int radeon_bo_move(struct ttm_buffer_object *bo, bool evict,
struct ttm_resource *old_mem = &bo->mem;
int r;
+ if (new_mem->mem_type == TTM_PL_TT) {
+ r = radeon_ttm_tt_bind(bo->bdev, bo->ttm, new_mem);
+ if (r)
+ return r;
+ }
radeon_bo_move_notify(bo, evict, new_mem);
r = ttm_bo_wait_ctx(bo, ctx);
@@ -823,7 +828,6 @@ static struct ttm_bo_driver radeon_bo_driver = {
.ttm_tt_create = &radeon_ttm_tt_create,
.ttm_tt_populate = &radeon_ttm_tt_populate,
.ttm_tt_unpopulate = &radeon_ttm_tt_unpopulate,
- .ttm_tt_bind = &radeon_ttm_tt_bind,
.ttm_tt_destroy = &radeon_ttm_tt_destroy,
.eviction_valuable = ttm_bo_eviction_valuable,
.evict_flags = &radeon_evict_flags,
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index e8ac3bc45d95..4b7fdb49df52 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -256,10 +256,6 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
ret = ttm_tt_populate(bo->bdev, bo->ttm, ctx);
if (ret)
goto out_err;
-
- ret = bdev->driver->ttm_tt_bind(bo->bdev, bo->ttm, mem);
- if (ret)
- goto out_err;
}
}
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
index fd82c9ba2d77..de25cf016be2 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
@@ -737,6 +737,12 @@ static int vmw_move(struct ttm_buffer_object *bo,
struct ttm_resource_manager *new_man = ttm_manager_type(bo->bdev, new_mem->mem_type);
int ret;
+ if (new_man->use_tt && new_mem->mem_type != TTM_PL_SYSTEM) {
+ ret = vmw_ttm_bind(bo->bdev, bo->ttm, new_mem);
+ if (ret)
+ return ret;
+ }
+
vmw_move_notify(bo, evict, new_mem);
if (old_man->use_tt && new_man->use_tt) {
@@ -769,7 +775,6 @@ struct ttm_bo_driver vmw_bo_driver = {
.ttm_tt_create = &vmw_ttm_tt_create,
.ttm_tt_populate = &vmw_ttm_populate,
.ttm_tt_unpopulate = &vmw_ttm_unpopulate,
- .ttm_tt_bind = &vmw_ttm_bind,
.ttm_tt_destroy = &vmw_ttm_destroy,
.eviction_valuable = ttm_bo_eviction_valuable,
.evict_flags = vmw_evict_flags,
diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
index 0c4efc169f46..72f106b335e9 100644
--- a/include/drm/ttm/ttm_bo_driver.h
+++ b/include/drm/ttm/ttm_bo_driver.h
@@ -90,20 +90,6 @@ struct ttm_bo_driver {
*/
void (*ttm_tt_unpopulate)(struct ttm_bo_device *bdev, struct ttm_tt *ttm);
- /**
- * ttm_tt_bind
- *
- * @bdev: Pointer to a ttm device
- * @ttm: Pointer to a struct ttm_tt.
- * @bo_mem: Pointer to a struct ttm_resource describing the
- * memory type and location for binding.
- *
- * Bind the backend pages into the aperture in the location
- * indicated by @bo_mem. This function should be able to handle
- * differences between aperture and system page sizes.
- */
- int (*ttm_tt_bind)(struct ttm_bo_device *bdev, struct ttm_tt *ttm, struct ttm_resource *bo_mem);
-
/**
* ttm_tt_destroy
*
--
2.27.0
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [PATCH 7/7] drm/ttm: move last binding into the drivers.
2020-10-20 1:03 ` [PATCH 7/7] drm/ttm: move last binding into the drivers Dave Airlie
@ 2020-10-20 12:16 ` Christian König
0 siblings, 0 replies; 15+ messages in thread
From: Christian König @ 2020-10-20 12:16 UTC (permalink / raw)
To: Dave Airlie, dri-devel
Am 20.10.20 um 03:03 schrieb Dave Airlie:
> From: Dave Airlie <airlied@redhat.com>
>
> This moves the call to tt binding into the driver move,
> and drops the driver callback.
>
> Signed-off-by: Dave Airlie <airlied@redhat.com>
amdgpu should now get some cleanup, but that is certainly not topic of
this patch.
Really nice work, patch is Reviewed-by: Christian König
<christian.koenig@amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 7 ++++++-
> drivers/gpu/drm/nouveau/nouveau_bo.c | 7 ++++++-
> drivers/gpu/drm/qxl/qxl_ttm.c | 14 --------------
> drivers/gpu/drm/radeon/radeon_ttm.c | 6 +++++-
> drivers/gpu/drm/ttm/ttm_bo.c | 4 ----
> drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c | 7 ++++++-
> include/drm/ttm/ttm_bo_driver.h | 14 --------------
> 7 files changed, 23 insertions(+), 36 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> index 9aba34b57e60..d1d1bd656153 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> @@ -666,6 +666,12 @@ static int amdgpu_bo_move(struct ttm_buffer_object *bo, bool evict,
> struct ttm_resource *old_mem = &bo->mem;
> int r;
>
> + if (new_mem->mem_type == TTM_PL_TT) {
> + r = amdgpu_ttm_backend_bind(bo->bdev, bo->ttm, new_mem);
> + if (r)
> + return r;
> + }
> +
> amdgpu_bo_move_notify(bo, evict, new_mem);
>
> /* Can't move a pinned BO */
> @@ -1728,7 +1734,6 @@ static struct ttm_bo_driver amdgpu_bo_driver = {
> .ttm_tt_create = &amdgpu_ttm_tt_create,
> .ttm_tt_populate = &amdgpu_ttm_tt_populate,
> .ttm_tt_unpopulate = &amdgpu_ttm_tt_unpopulate,
> - .ttm_tt_bind = &amdgpu_ttm_backend_bind,
> .ttm_tt_destroy = &amdgpu_ttm_backend_destroy,
> .eviction_valuable = amdgpu_ttm_bo_eviction_valuable,
> .evict_flags = &amdgpu_evict_flags,
> diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
> index ad0493c5103b..a69bd4098984 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_bo.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
> @@ -1032,6 +1032,12 @@ nouveau_bo_move(struct ttm_buffer_object *bo, bool evict,
> struct nouveau_drm_tile *new_tile = NULL;
> int ret = 0;
>
> + if (new_reg->mem_type == TTM_PL_TT) {
> + ret = nouveau_ttm_tt_bind(bo->bdev, bo->ttm, new_reg);
> + if (ret)
> + return ret;
> + }
> +
> nouveau_bo_move_ntfy(bo, evict, new_reg);
> ret = ttm_bo_wait_ctx(bo, ctx);
> if (ret)
> @@ -1399,7 +1405,6 @@ struct ttm_bo_driver nouveau_bo_driver = {
> .ttm_tt_create = &nouveau_ttm_tt_create,
> .ttm_tt_populate = &nouveau_ttm_tt_populate,
> .ttm_tt_unpopulate = &nouveau_ttm_tt_unpopulate,
> - .ttm_tt_bind = &nouveau_ttm_tt_bind,
> .ttm_tt_destroy = &nouveau_ttm_tt_destroy,
> .eviction_valuable = ttm_bo_eviction_valuable,
> .evict_flags = nouveau_bo_evict_flags,
> diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
> index a6149e3cc3d2..1cc3c14bc684 100644
> --- a/drivers/gpu/drm/qxl/qxl_ttm.c
> +++ b/drivers/gpu/drm/qxl/qxl_ttm.c
> @@ -100,19 +100,6 @@ int qxl_ttm_io_mem_reserve(struct ttm_bo_device *bdev,
> /*
> * TTM backend functions.
> */
> -
> -static int qxl_ttm_backend_bind(struct ttm_bo_device *bdev,
> - struct ttm_tt *ttm,
> - struct ttm_resource *bo_mem)
> -{
> - if (!ttm->num_pages) {
> - WARN(1, "nothing to bind %lu pages for mreg %p back %p!\n",
> - ttm->num_pages, bo_mem, ttm);
> - }
> - /* Not implemented */
> - return -1;
> -}
> -
> static void qxl_ttm_backend_destroy(struct ttm_bo_device *bdev,
> struct ttm_tt *ttm)
> {
> @@ -181,7 +168,6 @@ static int qxl_bo_move(struct ttm_buffer_object *bo, bool evict,
>
> static struct ttm_bo_driver qxl_bo_driver = {
> .ttm_tt_create = &qxl_ttm_tt_create,
> - .ttm_tt_bind = &qxl_ttm_backend_bind,
> .ttm_tt_destroy = &qxl_ttm_backend_destroy,
> .eviction_valuable = ttm_bo_eviction_valuable,
> .evict_flags = &qxl_evict_flags,
> diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
> index e427194b0b50..ac916fdd54d1 100644
> --- a/drivers/gpu/drm/radeon/radeon_ttm.c
> +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
> @@ -311,6 +311,11 @@ static int radeon_bo_move(struct ttm_buffer_object *bo, bool evict,
> struct ttm_resource *old_mem = &bo->mem;
> int r;
>
> + if (new_mem->mem_type == TTM_PL_TT) {
> + r = radeon_ttm_tt_bind(bo->bdev, bo->ttm, new_mem);
> + if (r)
> + return r;
> + }
> radeon_bo_move_notify(bo, evict, new_mem);
>
> r = ttm_bo_wait_ctx(bo, ctx);
> @@ -823,7 +828,6 @@ static struct ttm_bo_driver radeon_bo_driver = {
> .ttm_tt_create = &radeon_ttm_tt_create,
> .ttm_tt_populate = &radeon_ttm_tt_populate,
> .ttm_tt_unpopulate = &radeon_ttm_tt_unpopulate,
> - .ttm_tt_bind = &radeon_ttm_tt_bind,
> .ttm_tt_destroy = &radeon_ttm_tt_destroy,
> .eviction_valuable = ttm_bo_eviction_valuable,
> .evict_flags = &radeon_evict_flags,
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> index e8ac3bc45d95..4b7fdb49df52 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -256,10 +256,6 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
> ret = ttm_tt_populate(bo->bdev, bo->ttm, ctx);
> if (ret)
> goto out_err;
> -
> - ret = bdev->driver->ttm_tt_bind(bo->bdev, bo->ttm, mem);
> - if (ret)
> - goto out_err;
> }
> }
>
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
> index fd82c9ba2d77..de25cf016be2 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
> @@ -737,6 +737,12 @@ static int vmw_move(struct ttm_buffer_object *bo,
> struct ttm_resource_manager *new_man = ttm_manager_type(bo->bdev, new_mem->mem_type);
> int ret;
>
> + if (new_man->use_tt && new_mem->mem_type != TTM_PL_SYSTEM) {
> + ret = vmw_ttm_bind(bo->bdev, bo->ttm, new_mem);
> + if (ret)
> + return ret;
> + }
> +
> vmw_move_notify(bo, evict, new_mem);
>
> if (old_man->use_tt && new_man->use_tt) {
> @@ -769,7 +775,6 @@ struct ttm_bo_driver vmw_bo_driver = {
> .ttm_tt_create = &vmw_ttm_tt_create,
> .ttm_tt_populate = &vmw_ttm_populate,
> .ttm_tt_unpopulate = &vmw_ttm_unpopulate,
> - .ttm_tt_bind = &vmw_ttm_bind,
> .ttm_tt_destroy = &vmw_ttm_destroy,
> .eviction_valuable = ttm_bo_eviction_valuable,
> .evict_flags = vmw_evict_flags,
> diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
> index 0c4efc169f46..72f106b335e9 100644
> --- a/include/drm/ttm/ttm_bo_driver.h
> +++ b/include/drm/ttm/ttm_bo_driver.h
> @@ -90,20 +90,6 @@ struct ttm_bo_driver {
> */
> void (*ttm_tt_unpopulate)(struct ttm_bo_device *bdev, struct ttm_tt *ttm);
>
> - /**
> - * ttm_tt_bind
> - *
> - * @bdev: Pointer to a ttm device
> - * @ttm: Pointer to a struct ttm_tt.
> - * @bo_mem: Pointer to a struct ttm_resource describing the
> - * memory type and location for binding.
> - *
> - * Bind the backend pages into the aperture in the location
> - * indicated by @bo_mem. This function should be able to handle
> - * differences between aperture and system page sizes.
> - */
> - int (*ttm_tt_bind)(struct ttm_bo_device *bdev, struct ttm_tt *ttm, struct ttm_resource *bo_mem);
> -
> /**
> * ttm_tt_destroy
> *
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 15+ messages in thread