blob: 08f73ff8a20439bdec2e55ad3fa7cebc6388d495 [file] [log] [blame]
From 57c09646d2be2d1e333789706f19e2ebc10923f2 Mon Sep 17 00:00:00 2001
From: Rob Clark <robclark@freedesktop.org>
Date: Mon, 7 Mar 2016 18:19:11 -0800
Subject: [PATCH] CHROMIUM: freedreno: Fix renderbuffer destruction crash
Avoid crash on surface/sampler_view destruction when the context is
gone.
When we delete the context, sometimes there are pending surfaces and
sampler view left. Since mesa doesn't properly refcount them, the
context can go away before its resources. Until mesa is fixed to
properly refcount all these resources, let's just carry the destroy
function on the resource itself, which gives us a way to free it.
BUG=chromium:397801
TEST=boot reptile board to gui
Signed-off-by: Rob Clark <robdclark@gmail.com>
Signed-off-by: Prince Agyeman <prince.agyeman@intel.com>
Signed-off-by: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
Signed-off-by: James Ausmus <james.ausmus@intel.com>
Signed-off-by: Tomasz Figa <tfiga@chromium.org>
---
src/gallium/drivers/freedreno/a2xx/fd2_texture.c | 1 +
src/gallium/drivers/freedreno/a3xx/fd3_texture.c | 1 +
src/gallium/drivers/freedreno/a4xx/fd4_texture.c | 1 +
src/gallium/drivers/freedreno/freedreno_surface.c | 1 +
src/gallium/drivers/freedreno/freedreno_texture.c | 2 +-
src/gallium/drivers/freedreno/freedreno_texture.h | 3 +++
6 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/src/gallium/drivers/freedreno/a2xx/fd2_texture.c b/src/gallium/drivers/freedreno/a2xx/fd2_texture.c
index 6e4b5a5..8e7abf9 100644
--- a/src/gallium/drivers/freedreno/a2xx/fd2_texture.c
+++ b/src/gallium/drivers/freedreno/a2xx/fd2_texture.c
@@ -138,6 +138,7 @@ fd2_sampler_view_create(struct pipe_context *pctx, struct pipe_resource *prsc,
so->base.texture = prsc;
so->base.reference.count = 1;
so->base.context = pctx;
+ so->base.sampler_view_destroy = fd_sampler_view_destroy;
so->fmt = fd2_pipe2surface(cso->format);
diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_texture.c b/src/gallium/drivers/freedreno/a3xx/fd3_texture.c
index 9d54d41..355eed8 100644
--- a/src/gallium/drivers/freedreno/a3xx/fd3_texture.c
+++ b/src/gallium/drivers/freedreno/a3xx/fd3_texture.c
@@ -225,6 +225,7 @@ fd3_sampler_view_create(struct pipe_context *pctx, struct pipe_resource *prsc,
so->base.texture = prsc;
so->base.reference.count = 1;
so->base.context = pctx;
+ so->base.sampler_view_destroy = fd_sampler_view_destroy;
so->texconst0 =
A3XX_TEX_CONST_0_TYPE(tex_type(prsc->target)) |
diff --git a/src/gallium/drivers/freedreno/a4xx/fd4_texture.c b/src/gallium/drivers/freedreno/a4xx/fd4_texture.c
index 3834858..b11d510 100644
--- a/src/gallium/drivers/freedreno/a4xx/fd4_texture.c
+++ b/src/gallium/drivers/freedreno/a4xx/fd4_texture.c
@@ -226,6 +226,7 @@ fd4_sampler_view_create(struct pipe_context *pctx, struct pipe_resource *prsc,
so->base.texture = prsc;
so->base.reference.count = 1;
so->base.context = pctx;
+ so->base.sampler_view_destroy = fd_sampler_view_destroy;
so->texconst0 =
A4XX_TEX_CONST_0_TYPE(tex_type(cso->target)) |
diff --git a/src/gallium/drivers/freedreno/freedreno_surface.c b/src/gallium/drivers/freedreno/freedreno_surface.c
index 9043393..3efa1b6 100644
--- a/src/gallium/drivers/freedreno/freedreno_surface.c
+++ b/src/gallium/drivers/freedreno/freedreno_surface.c
@@ -54,6 +54,7 @@ fd_create_surface(struct pipe_context *pctx,
pipe_resource_reference(&psurf->texture, ptex);
psurf->context = pctx;
+ psurf->surface_destroy = fd_surface_destroy;
psurf->format = surf_tmpl->format;
psurf->width = u_minify(ptex->width0, level);
psurf->height = u_minify(ptex->height0, level);
diff --git a/src/gallium/drivers/freedreno/freedreno_texture.c b/src/gallium/drivers/freedreno/freedreno_texture.c
index f5611ab..4c2995f 100644
--- a/src/gallium/drivers/freedreno/freedreno_texture.c
+++ b/src/gallium/drivers/freedreno/freedreno_texture.c
@@ -41,7 +41,7 @@ fd_sampler_state_delete(struct pipe_context *pctx, void *hwcso)
FREE(hwcso);
}
-static void
+void
fd_sampler_view_destroy(struct pipe_context *pctx,
struct pipe_sampler_view *view)
{
diff --git a/src/gallium/drivers/freedreno/freedreno_texture.h b/src/gallium/drivers/freedreno/freedreno_texture.h
index fa27d1c..f296cb1 100644
--- a/src/gallium/drivers/freedreno/freedreno_texture.h
+++ b/src/gallium/drivers/freedreno/freedreno_texture.h
@@ -39,6 +39,9 @@ void fd_set_sampler_views(struct pipe_context *pctx, unsigned shader,
unsigned start, unsigned nr,
struct pipe_sampler_view **views);
+void fd_sampler_view_destroy(struct pipe_context *pctx,
+ struct pipe_sampler_view *view);
+
void fd_texture_init(struct pipe_context *pctx);
struct fd_texture_stateobj;
--
2.7.0.rc3.207.g0ac5344