renderonly: drop resources on destroy
authorPhilipp Zabel <p.zabel@pengutronix.de>
Thu, 27 Apr 2017 16:44:02 +0000 (18:44 +0200)
committerChristian Gmeiner <christian.gmeiner@gmail.com>
Tue, 2 May 2017 20:19:23 +0000 (22:19 +0200)
The renderonly_scanout holds a reference on its prime pipe resource,
which should be released when it is destroyed. If it was created by
renderonly_create_kms_dumb_buffer_for_resource, the dumb BO also has
to be destroyed.

Fixes: 848b49b288f ("gallium: add renderonly library")
CC: <mesa-stable@lists.freedesktop.org>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
src/gallium/auxiliary/renderonly/renderonly.c
src/gallium/auxiliary/renderonly/renderonly.h
src/gallium/drivers/etnaviv/etnaviv_resource.c

index e17c32886d2883bdc668058b5525d2425fc29328..f377c368e57e6c0ac982d1f233193010e7305153 100644 (file)
@@ -34,6 +34,7 @@
 
 #include "state_tracker/drm_driver.h"
 #include "pipe/p_screen.h"
+#include "util/u_inlines.h"
 #include "util/u_memory.h"
 
 struct renderonly *
@@ -65,8 +66,16 @@ renderonly_scanout_for_prime(struct pipe_resource *rsc, struct renderonly *ro)
 }
 
 void
-renderonly_scanout_destroy(struct renderonly_scanout *scanout)
+renderonly_scanout_destroy(struct renderonly_scanout *scanout,
+                          struct renderonly *ro)
 {
+   struct drm_mode_destroy_dumb destroy_dumb = { };
+
+   pipe_resource_reference(&scanout->prime, NULL);
+   if (ro->kms_fd != -1) {
+      destroy_dumb.handle = scanout->handle;
+      ioctl(ro->kms_fd, DRM_IOCTL_MODE_DESTROY_DUMB, &destroy_dumb);
+   }
    FREE(scanout);
 }
 
index 28989f202d9c028215f1dde011263fdadd0bba98..d54307329824c1547869fd4dd697b3f72497ff29 100644 (file)
@@ -77,7 +77,8 @@ struct renderonly_scanout *
 renderonly_scanout_for_prime(struct pipe_resource *rsc, struct renderonly *ro);
 
 void
-renderonly_scanout_destroy(struct renderonly_scanout *scanout);
+renderonly_scanout_destroy(struct renderonly_scanout *scanout,
+                          struct renderonly *ro);
 
 static inline boolean
 renderonly_get_handle(struct renderonly_scanout *scanout,
index 2c5e9298e55022a326a224103cbd6127b9830349..0e37345c0c0a576a01c20f166407b3a0f22213b6 100644 (file)
@@ -305,7 +305,7 @@ etna_resource_destroy(struct pipe_screen *pscreen, struct pipe_resource *prsc)
       etna_bo_del(rsc->ts_bo);
 
    if (rsc->scanout)
-      renderonly_scanout_destroy(rsc->scanout);
+      renderonly_scanout_destroy(rsc->scanout, etna_screen(pscreen)->ro);
 
    list_delinit(&rsc->list);