Commit 9eba1e92 authored by Philipp Zabel's avatar Philipp Zabel Committed by Andres Gomez

renderonly: drop resources on destroy

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: 848b49b2 ("gallium: add renderonly library")
CC: <mesa-stable@lists.freedesktop.org>
Signed-off-by: Philipp Zabel's avatarPhilipp Zabel <p.zabel@pengutronix.de>
Reviewed-by: Emil Velikov's avatarEmil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Christian Gmeiner's avatarChristian Gmeiner <christian.gmeiner@gmail.com>
(cherry picked from commit cd8ee259)
parent 937376e4
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include "state_tracker/drm_driver.h" #include "state_tracker/drm_driver.h"
#include "pipe/p_screen.h" #include "pipe/p_screen.h"
#include "util/u_inlines.h"
#include "util/u_memory.h" #include "util/u_memory.h"
struct renderonly * struct renderonly *
...@@ -65,8 +66,16 @@ renderonly_scanout_for_prime(struct pipe_resource *rsc, struct renderonly *ro) ...@@ -65,8 +66,16 @@ renderonly_scanout_for_prime(struct pipe_resource *rsc, struct renderonly *ro)
} }
void 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); FREE(scanout);
} }
......
...@@ -77,7 +77,8 @@ struct renderonly_scanout * ...@@ -77,7 +77,8 @@ struct renderonly_scanout *
renderonly_scanout_for_prime(struct pipe_resource *rsc, struct renderonly *ro); renderonly_scanout_for_prime(struct pipe_resource *rsc, struct renderonly *ro);
void void
renderonly_scanout_destroy(struct renderonly_scanout *scanout); renderonly_scanout_destroy(struct renderonly_scanout *scanout,
struct renderonly *ro);
static inline boolean static inline boolean
renderonly_get_handle(struct renderonly_scanout *scanout, renderonly_get_handle(struct renderonly_scanout *scanout,
......
...@@ -289,7 +289,7 @@ etna_resource_destroy(struct pipe_screen *pscreen, struct pipe_resource *prsc) ...@@ -289,7 +289,7 @@ etna_resource_destroy(struct pipe_screen *pscreen, struct pipe_resource *prsc)
etna_bo_del(rsc->ts_bo); etna_bo_del(rsc->ts_bo);
if (rsc->scanout) if (rsc->scanout)
renderonly_scanout_destroy(rsc->scanout); renderonly_scanout_destroy(rsc->scanout, etna_screen(pscreen)->ro);
list_delinit(&rsc->list); list_delinit(&rsc->list);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment