OSDN Git Service

radeonsi: stop command submission with PIPE_CONTEXT_LOSE_CONTEXT_ON_RESET only
authorMarek Olšák <marek.olsak@amd.com>
Fri, 2 Nov 2018 20:09:13 +0000 (16:09 -0400)
committerMarek Olšák <marek.olsak@amd.com>
Fri, 9 Nov 2018 19:55:04 +0000 (14:55 -0500)
Tested-by: Dieter Nützel <Dieter@nuetzel-hh.de>
15 files changed:
src/gallium/drivers/r300/r300_context.c
src/gallium/drivers/r600/r600_pipe.c
src/gallium/drivers/r600/r600_pipe_common.c
src/gallium/drivers/r600/radeon_uvd.c
src/gallium/drivers/r600/radeon_vce.c
src/gallium/drivers/radeon/radeon_uvd.c
src/gallium/drivers/radeon/radeon_uvd_enc.c
src/gallium/drivers/radeon/radeon_vce.c
src/gallium/drivers/radeon/radeon_vcn_dec.c
src/gallium/drivers/radeon/radeon_vcn_enc.c
src/gallium/drivers/radeon/radeon_winsys.h
src/gallium/drivers/radeonsi/si_pipe.c
src/gallium/winsys/amdgpu/drm/amdgpu_cs.c
src/gallium/winsys/amdgpu/drm/amdgpu_cs.h
src/gallium/winsys/radeon/drm/radeon_drm_cs.c

index 79bfdc5..0a68d37 100644 (file)
@@ -393,7 +393,7 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen,
     if (!r300->ctx)
         goto fail;
 
-    r300->cs = rws->cs_create(r300->ctx, RING_GFX, r300_flush_callback, r300);
+    r300->cs = rws->cs_create(r300->ctx, RING_GFX, r300_flush_callback, r300, false);
     if (r300->cs == NULL)
         goto fail;
 
index 2680396..9e8501f 100644 (file)
@@ -206,7 +206,7 @@ static struct pipe_context *r600_create_context(struct pipe_screen *screen,
        }
 
        rctx->b.gfx.cs = ws->cs_create(rctx->b.ctx, RING_GFX,
-                                      r600_context_gfx_flush, rctx);
+                                      r600_context_gfx_flush, rctx, false);
        rctx->b.gfx.flush = r600_context_gfx_flush;
 
        rctx->allocator_fetch_shader =
index e7c6456..19ba09a 100644 (file)
@@ -715,7 +715,7 @@ bool r600_common_context_init(struct r600_common_context *rctx,
        if (rscreen->info.num_sdma_rings && !(rscreen->debug_flags & DBG_NO_ASYNC_DMA)) {
                rctx->dma.cs = rctx->ws->cs_create(rctx->ctx, RING_DMA,
                                                   r600_flush_dma_ring,
-                                                  rctx);
+                                                  rctx, false);
                rctx->dma.flush = r600_flush_dma_ring;
        }
 
index ac4f40e..495a93d 100644 (file)
@@ -1332,7 +1332,7 @@ struct pipe_video_codec *ruvd_create_decoder(struct pipe_context *context,
        dec->stream_handle = rvid_alloc_stream_handle();
        dec->screen = context->screen;
        dec->ws = ws;
-       dec->cs = ws->cs_create(rctx->ctx, RING_UVD, NULL, NULL);
+       dec->cs = ws->cs_create(rctx->ctx, RING_UVD, NULL, NULL, false);
        if (!dec->cs) {
                RVID_ERR("Can't get command submission context.\n");
                goto error;
index e49e5aa..60ba12a 100644 (file)
@@ -428,7 +428,7 @@ struct pipe_video_codec *rvce_create_encoder(struct pipe_context *context,
 
        enc->screen = context->screen;
        enc->ws = ws;
-       enc->cs = ws->cs_create(rctx->ctx, RING_VCE, rvce_cs_flush, enc);
+       enc->cs = ws->cs_create(rctx->ctx, RING_VCE, rvce_cs_flush, enc, false);
        if (!enc->cs) {
                RVID_ERR("Can't get command submission context.\n");
                goto error;
index 0f3b43d..62af1a3 100644 (file)
@@ -1268,7 +1268,7 @@ struct pipe_video_codec *si_common_uvd_create_decoder(struct pipe_context *conte
        dec->stream_handle = si_vid_alloc_stream_handle();
        dec->screen = context->screen;
        dec->ws = ws;
-       dec->cs = ws->cs_create(sctx->ctx, RING_UVD, NULL, NULL);
+       dec->cs = ws->cs_create(sctx->ctx, RING_UVD, NULL, NULL, false);
        if (!dec->cs) {
                RVID_ERR("Can't get command submission context.\n");
                goto error;
index 521d08f..4384e5e 100644 (file)
@@ -314,7 +314,7 @@ radeon_uvd_create_encoder(struct pipe_context *context,
    enc->screen = context->screen;
    enc->ws = ws;
    enc->cs =
-      ws->cs_create(sctx->ctx, RING_UVD_ENC, radeon_uvd_enc_cs_flush, enc);
+      ws->cs_create(sctx->ctx, RING_UVD_ENC, radeon_uvd_enc_cs_flush, enc, false);
 
    if (!enc->cs) {
       RVID_ERR("Can't get command submission context.\n");
index 8972253..310d165 100644 (file)
@@ -438,7 +438,7 @@ struct pipe_video_codec *si_vce_create_encoder(struct pipe_context *context,
 
        enc->screen = context->screen;
        enc->ws = ws;
-       enc->cs = ws->cs_create(sctx->ctx, RING_VCE, rvce_cs_flush, enc);
+       enc->cs = ws->cs_create(sctx->ctx, RING_VCE, rvce_cs_flush, enc, false);
        if (!enc->cs) {
                RVID_ERR("Can't get command submission context.\n");
                goto error;
index 75ef4a5..1ee85ae 100644 (file)
@@ -1507,7 +1507,7 @@ struct pipe_video_codec *radeon_create_decoder(struct pipe_context *context,
        dec->stream_handle = si_vid_alloc_stream_handle();
        dec->screen = context->screen;
        dec->ws = ws;
-       dec->cs = ws->cs_create(sctx->ctx, ring, NULL, NULL);
+       dec->cs = ws->cs_create(sctx->ctx, ring, NULL, NULL, false);
        if (!dec->cs) {
                RVID_ERR("Can't get command submission context.\n");
                goto error;
index 8f9af73..e8676f6 100644 (file)
@@ -286,7 +286,8 @@ struct pipe_video_codec *radeon_create_encoder(struct pipe_context *context,
        enc->bits_in_shifter = 0;
        enc->screen = context->screen;
        enc->ws = ws;
-       enc->cs = ws->cs_create(sctx->ctx, RING_VCN_ENC, radeon_enc_cs_flush, enc);
+       enc->cs = ws->cs_create(sctx->ctx, RING_VCN_ENC, radeon_enc_cs_flush,
+                               enc, false);
 
        if (!enc->cs) {
                RVID_ERR("Can't get command submission context.\n");
index c680080..49f8bb2 100644 (file)
@@ -464,10 +464,11 @@ struct radeon_winsys {
      * \param user      User pointer that will be passed to the flush callback.
      */
     struct radeon_cmdbuf *(*cs_create)(struct radeon_winsys_ctx *ctx,
-                                          enum ring_type ring_type,
-                                          void (*flush)(void *ctx, unsigned flags,
-                                                       struct pipe_fence_handle **fence),
-                                          void *flush_ctx);
+                                       enum ring_type ring_type,
+                                       void (*flush)(void *ctx, unsigned flags,
+                                                     struct pipe_fence_handle **fence),
+                                       void *flush_ctx,
+                                       bool stop_exec_on_failure);
 
     /**
      * Destroy a command stream.
index ba406be..c487ef4 100644 (file)
@@ -373,6 +373,7 @@ static struct pipe_context *si_create_context(struct pipe_screen *screen,
        struct si_screen* sscreen = (struct si_screen *)screen;
        struct radeon_winsys *ws = sscreen->ws;
        int shader, i;
+       bool stop_exec_on_failure = (flags & PIPE_CONTEXT_LOSE_CONTEXT_ON_RESET) != 0;
 
        if (!sctx)
                return NULL;
@@ -450,8 +451,8 @@ static struct pipe_context *si_create_context(struct pipe_screen *screen,
 
        if (sscreen->info.num_sdma_rings && !(sscreen->debug_flags & DBG(NO_ASYNC_DMA))) {
                sctx->dma_cs = sctx->ws->cs_create(sctx->ctx, RING_DMA,
-                                                      (void*)si_flush_dma_cs,
-                                                      sctx);
+                                                  (void*)si_flush_dma_cs,
+                                                  sctx, stop_exec_on_failure);
        }
 
        si_init_buffer_functions(sctx);
@@ -472,7 +473,7 @@ static struct pipe_context *si_create_context(struct pipe_screen *screen,
        }
 
        sctx->gfx_cs = ws->cs_create(sctx->ctx, RING_GFX,
-                                      (void*)si_flush_gfx_cs, sctx);
+                                    (void*)si_flush_gfx_cs, sctx, stop_exec_on_failure);
 
        /* Border colors. */
        sctx->border_color_table = malloc(SI_MAX_BORDER_COLORS *
index 5986810..5ec3b47 100644 (file)
@@ -923,7 +923,8 @@ amdgpu_cs_create(struct radeon_winsys_ctx *rwctx,
                  enum ring_type ring_type,
                  void (*flush)(void *ctx, unsigned flags,
                                struct pipe_fence_handle **fence),
-                 void *flush_ctx)
+                 void *flush_ctx,
+                 bool stop_exec_on_failure)
 {
    struct amdgpu_ctx *ctx = (struct amdgpu_ctx*)rwctx;
    struct amdgpu_cs *cs;
@@ -939,6 +940,7 @@ amdgpu_cs_create(struct radeon_winsys_ctx *rwctx,
    cs->flush_cs = flush;
    cs->flush_data = flush_ctx;
    cs->ring_type = ring_type;
+   cs->stop_exec_on_failure = stop_exec_on_failure;
 
    struct amdgpu_cs_fence_info fence_info;
    fence_info.handle = cs->ctx->user_fence_bo;
@@ -1395,7 +1397,7 @@ void amdgpu_cs_submit_ib(void *job, int thread_index)
    if (acs->ring_type == RING_GFX)
       ws->gfx_bo_list_counter += cs->num_real_buffers;
 
-   if (acs->ctx->num_rejected_cs) {
+   if (acs->stop_exec_on_failure && acs->ctx->num_rejected_cs) {
       r = -ECANCELED;
    } else {
       struct drm_amdgpu_cs_chunk chunks[6];
index 9f5a4fd..5de770c 100644 (file)
@@ -129,6 +129,7 @@ struct amdgpu_cs {
    /* Flush CS. */
    void (*flush_cs)(void *ctx, unsigned flags, struct pipe_fence_handle **fence);
    void *flush_data;
+   bool stop_exec_on_failure;
 
    struct util_queue_fence flush_completed;
    struct pipe_fence_handle *next_fence;
index 798be78..490c246 100644 (file)
@@ -150,7 +150,8 @@ radeon_drm_cs_create(struct radeon_winsys_ctx *ctx,
                      enum ring_type ring_type,
                      void (*flush)(void *ctx, unsigned flags,
                                    struct pipe_fence_handle **fence),
-                     void *flush_ctx)
+                     void *flush_ctx,
+                     bool stop_exec_on_failure)
 {
     struct radeon_drm_winsys *ws = (struct radeon_drm_winsys*)ctx;
     struct radeon_drm_cs *cs;