[igt-dev] [PATCH i-g-t 2/2] lib/igt_fb: Don't leak the bufmgr and batch for converted surfaces
Ville Syrjala
ville.syrjala at linux.intel.com
Thu Mar 28 17:54:50 UTC 2019
From: Ville Syrjälä <ville.syrjala at linux.intel.com>
Remember to free the bufmgr and batch after the convert surface is
destroyed. We'll do that by sucking the relevant code into
free_linear_mapping(), and for the sake of symmetry we'll move
the setup code into setup_linear_mapping().
Cc: Dhinakaran Pandiyan <dhinakaran.pandiyan at intel.com>
Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
---
lib/igt_fb.c | 24 +++++++++++-------------
1 file changed, 11 insertions(+), 13 deletions(-)
diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index 8b6adf55a338..99766d2d08f9 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -1604,6 +1604,11 @@ static void free_linear_mapping(struct fb_blit_upload *blit)
gem_sync(fd, linear->fb.gem_handle);
gem_close(fd, linear->fb.gem_handle);
+
+ if (blit->batch) {
+ intel_batchbuffer_free(blit->batch);
+ drm_intel_bufmgr_destroy(blit->bufmgr);
+ }
}
static void destroy_cairo_surface__blit(void *arg)
@@ -1625,9 +1630,6 @@ static void destroy_cairo_surface__rendercopy(void *arg)
free_linear_mapping(blit);
- intel_batchbuffer_free(blit->batch);
- drm_intel_bufmgr_destroy(blit->bufmgr);
-
free(blit);
}
@@ -1637,6 +1639,12 @@ static void setup_linear_mapping(struct fb_blit_upload *blit)
struct igt_fb *fb = blit->fb;
struct fb_blit_linear *linear = &blit->linear;
+ if (use_rendercopy(fb)) {
+ blit->bufmgr = drm_intel_bufmgr_gem_init(fd, 4096);
+ blit->batch = intel_batchbuffer_alloc(blit->bufmgr,
+ intel_get_drm_devid(fd));
+ }
+
/*
* We create a linear BO that we'll map for the CPU to write to (using
* cairo). This linear bo will be then blitted to its final
@@ -1706,10 +1714,6 @@ static void create_cairo_surface__rendercopy(int fd, struct igt_fb *fb)
blit->fd = fd;
blit->fb = fb;
- blit->bufmgr = drm_intel_bufmgr_gem_init(fd, 4096);
- blit->batch = intel_batchbuffer_alloc(blit->bufmgr,
- intel_get_drm_devid(fd));
-
setup_linear_mapping(blit);
cairo_format = drm_format_to_cairo(fb->drm_format);
@@ -2525,12 +2529,6 @@ static void create_cairo_surface__convert(int fd, struct igt_fb *fb)
blit->base.fd = fd;
blit->base.fb = fb;
- if (use_rendercopy(fb)) {
- blit->base.bufmgr = drm_intel_bufmgr_gem_init(fd, 4096);
- blit->base.batch = intel_batchbuffer_alloc(blit->base.bufmgr,
- intel_get_drm_devid(fd));
- }
-
blit->shadow_ptr = igt_fb_create_cairo_shadow_buffer(fd, drm_format,
fb->width,
fb->height,
--
2.19.2
More information about the igt-dev
mailing list