xa: don't leak fences
authorRob Clark <robclark@freedesktop.org>
Wed, 8 Jul 2015 17:30:22 +0000 (13:30 -0400)
committerRob Clark <robclark@freedesktop.org>
Fri, 10 Jul 2015 15:57:30 +0000 (11:57 -0400)
XA was never unref'ing last_fence in the various call paths to
pipe->flush().  Add this to xa_context_flush() and update the other
open-coded calls to pipe->flush() to use xa_context_flush() instead.

This fixes a memory leak reported with xf86-video-freedreno.

Reported-by: Nicolas Dechesne <nicolas.dechesne@linaro.org>
Cc: "10.5 10.6" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Rob Clark <robclark@freedesktop.org>
src/gallium/state_trackers/xa/xa_context.c
src/gallium/state_trackers/xa/xa_tracker.c
src/gallium/state_trackers/xa/xa_yuv.c

index fd49c82a5595d6d0c22aa88d385cc64778c954af..ebfb290af13e32baa48e5ce25ef6b1d00c0ecc27 100644 (file)
 XA_EXPORT void
 xa_context_flush(struct xa_context *ctx)
 {
-       ctx->pipe->flush(ctx->pipe, &ctx->last_fence, 0);
+    if (ctx->last_fence) {
+        struct pipe_screen *screen = ctx->xa->screen;
+        screen->fence_reference(screen, &ctx->last_fence, NULL);
+    }
+    ctx->pipe->flush(ctx->pipe, &ctx->last_fence, 0);
 }
 
 XA_EXPORT struct xa_context *
index f69ac8edf2774a1dfd2d824d4a2ea6fc0c55ef4f..59e8108b1b58132f866f4469d8ed3f6bf6ebcbf7 100644 (file)
@@ -461,7 +461,7 @@ xa_surface_redefine(struct xa_surface *srf,
                        xa_min(save_height, template->height0), &src_box);
        pipe->resource_copy_region(pipe, texture,
                                   0, 0, 0, 0, srf->tex, 0, &src_box);
-       pipe->flush(pipe, &xa->default_ctx->last_fence, 0);
+       xa_context_flush(xa->default_ctx);
     }
 
     pipe_resource_reference(&srf->tex, texture);
index 15196392ac79b6981b569999ef2f04ed90d10e76..97a1833ff154e4818a22fbec032f9f3f0b9f31b4 100644 (file)
@@ -154,7 +154,7 @@ xa_yuv_planar_blit(struct xa_context *r,
        box++;
     }
 
-    r->pipe->flush(r->pipe, &r->last_fence, 0);
+    xa_context_flush(r);
 
     xa_ctx_sampler_views_destroy(r);
     xa_ctx_srf_destroy(r);