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 79bfdc53d25b2a3e8eb6ea8ee4edbbdb3a727441..0a68d37b8066284a4bdc940b41754f861240f829 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 2680396c3d608e8fbc23f03b105a0cf5fc797d5a..9e8501ff3336605eeb911880a929f8dcccf30283 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 e7c645611d77246a6119bcf4ea87ee011caf6125..19ba09ae82a39284b1b825f9139ca336a9a11f6d 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 ac4f40e66c042bc28b3260a33d7d0622c636e860..495a93dc55a1b15cef050551d7d012fb2de01bfe 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 e49e5aa8bde8400cfb0acebee5864baa42125b2b..60ba12a593a637fa4880ee631bc802ecc23be82d 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 0f3b43de81a4823b8e22a78bf7e011f999b2463b..62af1a311c2e113b6ee2028f26cfead52fcd5039 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 521d08f304cce2a7fe2a9506d910c9c3d51d875a..4384e5e1646e833f830e1962f68e47956998d1eb 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 8972253c7c55140179b51c01d21c07a1830286bd..310d1654b05dcf6490871a6bf6b8f2e938d6e47a 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 75ef4a5d401d52f9f676a4092cd53a2d8f9985a5..1ee85ae3d3f799668cbcb73dcf4e569c5c314a16 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 8f9af73c66467a79be23e49f98b97e5528c4a7e1..e8676f6c721033f463506c45662a917773563ed0 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 c6800808cbdc41a244ea51537b88f7bb5210d0bd..49f8bb279e5d70374e7d677dde308776b6c71138 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 ba406bee9224cd4355d092c70c4d064d2e2235dc..c487ef43b5257b60b92e58f41c52a83b399f1fa8 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 5986810d4e9997ca7b1098250ff6da88fb245f40..5ec3b470a15d9ae597910ee4e2e11fecb26cdca6 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 9f5a4fd991a31eb673ae8fa4da4b183d09f0cb37..5de770c89e7adb5046ee0eaf40600d9b07ca64ee 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 798be78504c4c6e8081c17541f1c3282cd7970cd..490c246d6e01fcc3f8aa923e7a1756587a4a6947 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;