From: Jerome Glisse Date: Mon, 28 Jan 2013 19:48:46 +0000 (-0500) Subject: r600g: fix segfault with old kernel X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=72916698b056d0559263e84372bb45cd83a1c2c2;p=mesa.git r600g: fix segfault with old kernel Old kernel do not have dma support, patch pushed were missing some of the check needed to not use dma. Signed-off-by: Jerome Glisse --- diff --git a/src/gallium/drivers/r600/evergreen_compute.c b/src/gallium/drivers/r600/evergreen_compute.c index f4a790585b1..128464e101a 100644 --- a/src/gallium/drivers/r600/evergreen_compute.c +++ b/src/gallium/drivers/r600/evergreen_compute.c @@ -321,7 +321,9 @@ static void compute_emit_cs(struct r600_context *ctx, const uint *block_layout, ctx->cs_shader_state.shader->resources; /* make sure that the gfx ring is only one active */ - ctx->rings.dma.flush(ctx, RADEON_FLUSH_ASYNC); + if (ctx->rings.dma.cs) { + ctx->rings.dma.flush(ctx, RADEON_FLUSH_ASYNC); + } /* Initialize all the compute-related registers. * diff --git a/src/gallium/drivers/r600/r600_pipe.c b/src/gallium/drivers/r600/r600_pipe.c index 676741255f5..a59578db9c4 100644 --- a/src/gallium/drivers/r600/r600_pipe.c +++ b/src/gallium/drivers/r600/r600_pipe.c @@ -151,7 +151,9 @@ static void r600_flush_from_st(struct pipe_context *ctx, *rfence = r600_create_fence(rctx); } /* flush gfx & dma ring, order does not matter as only one can be live */ - rctx->rings.dma.flush(rctx, fflags); + if (rctx->rings.dma.cs) { + rctx->rings.dma.flush(rctx, fflags); + } rctx->rings.gfx.flush(rctx, fflags); } @@ -179,8 +181,10 @@ boolean r600_rings_is_buffer_referenced(struct r600_context *ctx, if (ctx->ws->cs_is_buffer_referenced(ctx->rings.gfx.cs, buf, usage)) { return TRUE; } - if (ctx->ws->cs_is_buffer_referenced(ctx->rings.dma.cs, buf, usage)) { - return TRUE; + if (ctx->rings.dma.cs) { + if (ctx->ws->cs_is_buffer_referenced(ctx->rings.dma.cs, buf, usage)) { + return TRUE; + } } return FALSE; } @@ -211,10 +215,12 @@ void *r600_buffer_mmap_sync_with_rings(struct r600_context *ctx, return NULL; } } - if (ctx->ws->cs_is_buffer_referenced(ctx->rings.dma.cs, resource->cs_buf, rusage) && ctx->rings.dma.cs->cdw) { - ctx->rings.dma.flush(ctx, flags); - if (usage & PIPE_TRANSFER_DONTBLOCK) { - return NULL; + if (ctx->rings.dma.cs) { + if (ctx->ws->cs_is_buffer_referenced(ctx->rings.dma.cs, resource->cs_buf, rusage) && ctx->rings.dma.cs->cdw) { + ctx->rings.dma.flush(ctx, flags); + if (usage & PIPE_TRANSFER_DONTBLOCK) { + return NULL; + } } } diff --git a/src/gallium/drivers/r600/r600_pipe.h b/src/gallium/drivers/r600/r600_pipe.h index 31dcd057265..0f51eb2501f 100644 --- a/src/gallium/drivers/r600/r600_pipe.h +++ b/src/gallium/drivers/r600/r600_pipe.h @@ -869,7 +869,7 @@ static INLINE unsigned r600_context_bo_reloc(struct r600_context *ctx, * look serialized from driver pov */ if (!ring->flushing) { - if (ring == &ctx->rings.gfx) { + if (ring == &ctx->rings.gfx && ctx->rings.dma.cs) { /* flush dma ring */ ctx->rings.dma.flush(ctx, RADEON_FLUSH_ASYNC); } else { diff --git a/src/gallium/drivers/r600/r600_state_common.c b/src/gallium/drivers/r600/r600_state_common.c index b547d647cba..9386f618b3a 100644 --- a/src/gallium/drivers/r600/r600_state_common.c +++ b/src/gallium/drivers/r600/r600_state_common.c @@ -1274,7 +1274,9 @@ static void r600_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info } /* make sure that the gfx ring is only one active */ - rctx->rings.dma.flush(rctx, RADEON_FLUSH_ASYNC); + if (rctx->rings.dma.cs) { + rctx->rings.dma.flush(rctx, RADEON_FLUSH_ASYNC); + } if (!r600_update_derived_state(rctx)) { /* useless to render because current rendering command diff --git a/src/gallium/drivers/r600/r600_texture.c b/src/gallium/drivers/r600/r600_texture.c index 96c3729bc08..1d04cc06014 100644 --- a/src/gallium/drivers/r600/r600_texture.c +++ b/src/gallium/drivers/r600/r600_texture.c @@ -851,7 +851,9 @@ static void *r600_texture_transfer_map(struct pipe_context *ctx, if (usage & PIPE_TRANSFER_READ) { r600_copy_to_staging_texture(ctx, trans); /* flush gfx & dma ring, order does not matter as only one can be live */ - rctx->rings.dma.flush(rctx, 0); + if (rctx->rings.dma.cs) { + rctx->rings.dma.flush(rctx, 0); + } rctx->rings.gfx.flush(rctx, 0); } } else {