drm/vmwgfx: Fix dumb buffer leak
Subsystems (3)
PATCH 1/1 drm/vmwgfx: Fix dumb buffer leak
--- drivers/gpu/drm/vmwgfx/vmwgfx_bo.c | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_surface.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/vmwgfx/vmwgfx_bo.c +1 -1
@@ -73,7 +73,7 @@ static void vmw_bo_free(struct ttm_buffer_object *bo) {struct vmw_bo *vbo =to_vmw_bo (&bo->base); -WARN_ON (vbo->dirty); +WARN_ON (vbo->dirty && !vbo->is_dumb);WARN_ON (!RB_EMPTY_ROOT (&vbo->res_tree));vmw_bo_release (vbo);kfree (vbo);
drivers/gpu/drm/vmwgfx/vmwgfx_surface.c +1 -0
@@ -2358,6 +2358,7 @@ int vmw_dumb_create(struct drm_file *file_priv, vbo = res->guest_memory_bo; vbo->is_dumb = true; vbo->dumb_surface =vmw_res_to_srf (res); +drm_gem_object_put (&vbo->tbo.base); err:if (res)
Signature · 1 line
2.34.1
Zack Rusin
maintainerQuoted 34 lines · Ian Forbes
Fixes d6667f0ddf46 ("drm/vmwgfx: Fix handling of dumb buffers")Signed-off-by Ian Forbes <[email protected]>--- drivers/gpu/drm/vmwgfx/vmwgfx_bo.c | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_surface.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)drivers/gpu/drm/vmwgfx/vmwgfx_bo.c +1
-1@@ -73,7 +73,7 @@ static void vmw_bo_free(struct ttm_buffer_object *bo) {struct vmw_bo *vbo =to_vmw_bo (&bo->base); -WARN_ON (vbo->dirty); +WARN_ON (vbo->dirty && !vbo->is_dumb);WARN_ON (!RB_EMPTY_ROOT (&vbo->res_tree));vmw_bo_release (vbo);kfree (vbo);drivers/gpu/drm/vmwgfx/vmwgfx_surface.c +1
-1@@ -2358,6 +2358,7 @@ int vmw_dumb_create(struct drm_file *file_priv, vbo = res->guest_memory_bo; vbo->is_dumb = true; vbo->dumb_surface =vmw_res_to_srf (res); +drm_gem_object_put (&vbo->tbo.base); err:if (res) --
Quoted 2 lines
2.34.1
You're going to have to explain that one in the commit message a lot better because as is it doesn't make sense to me. Especially the !vbo->is_dumb in vmw_bo_free.
z
Quoted 6 lines · Zack Rusin
You're going to have to explain that one in the commit message a lot better because as is it doesn't make sense to me. Especially the !vbo->is_dumb in
vmw_bo_free.z
The dirty tracker is freed later in vmw_bo_release when it's a coherent dumb_buffer.
Alternatively I can move the WARN_ON below vmw_bo_release and remove the is_dumb check.
Zack Rusin
maintainerQuoted 11 lines · Ian Forbes
Quoted 6 lines · Zack Rusin
You're going to have to explain that one in the commit message a lot better because as is it doesn't make sense to me. Especially the !vbo->is_dumb in
vmw_bo_free.z
The dirty tracker is freed later in
vmw_bo_releasewhen it's a coherentdumb_buffer.
Ah, that makes sense. If you could improve the commit message that'd be great (just describe both issues. i.e. the buffer handle being allocated via vmw_gem_object_create_with_handle which create a gem handle that holds the reference and the dirty being explicitly freed for dumb buffers in vmw_bo_release).
If you don't have anything too important on your plate right now maybe you could try to come up with some way of testing the creation/destruction of buffers matches. IGT could technically use the debugfs file that Maaz added that should contain all the buffer stats. Even for the above change it'd be a lot nicer if you could just add to the commit message the debugfs output before and after this change while running gnome or kde that shows the leak has been fixed.
z
Quoted 16 lines · Zack Rusin
Ah, that makes sense. If you could improve the commit message that'd be great (just describe both issues. i.e. the buffer handle being allocated via
vmw_gem_object_create_with_handlewhich create a gem handle that holds the reference and the dirty being explicitly freed for dumb buffers invmw_bo_release).If you don't have anything too important on your plate right now maybe you could try to come up with some way of testing the creation/destruction of buffers matches. IGT could technically use the debugfs file that Maaz added that should contain all the buffer stats. Even for the above change it'd be a lot nicer if you could just add to the commit message the debugfs output before and after this change while running gnome or kde that shows the leak has been fixed.
Quoted 1 line
z
The total number of BOs in use is exposed through /sys/kernel/debug/ttm/buffer_objects.
After shutting down the GUI it should always be 11 for the otable and fbdev allocations.