From: Rob Clark Date: Sat, 11 Jan 2014 15:34:36 +0000 (-0500) Subject: freedreno: ctx should hold ref to dev X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4971628baedf885ba6987a2946c6e24526464125;p=mesa.git 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 --- diff --git a/src/gallium/drivers/freedreno/a2xx/fd2_context.c b/src/gallium/drivers/freedreno/a2xx/fd2_context.c index ec9eaf66417..239558b6f07 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 3732896d2a2..8273e9a1a77 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 a08b482fafb..0f0cf3104c5 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 2622006ff09..0886c495d89 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 370c8f69da6..33abb317045 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 0871efc53c7..0364d0f94c6 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 8afb9cd8380..9eb974451d1 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);