From 4971628baedf885ba6987a2946c6e24526464125 Mon Sep 17 00:00:00 2001 From: Rob Clark Date: Sat, 11 Jan 2014 10:34:36 -0500 Subject: freedreno: ctx should hold ref to dev 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 --- src/gallium/drivers/freedreno/a2xx/fd2_context.c | 2 ++ src/gallium/drivers/freedreno/a3xx/fd3_context.c | 1 + src/gallium/drivers/freedreno/a3xx/fd3_gmem.c | 2 +- src/gallium/drivers/freedreno/a3xx/fd3_program.c | 2 +- src/gallium/drivers/freedreno/freedreno_context.c | 2 ++ src/gallium/drivers/freedreno/freedreno_context.h | 1 + src/gallium/winsys/freedreno/drm/freedreno_drm_winsys.c | 2 +- 7 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/freedreno/a2xx/fd2_context.c b/src/gallium/drivers/freedreno/a2xx/fd2_context.c index ec9eaf6..239558b 100644 --- a/src/gallium/drivers/freedreno/a2xx/fd2_context.c +++ b/src/gallium/drivers/freedreno/a2xx/fd2_context.c @@ -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; diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_context.c b/src/gallium/drivers/freedreno/a3xx/fd3_context.c index 3732896..8273e9a 100644 --- a/src/gallium/drivers/freedreno/a3xx/fd3_context.c +++ b/src/gallium/drivers/freedreno/a3xx/fd3_context.c @@ -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; diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_gmem.c b/src/gallium/drivers/freedreno/a3xx/fd3_gmem.c index a08b482..0f0cf31 100644 --- a/src/gallium/drivers/freedreno/a3xx/fd3_gmem.c +++ b/src/gallium/drivers/freedreno/a3xx/fd3_gmem.c @@ -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); } diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_program.c b/src/gallium/drivers/freedreno/a3xx/fd3_program.c index 2622006..0886c49 100644 --- a/src/gallium/drivers/freedreno/a3xx/fd3_program.c +++ b/src/gallium/drivers/freedreno/a3xx/fd3_program.c @@ -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); diff --git a/src/gallium/drivers/freedreno/freedreno_context.c b/src/gallium/drivers/freedreno/freedreno_context.c index 370c8f6..33abb31 100644 --- a/src/gallium/drivers/freedreno/freedreno_context.c +++ b/src/gallium/drivers/freedreno/freedreno_context.c @@ -168,6 +168,8 @@ fd_context_destroy(struct pipe_context *pctx) fd_bo_del(pipe->bo); } + fd_device_del(ctx->dev); + FREE(ctx); } diff --git a/src/gallium/drivers/freedreno/freedreno_context.h b/src/gallium/drivers/freedreno/freedreno_context.h index 0871efc..0364d0f 100644 --- a/src/gallium/drivers/freedreno/freedreno_context.h +++ b/src/gallium/drivers/freedreno/freedreno_context.h @@ -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; diff --git a/src/gallium/winsys/freedreno/drm/freedreno_drm_winsys.c b/src/gallium/winsys/freedreno/drm/freedreno_drm_winsys.c index 8afb9cd..9eb9744 100644 --- a/src/gallium/winsys/freedreno/drm/freedreno_drm_winsys.c +++ b/src/gallium/winsys/freedreno/drm/freedreno_drm_winsys.c @@ -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); -- cgit v1.1