Skip to contentSkip to conversation

drm/ttm: stop destroying pinned ghost object

PATCH In review Christian König 2 participants 3 messages Dec 1, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/ttm: stop destroying pinned ghost object

Daniel added a warning for this, but we were abusing that behavior here.

Fixes 57fcd550eb15 ("drm/ttm: Warn on pinning without holding a reference")
---
 drivers/gpu/drm/ttm/ttm_bo_util.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/ttm/ttm_bo_util.c +3 -1
index 7ccb2295cac1..5bbc1339d28e 100644
@@ -310,7 +310,7 @@ static int ttm_buffer_object_transfer(struct ttm_buffer_object *bo,
 	kref_init(&fbo->base.kref);
 	fbo->base.destroy = &ttm_transfered_destroy;
 	fbo->base.acc_size = 0;
-	fbo->base.pin_count = 1;
+	fbo->base.pin_count = 0;
 	if (bo->type != ttm_bo_type_sg)
 		fbo->base.base.resv = &fbo->base.base._resv;
 
@@ -319,6 +319,8 @@ static int ttm_buffer_object_transfer(struct ttm_buffer_object *bo,
 	ret = dma_resv_trylock(&fbo->base.base._resv);
 	WARN_ON(!ret);
 
+	ttm_bo_move_to_lru_tail_unlocked(&fbo->base);
+
 	*new_obj = &fbo->base;
 	return 0;
 }
Signature · 6 lines
2.25.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Acked-by on v1 1/1
#1 lore raw
Quoted 14 lines · Christian König

Daniel added a warning for this, but we were abusing that behavior here.

Fixes 57fcd550eb15 ("drm/ttm: Warn on pinning without holding a reference")
---
 drivers/gpu/drm/ttm/ttm_bo_util.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/ttm/ttm_bo_util.c +0 -0
index 7ccb2295cac1..5bbc1339d28e 100644

drivers/gpu/drm/ttm/ttm_bo_util.c static int ttm_buffer_object_transfer(struct ttm_buffer_object *bo, · line 313

Quoted 5 lines
drivers/gpu/drm/ttm/ttm_bo_util.c +1 -1
@@ -310,7 +310,7 @@ static int ttm_buffer_object_transfer(struct ttm_buffer_object *bo,
        kref_init(&fbo->base.kref);
        fbo->base.destroy = &ttm_transfered_destroy;
        fbo->base.acc_size = 0;
-       fbo->base.pin_count = 1;
+       fbo->base.pin_count = 0;

Was this just to prevent lru reaping, and let the buffer deletion code clean up everything when it's all done? Just kinda freaking out that there's no unpin anywhere ...

Anyway tracking ghost objects with the lru like anything else instead of tricks with pin count sounds like a good idea.

But maybe ask Dave or Thomas for a second check.
-Daniel

Quoted 15 lines
drivers/gpu/drm/ttm/ttm_bo_util.c +2 -1
        if (bo->type != ttm_bo_type_sg)
                fbo->base.base.resv = &fbo->base.base._resv;
 
@@ -319,6 +319,8 @@ static int ttm_buffer_object_transfer(struct ttm_buffer_object *bo,
        ret = dma_resv_trylock(&fbo->base.base._resv);
        WARN_ON(!ret);
 
+       ttm_bo_move_to_lru_tail_unlocked(&fbo->base);
+
        *new_obj = &fbo->base;
        return 0;
 }
--

2.25.1

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#2 lore raw

Am 01.12.20 um 17:58 schrieb Daniel Vetter:

Quoted 10 lines
Quoted 8 lines · Christian König

Daniel added a warning for this, but we were abusing that behavior here.

Fixes 57fcd550eb15 ("drm/ttm: Warn on pinning without holding a reference")
---
  drivers/gpu/drm/ttm/ttm_bo_util.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
Quoted 13 lines

drivers/gpu/drm/ttm/ttm_bo_util.c static int ttm_buffer_object_transfer(struct ttm_buffer_object *bo, · line 313

Quoted 10 lines
drivers/gpu/drm/ttm/ttm_bo_util.c +1 -1
index 7ccb2295cac1..5bbc1339d28e 100644
@@ -310,7 +310,7 @@ static int ttm_buffer_object_transfer(struct ttm_buffer_object *bo,
         kref_init(&fbo->base.kref);
         fbo->base.destroy = &ttm_transfered_destroy;
         fbo->base.acc_size = 0;
-       fbo->base.pin_count = 1;
+       fbo->base.pin_count = 0;

Was this just to prevent lru reaping, and let the buffer deletion code clean up everything when it's all done? Just kinda freaking out that there's no unpin anywhere ...

Yeah, didn't realized how this works before either.

Quoted 2 lines

Anyway tracking ghost objects with the lru like anything else instead of tricks with pin count sounds like a good idea.

Well I really want to nuke ghost objects which would be an even better idea :)

Quoted 1 line

Thanks,
Christian.

Quoted 11 lines

But maybe ask Dave or Thomas for a second check.
-Daniel

Quoted 7 lines
drivers/gpu/drm/ttm/ttm_bo_util.c +0 -0
         if (bo->type != ttm_bo_type_sg)
                 fbo->base.base.resv = &fbo->base.base._resv;
 
@@ -319,6 +319,8 @@ static int ttm_buffer_object_transfer(struct ttm_buffer_object *bo,
         ret = dma_resv_trylock(&fbo->base.base._resv);
         WARN_ON(!ret);
 
Quoted 9 lines
Quoted 8 lines
drivers/gpu/drm/ttm/ttm_bo_util.c +2 -1
+       ttm_bo_move_to_lru_tail_unlocked(&fbo->base);
+
         *new_obj = &fbo->base;
         return 0;
  }
--

2.25.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel