r600g: fix segfault with old kernel
authorJerome Glisse <jglisse@redhat.com>
Mon, 28 Jan 2013 19:48:46 +0000 (14:48 -0500)
committerJerome Glisse <jglisse@redhat.com>
Mon, 28 Jan 2013 19:51:40 +0000 (14:51 -0500)
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@redhat.com>
src/gallium/drivers/r600/evergreen_compute.c
src/gallium/drivers/r600/r600_pipe.c
src/gallium/drivers/r600/r600_pipe.h
src/gallium/drivers/r600/r600_state_common.c
src/gallium/drivers/r600/r600_texture.c

index f4a790585b1139b7686973a4363359ea5a606786..128464e101ac1a936104557722360934ae1a8282 100644 (file)
@@ -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.
         *
index 676741255f56b45f5ca902d88385f61a1fbd8f7c..a59578db9c49fc504e41590f5d9b8c33114d2c7e 100644 (file)
@@ -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;
+                       }
                }
        }
 
index 31dcd057265fef1ef3e5d5cc938bc6675ccd83d4..0f51eb2501fcad58daf264aaa73d1665487bc23e 100644 (file)
@@ -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 {
index b547d647cba1492b1b5c9036dde2f40b61d73d2f..9386f618b3aaf6d2bd5bc310eb9bb3960ddc672d 100644 (file)
@@ -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
index 96c3729bc089034c9cd956ca1273e2add74a173c..1d04cc06014a1dced9c0f3a1d90a731dc110bb73 100644 (file)
@@ -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 {