[PATCH] drm/vmwgfx: Make sure the dirty tracker is released on surfaces

Zack Rusin zack.rusin at broadcom.com
Tue Mar 4 18:49:42 UTC 2025


Free all the dirty trackers associated with the surface when the
parent framebuffer is destroyed.

The buffers backing framebuffers are explicitly made coherent. Code
separates buffers from surfaces. Buffers only require a dirty tracker
which is released during the framebuffer cleanup. Surfaces, which can
be coherent to begin with, require a dirty tracker in the backing buffer
and in the resource. Neither was properly cleaned up. Make sure they're
correctly cleaned up when the parent framebuffer is destroyed.

Fixes: 609023571ff2 ("drm/vmwgfx: Refactor cursor handling")
Cc: Broadcom internal kernel review list <bcm-kernel-feedback-list at broadcom.com>
Cc: dri-devel at lists.freedesktop.org
Signed-off-by: Zack Rusin <zack.rusin at broadcom.com>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
index d8937f3de514..339ed2ddb717 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
@@ -438,7 +438,20 @@ static void vmw_framebuffer_surface_destroy(struct drm_framebuffer *framebuffer)
 {
 	struct vmw_framebuffer_surface *vfbs =
 		vmw_framebuffer_to_vfbs(framebuffer);
+	struct vmw_bo *bo = vmw_user_object_buffer(&vfbs->uo);
+	struct vmw_surface *surf = vmw_user_object_surface(&vfbs->uo);
 
+	if (bo) {
+		vmw_bo_dirty_release(bo);
+		/*
+		 * bo->dirty is reference counted so it being NULL
+		 * means that the surface wasn't coherent to begin
+		 * with and so we have to free the dirty tracker
+		 * in the vmw_resource
+		 */
+		if (!bo->dirty && surf && surf->res.dirty)
+			surf->res.func->dirty_free(&surf->res);
+	}
 	drm_framebuffer_cleanup(framebuffer);
 	vmw_user_object_unref(&vfbs->uo);
 
-- 
2.45.2



More information about the dri-devel mailing list