Skip to contentSkip to conversation

drm/ttm: fix leaking fences via ttm_buffer_object_transfer

PATCH In review Alex Deucher 4 participants 7 messages Feb 25, 2020 – Feb 26, 2020

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

PATCH 1/1 drm/ttm: fix leaking fences via ttm_buffer_object_transfer

From: Ahzo <[email protected]>

Set the drm_device to NULL, so that the newly created buffer object doesn't appear to use the embedded gem object.

This is necessary, because otherwise no corresponding dma_resv_fini for the dma_resv_init is called, resulting in a memory leak.

The dma_resv_fini in ttm_bo_release_list is only called if the embedded gem object is not used, which is determined by checking if the drm_device is NULL.

Fixes 1e053b10ba60 ("drm/ttm: use gem reservation object")
---
 drivers/gpu/drm/ttm/ttm_bo_util.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/ttm/ttm_bo_util.c +1 -0
index c8e359ded1df..44c1e7adfb7c 100644
@@ -514,6 +514,7 @@ static int ttm_buffer_object_transfer(struct ttm_buffer_object *bo,
 		fbo->base.base.resv = &fbo->base.base._resv;
 
 	dma_resv_init(&fbo->base.base._resv);
+	fbo->base.base.dev = NULL;
 	ret = dma_resv_trylock(&fbo->base.base._resv);
 	WARN_ON(!ret);
 
Signature · 6 lines
2.24.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Reviewed-by on v1 1/1
#1 lore raw

Am 25.02.20 um 19:56 schrieb Alex Deucher:

Quoted 8 lines

From: Ahzo <[email protected]>

Set the drm_device to NULL, so that the newly created buffer object doesn't appear to use the embedded gem object.

This is necessary, because otherwise no corresponding dma_resv_fini for the dma_resv_init is called, resulting in a memory leak.

Quoted 8 lines

The dma_resv_fini in ttm_bo_release_list is only called if the embedded gem object is not used, which is determined by checking if the drm_device is NULL.

Fixes 1e053b10ba60 ("drm/ttm: use gem reservation object")

Good catch I was trying to hunt that one down as well.

Quoted 9 lines
---
  drivers/gpu/drm/ttm/ttm_bo_util.c | 1 +
  1 file changed, 1 insertion(+)
drivers/gpu/drm/ttm/ttm_bo_util.c +0 -0
index c8e359ded1df..44c1e7adfb7c 100644

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

Quoted 7 lines
drivers/gpu/drm/ttm/ttm_bo_util.c +1 -0
@@ -514,6 +514,7 @@ static int ttm_buffer_object_transfer(struct ttm_buffer_object *bo,
  		fbo->base.base.resv = &fbo->base.base._resv;
 
  	dma_resv_init(&fbo->base.base._resv);
+	fbo->base.base.dev = NULL;
  	ret = dma_resv_trylock(&fbo->base.base._resv);
  	WARN_ON(!ret);
 

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

#2 lore raw
Quoted 14 lines · Christian König

Am 25.02.20 um 19:56 schrieb Alex Deucher:

Quoted 12 lines

From: Ahzo <[email protected]>

Set the drm_device to NULL, so that the newly created buffer object doesn't appear to use the embedded gem object.

This is necessary, because otherwise no corresponding dma_resv_fini for the dma_resv_init is called, resulting in a memory leak.

The dma_resv_fini in ttm_bo_release_list is only called if the embedded gem object is not used, which is determined by checking if the drm_device is NULL.

Quoted 8 lines
Quoted 4 lines
Fixes 1e053b10ba60 ("drm/ttm: use gem reservation object")

Good catch I was trying to hunt that one down as well.

Can you apply it to drm-misc?

Thanks,

Alex

Quoted 12 lines
Quoted 12 lines
---
  drivers/gpu/drm/ttm/ttm_bo_util.c | 1 +
  1 file changed, 1 insertion(+)
drivers/gpu/drm/ttm/ttm_bo_util.c +0 -0
index c8e359ded1df..44c1e7adfb7c 100644
@@ -514,6 +514,7 @@ static int ttm_buffer_object_transfer(struct ttm_buffer_object *bo,
              fbo->base.base.resv = &fbo->base.base._resv;
 
Quoted 6 lines

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

Quoted 5 lines
drivers/gpu/drm/ttm/ttm_bo_util.c +1 -0
      dma_resv_init(&fbo->base.base._resv);
+     fbo->base.base.dev = NULL;
      ret = dma_resv_trylock(&fbo->base.base._resv);
      WARN_ON(!ret);
 

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

#3 lore raw

Am 25.02.20 um 20:11 schrieb Alex Deucher:

Quoted 15 lines
Quoted 13 lines · Christian König

Am 25.02.20 um 19:56 schrieb Alex Deucher:

Quoted 12 lines

From: Ahzo <[email protected]>

Set the drm_device to NULL, so that the newly created buffer object doesn't appear to use the embedded gem object.

This is necessary, because otherwise no corresponding dma_resv_fini for the dma_resv_init is called, resulting in a memory leak.

The dma_resv_fini in ttm_bo_release_list is only called if the embedded gem object is not used, which is determined by checking if the drm_device is NULL.

Quoted 8 lines
Quoted 7 lines
Quoted 4 lines

Good catch I was trying to hunt that one down as well.

Can you apply it to drm-misc?

Sure, but not today. Need to get the kids to bed.

Christian.

Quoted 16 lines

Thanks,

Alex

Quoted 11 lines
Quoted 11 lines
---
   drivers/gpu/drm/ttm/ttm_bo_util.c | 1 +
   1 file changed, 1 insertion(+)
drivers/gpu/drm/ttm/ttm_bo_util.c +0 -0
index c8e359ded1df..44c1e7adfb7c 100644
@@ -514,6 +514,7 @@ static int ttm_buffer_object_transfer(struct ttm_buffer_object *bo,
               fbo->base.base.resv = &fbo->base.base._resv;
 
Quoted 5 lines
Quoted 5 lines

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

Quoted 5 lines
drivers/gpu/drm/ttm/ttm_bo_util.c +1 -0
       dma_resv_init(&fbo->base.base._resv);
+     fbo->base.base.dev = NULL;
       ret = dma_resv_trylock(&fbo->base.base._resv);
       WARN_ON(!ret);
 

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

#4 lore raw

Am 25.02.20 um 20:12 schrieb Christian König:

Quoted 20 lines

Am 25.02.20 um 20:11 schrieb Alex Deucher:

Quoted 19 lines
Quoted 17 lines · Christian König

Am 25.02.20 um 19:56 schrieb Alex Deucher:

Quoted 16 lines

From: Ahzo <[email protected]>

Set the drm_device to NULL, so that the newly created buffer object doesn't appear to use the embedded gem object.

This is necessary, because otherwise no corresponding dma_resv_fini for the dma_resv_init is called, resulting in a memory leak.

The dma_resv_fini in ttm_bo_release_list is only called if the embedded gem object is not used, which is determined by checking if the drm_device is NULL.

Quoted 6 lines
Quoted 4 lines
Quoted 3 lines

Good catch I was trying to hunt that one down as well.

Can you apply it to drm-misc?

Sure, but not today. Need to get the kids to bed.

So just pushed to drm-misc-fixes. Do we also need that on amd-staging-drm-next?

Christian.

Quoted 20 lines

Christian.

Quoted 17 lines

Thanks,

Alex

Quoted 12 lines
Quoted 12 lines

---
   drivers/gpu/drm/ttm/ttm_bo_util.c | 1 +

   1 file changed, 1 insertion(+)
drivers/gpu/drm/ttm/ttm_bo_util.c +0 -0
index c8e359ded1df..44c1e7adfb7c 100644
@@ -514,6 +514,7 @@ static int ttm_buffer_object_transfer(struct 
 ttm_buffer_object *bo,
                fbo->base.base.resv = &fbo->base.base._resv;
 
Quoted 10 lines
Quoted 5 lines
Quoted 5 lines

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

Quoted 5 lines
drivers/gpu/drm/ttm/ttm_bo_util.c +1 -0
        dma_resv_init(&fbo->base.base._resv);
+     fbo->base.base.dev = NULL;
        ret = dma_resv_trylock(&fbo->base.base._resv);
        WARN_ON(!ret);

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

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

#5 lore raw
Quoted 27 lines · Christian König

Am 25.02.20 um 20:12 schrieb Christian König:

Quoted 25 lines

Am 25.02.20 um 20:11 schrieb Alex Deucher:

Quoted 24 lines
Quoted 22 lines · Christian König

Am 25.02.20 um 19:56 schrieb Alex Deucher:

Quoted 14 lines

From: Ahzo <[email protected]>

Set the drm_device to NULL, so that the newly created buffer object doesn't appear to use the embedded gem object.

This is necessary, because otherwise no corresponding dma_resv_fini for
the dma_resv_init is called, resulting in a memory leak.

The dma_resv_fini in ttm_bo_release_list is only called if the embedded
gem object is not used, which is determined by checking if the drm_device is NULL.

Quoted 5 lines

Bug:
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgitlab.freedesktop.org%2Fdrm%2Famd%2Fissues%2F958&amp;data=02%7C01%7Cchristian.koenig%40amd.com%7Caa3f774da03e4dfcc09a08d7ba268305%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637182546879144030&amp;sdata=N8WxYZZRj5obMU5SLv0giog0a1sCYi%2FouxSuWNom0gw%3D&amp;reserved=0

Fixes 1e053b10ba60 ("drm/ttm: use gem reservation object")

Good catch I was trying to hunt that one down as well.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Quoted 1 line

Can you apply it to drm-misc?

Sure, but not today. Need to get the kids to bed.

So just pushed to drm-misc-fixes. Do we also need that on amd-staging-drm-next?

Backmerge -rc4 (once it's released) probably a good idea. Or cherry-pick with a note why you needed it real quick. -Daniel

Quoted 39 lines

Christian.

Quoted 21 lines

Christian.

Quoted 18 lines

Thanks,

Alex

Quoted 13 lines
Quoted 13 lines
---
   drivers/gpu/drm/ttm/ttm_bo_util.c | 1 +
   1 file changed, 1 insertion(+)
drivers/gpu/drm/ttm/ttm_bo_util.c +0 -0
index c8e359ded1df..44c1e7adfb7c 100644
@@ -514,6 +514,7 @@ static int ttm_buffer_object_transfer(struct
 ttm_buffer_object *bo,
               fbo->base.base.resv = &fbo->base.base._resv;
 
Quoted 10 lines
Quoted 5 lines
Quoted 5 lines

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

Quoted 5 lines
drivers/gpu/drm/ttm/ttm_bo_util.c +1 -0
       dma_resv_init(&fbo->base.base._resv);
+     fbo->base.base.dev = NULL;
       ret = dma_resv_trylock(&fbo->base.base._resv);
       WARN_ON(!ret);

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

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

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#6 lore raw
In reply to Christian König
Quoted 27 lines · Christian König

Am 25.02.20 um 20:12 schrieb Christian König:

Quoted 25 lines

Am 25.02.20 um 20:11 schrieb Alex Deucher:

Quoted 24 lines
Quoted 22 lines · Christian König

Am 25.02.20 um 19:56 schrieb Alex Deucher:

Quoted 14 lines

From: Ahzo <[email protected]>

Set the drm_device to NULL, so that the newly created buffer object doesn't appear to use the embedded gem object.

This is necessary, because otherwise no corresponding dma_resv_fini for
the dma_resv_init is called, resulting in a memory leak.

The dma_resv_fini in ttm_bo_release_list is only called if the embedded
gem object is not used, which is determined by checking if the drm_device is NULL.

Quoted 5 lines

Bug:
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgitlab.freedesktop.org%2Fdrm%2Famd%2Fissues%2F958&amp;data=02%7C01%7Cchristian.koenig%40amd.com%7Caa3f774da03e4dfcc09a08d7ba268305%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637182546879144030&amp;sdata=N8WxYZZRj5obMU5SLv0giog0a1sCYi%2FouxSuWNom0gw%3D&amp;reserved=0

Fixes 1e053b10ba60 ("drm/ttm: use gem reservation object")

Good catch I was trying to hunt that one down as well.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Quoted 1 line

Can you apply it to drm-misc?

Sure, but not today. Need to get the kids to bed.

So just pushed to drm-misc-fixes. Do we also need that on amd-staging-drm-next?

Sure.

Alex

Quoted 35 lines

Christian.

Quoted 31 lines

Christian.

Quoted 18 lines

Thanks,

Alex

Quoted 13 lines
Quoted 13 lines
---
   drivers/gpu/drm/ttm/ttm_bo_util.c | 1 +
   1 file changed, 1 insertion(+)
drivers/gpu/drm/ttm/ttm_bo_util.c +0 -0
index c8e359ded1df..44c1e7adfb7c 100644
@@ -514,6 +514,7 @@ static int ttm_buffer_object_transfer(struct
 ttm_buffer_object *bo,
               fbo->base.base.resv = &fbo->base.base._resv;
 
Quoted 5 lines
Quoted 5 lines

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

Quoted 5 lines
drivers/gpu/drm/ttm/ttm_bo_util.c +1 -0
       dma_resv_init(&fbo->base.base._resv);
+     fbo->base.base.dev = NULL;
       ret = dma_resv_trylock(&fbo->base.base._resv);
       WARN_ON(!ret);

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

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