Mesa (9.1): r600g: fix segfault with old kernel

Ian Romanick idr at kemper.freedesktop.org
Mon Jan 28 20:40:56 UTC 2013


Module: Mesa
Branch: 9.1
Commit: 72916698b056d0559263e84372bb45cd83a1c2c2
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=72916698b056d0559263e84372bb45cd83a1c2c2

Author: Jerome Glisse <jglisse at redhat.com>
Date:   Mon Jan 28 14:48:46 2013 -0500

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 <jglisse at redhat.com>

---

 src/gallium/drivers/r600/evergreen_compute.c |    4 +++-
 src/gallium/drivers/r600/r600_pipe.c         |   20 +++++++++++++-------
 src/gallium/drivers/r600/r600_pipe.h         |    2 +-
 src/gallium/drivers/r600/r600_state_common.c |    4 +++-
 src/gallium/drivers/r600/r600_texture.c      |    4 +++-
 5 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/src/gallium/drivers/r600/evergreen_compute.c b/src/gallium/drivers/r600/evergreen_compute.c
index f4a7905..128464e 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 6767412..a59578d 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 31dcd05..0f51eb2 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 b547d64..9386f61 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 96c3729..1d04cc0 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 {




More information about the mesa-commit mailing list