freedreno: ctx should hold ref to dev
authorRob Clark <robclark@freedesktop.org>
Sat, 11 Jan 2014 15:34:36 +0000 (10:34 -0500)
committerRob Clark <robclark@freedesktop.org>
Sat, 1 Feb 2014 16:47:08 +0000 (11:47 -0500)
The ctx should hold ref to dev to avoid problems if screen is destroyed
before ctx.  Doesn't really fix the egl/glx issues, but at least it
prevents things from getting much worse.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
src/gallium/drivers/freedreno/a2xx/fd2_context.c
src/gallium/drivers/freedreno/a3xx/fd3_context.c
src/gallium/drivers/freedreno/a3xx/fd3_gmem.c
src/gallium/drivers/freedreno/a3xx/fd3_program.c
src/gallium/drivers/freedreno/freedreno_context.c
src/gallium/drivers/freedreno/freedreno_context.h
src/gallium/winsys/freedreno/drm/freedreno_drm_winsys.c

index ec9eaf664177d86806873812e178903ff3fee2da..239558b6f07d6c8b05a357d3b0daa879c3e98da2 100644 (file)
@@ -98,6 +98,8 @@ fd2_context_create(struct pipe_screen *pscreen, void *priv)
 
        pctx = &fd2_ctx->base.base;
 
+       fd2_ctx->base.dev = fd_device_ref(screen->dev);
+
        pctx->destroy = fd2_context_destroy;
        pctx->create_blend_state = fd2_blend_state_create;
        pctx->create_rasterizer_state = fd2_rasterizer_state_create;
index 3732896d2a280cce473b4077228b828b7138a524..8273e9a1a77bf1343510f2be4c55cc2d0a53ac55 100644 (file)
@@ -105,6 +105,7 @@ fd3_context_create(struct pipe_screen *pscreen, void *priv)
 
        pctx = &fd3_ctx->base.base;
 
+       fd3_ctx->base.dev = fd_device_ref(screen->dev);
        fd3_ctx->base.screen = fd_screen(pscreen);
 
        pctx->destroy = fd3_context_destroy;
index a08b482fafb919e1ff89bd6c509d3eadadb42506..0f0cf3104c5a5661f89794e70123e5275c38bcdc 100644 (file)
@@ -609,7 +609,7 @@ update_vsc_pipe(struct fd_context *ctx)
                struct fd_vsc_pipe *pipe = &ctx->pipe[i];
 
                if (!pipe->bo) {
-                       pipe->bo = fd_bo_new(ctx->screen->dev, 0x40000,
+                       pipe->bo = fd_bo_new(ctx->dev, 0x40000,
                                        DRM_FREEDRENO_GEM_TYPE_KMEM);
                }
 
index 2622006ff0914dc015c080e281905c67525f7922..0886c495d896bd0f0d1d565496a1849ac4cbdc89 100644 (file)
@@ -57,7 +57,7 @@ assemble_shader(struct pipe_context *pctx, struct fd3_shader_stateobj *so)
        bin = ir3_shader_assemble(so->ir, &so->info);
        sz = so->info.sizedwords * 4;
 
-       so->bo = fd_bo_new(ctx->screen->dev, sz,
+       so->bo = fd_bo_new(ctx->dev, sz,
                        DRM_FREEDRENO_GEM_CACHE_WCOMBINE |
                        DRM_FREEDRENO_GEM_TYPE_KMEM);
 
index 370c8f69da6a6dc123012002bdc226d19efe246b..33abb317045bc22fb2d1c5a6468c52b7758eb885 100644 (file)
@@ -168,6 +168,8 @@ fd_context_destroy(struct pipe_context *pctx)
                fd_bo_del(pipe->bo);
        }
 
+       fd_device_del(ctx->dev);
+
        FREE(ctx);
 }
 
index 0871efc53c759f03477481b791e72984cf81f8a7..0364d0f94c61cb50902df47815db3bf1b481ec54 100644 (file)
@@ -85,6 +85,7 @@ struct fd_vertex_stateobj {
 struct fd_context {
        struct pipe_context base;
 
+       struct fd_device *dev;
        struct fd_screen *screen;
        struct blitter_context *blitter;
        struct primconvert_context *primconvert;
index 8afb9cd8380c7f4f9302c8af48adf636615f720d..9eb974451d1244cfec117c37b19aa998b82ca45d 100644 (file)
@@ -11,7 +11,7 @@
 struct pipe_screen *
 fd_drm_screen_create(int fd)
 {
-       struct fd_device *dev = fd_device_new(fd);
+       struct fd_device *dev = fd_device_new_dup(fd);
        if (!dev)
                return NULL;
        return fd_screen_create(dev);