intel/decoders: handle decoding MI_BBS from ring
authorLionel Landwerlin <lionel.g.landwerlin@intel.com>
Tue, 28 Aug 2018 10:41:42 +0000 (11:41 +0100)
committerLionel Landwerlin <lionel.g.landwerlin@intel.com>
Thu, 7 Mar 2019 15:08:31 +0000 (15:08 +0000)
An MI_BATCH_BUFFER_START in the ring buffer acts as a second level
batchbuffer (aka jump back to ring buffer when running into a
MI_BATCH_BUFFER_END).

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Rafael Antognolli <rafael.antognolli@intel.com>
src/intel/common/gen_batch_decoder.c
src/intel/common/gen_decoder.h
src/intel/tools/aubinator.c
src/intel/tools/aubinator_error_decode.c
src/intel/tools/aubinator_viewer.cpp
src/intel/tools/aubinator_viewer.h
src/intel/tools/aubinator_viewer_decoder.cpp
src/intel/vulkan/anv_batch_chain.c
src/intel/vulkan/anv_device.c
src/intel/vulkan/anv_queue.c
src/mesa/drivers/dri/i965/intel_batchbuffer.c

index 8eff5d171a53d51d625e76c816348423466998d3..becb708da651460ef22d97f029b09896cd8ecf17 100644 (file)
@@ -805,7 +805,7 @@ struct custom_decoder {
 void
 gen_print_batch(struct gen_batch_decode_ctx *ctx,
                 const uint32_t *batch, uint32_t batch_size,
-                uint64_t batch_addr)
+                uint64_t batch_addr, bool from_ring)
 {
    const uint32_t *p, *end = batch + batch_size / sizeof(uint32_t);
    int length;
@@ -887,7 +887,7 @@ gen_print_batch(struct gen_batch_decode_ctx *ctx,
                     next_batch_addr);
          } else {
             gen_print_batch(ctx, next_batch.map, next_batch.size,
-                            next_batch.addr);
+                            next_batch.addr, false);
          }
          if (second_level) {
             /* MI_BATCH_BUFFER_START with "2nd Level Batch Buffer" set acts
@@ -896,7 +896,7 @@ gen_print_batch(struct gen_batch_decode_ctx *ctx,
              * MI_BATCH_BUFFER_END.
              */
             continue;
-         } else {
+         } else if (!from_ring) {
             /* MI_BATCH_BUFFER_START with "2nd Level Batch Buffer" unset acts
              * like a goto.  Nothing after it will ever get processed.  In
              * order to prevent the recursion from growing, we just reset the
index 6ab0b66aca3bb9a8ba5da6292e01c240c51f2d50..f5f38078442c0d2e9d7b423e0f0163ea4b4e8f82 100644 (file)
@@ -254,7 +254,7 @@ void gen_batch_decode_ctx_finish(struct gen_batch_decode_ctx *ctx);
 
 void gen_print_batch(struct gen_batch_decode_ctx *ctx,
                      const uint32_t *batch, uint32_t batch_size,
-                     uint64_t batch_addr);
+                     uint64_t batch_addr, bool from_ring);
 
 #ifdef __cplusplus
 }
index 1108604fdfed1cabfff4cf3538ebddeae810a05c..e8c3db71f0e5c79591bb4924c8e693ca3b2830b6 100644 (file)
@@ -166,7 +166,7 @@ handle_execlist_write(void *user_data, enum drm_i915_gem_engine_class engine, ui
    batch_ctx.engine = engine;
    gen_print_batch(&batch_ctx, commands,
                    MIN2(ring_buffer_tail - ring_buffer_head, ring_buffer_length),
-                   ring_bo.addr + ring_buffer_head);
+                   ring_bo.addr + ring_buffer_head, true);
    aub_mem_clear_bo_maps(&mem);
 }
 
@@ -184,7 +184,7 @@ handle_ring_write(void *user_data, enum drm_i915_gem_engine_class engine,
    batch_ctx.get_bo = get_legacy_bo;
 
    batch_ctx.engine = engine;
-   gen_print_batch(&batch_ctx, data, data_len, 0);
+   gen_print_batch(&batch_ctx, data, data_len, 0, false);
 
    aub_mem_clear_bo_maps(&mem);
 }
index bd578de48e4e301d4c68ee7c77f976bc041752b1..049823ca46326f2f4d7c64a83c8e0d9efd131d21 100644 (file)
@@ -612,7 +612,7 @@ read_data_file(FILE *file)
          batch_ctx.engine = class;
          gen_print_batch(&batch_ctx, sections[s].data,
                          sections[s].dword_count * 4,
-                         sections[s].gtt_offset);
+                         sections[s].gtt_offset, false);
       }
    }
 
index a0c611350fc8f5f33e16e41ac966a8e11c7ef12c..3eed5140ef24396bfbfab06550e1cdf1dcd4a31b 100644 (file)
@@ -702,7 +702,7 @@ display_batch_ring_write(void *user_data, enum drm_i915_gem_engine_class engine,
 
    window->uses_ppgtt = false;
 
-   aub_viewer_render_batch(&window->decode_ctx, data, data_len, 0);
+   aub_viewer_render_batch(&window->decode_ctx, data, data_len, 0, false);
 }
 
 static void
@@ -737,7 +737,7 @@ display_batch_execlist_write(void *user_data,
    window->decode_ctx.engine = engine;
    aub_viewer_render_batch(&window->decode_ctx, commands,
                            MIN2(ring_buffer_tail - ring_buffer_head, ring_buffer_length),
-                           ring_buffer_start + ring_buffer_head);
+                           ring_buffer_start + ring_buffer_head, true);
 }
 
 static void
index 755df05769929d8d4f5aca37bedda5f4bdc4fe26..168129255156a54f4f9a330f8a55e6fe98f811db 100644 (file)
@@ -95,6 +95,6 @@ void aub_viewer_decode_ctx_init(struct aub_viewer_decode_ctx *ctx,
 
 void aub_viewer_render_batch(struct aub_viewer_decode_ctx *ctx,
                              const void *batch, uint32_t batch_size,
-                             uint64_t batch_addr);
+                             uint64_t batch_addr, bool from_ring);
 
 #endif /* AUBINATOR_VIEWER_H */
index 8e92ad03dd4580920fc44361baf22541ca7caadb..b946fb33e0ceedff0c117fd08baa644c292afe71 100644 (file)
@@ -892,7 +892,7 @@ struct custom_decoder info_decoders[] = {
 void
 aub_viewer_render_batch(struct aub_viewer_decode_ctx *ctx,
                         const void *_batch, uint32_t batch_size,
-                        uint64_t batch_addr)
+                        uint64_t batch_addr, bool from_ring)
 {
    struct gen_group *inst;
    const uint32_t *p, *batch = (const uint32_t *) _batch, *end = batch + batch_size / sizeof(uint32_t);
@@ -970,7 +970,7 @@ aub_viewer_render_batch(struct aub_viewer_decode_ctx *ctx,
                                next_batch_addr);
          } else {
             aub_viewer_render_batch(ctx, next_batch.map, next_batch.size,
-                                    next_batch.addr);
+                                    next_batch.addr, false);
          }
          if (second_level) {
             /* MI_BATCH_BUFFER_START with "2nd Level Batch Buffer" set acts
@@ -979,7 +979,7 @@ aub_viewer_render_batch(struct aub_viewer_decode_ctx *ctx,
              * MI_BATCH_BUFFER_END.
              */
             continue;
-         } else {
+         } else if (!from_ring) {
             /* MI_BATCH_BUFFER_START with "2nd Level Batch Buffer" unset acts
              * like a goto.  Nothing after it will ever get processed.  In
              * order to prevent the recursion from growing, we just reset the
index 9c7f96873a88147017d443a880de86c8b4b7ffc2..cf40d8b7123877354587575827994ac156f5abeb 100644 (file)
@@ -1735,7 +1735,7 @@ anv_cmd_buffer_execbuf(struct anv_device *device,
 
          device->cmd_buffer_being_decoded = cmd_buffer;
          gen_print_batch(&device->decoder_ctx, (*bo)->bo.map,
-                         (*bo)->bo.size, (*bo)->bo.offset);
+                         (*bo)->bo.size, (*bo)->bo.offset, false);
          device->cmd_buffer_being_decoded = NULL;
       }
 
index aee795cbdbb038f6da93e13b80a833146e7fbc36..92e8f40278f545d6ad7922afe12a6ffd342830ea 100644 (file)
@@ -1795,11 +1795,13 @@ get_bo_from_pool(struct gen_batch_decode_bo *ret,
 
 /* Finding a buffer for batch decoding */
 static struct gen_batch_decode_bo
-decode_get_bo(void *v_batch, uint64_t address)
+decode_get_bo(void *v_batch, bool ppgtt, uint64_t address)
 {
    struct anv_device *device = v_batch;
    struct gen_batch_decode_bo ret_bo = {};
 
+   assert(ppgtt);
+
    if (get_bo_from_pool(&ret_bo, &device->dynamic_state_pool.block_pool, address))
       return ret_bo;
    if (get_bo_from_pool(&ret_bo, &device->instruction_state_pool.block_pool, address))
index 54e848fd15c24bf674b5c7d1d44e2a7c18239de2..dcefed9e4dc7e4e933f7816443505a523615baca 100644 (file)
@@ -101,7 +101,7 @@ anv_device_submit_simple_batch(struct anv_device *device,
    execbuf.rsvd2 = 0;
 
    if (unlikely(INTEL_DEBUG & DEBUG_BATCH))
-      gen_print_batch(&device->decoder_ctx, bo.map, bo.size, bo.offset);
+      gen_print_batch(&device->decoder_ctx, bo.map, bo.size, bo.offset, false);
 
    result = anv_device_execbuf(device, &execbuf, exec_bos);
    if (result != VK_SUCCESS)
index 0c7f25272184a23880bd3619fcc542a99eacae37..a701f3bd353de09cf11f3ededb66c05e6f4f3f7d 100644 (file)
@@ -828,7 +828,7 @@ submit_batch(struct brw_context *brw, int in_fence_fd, int *out_fence_fd)
    if (unlikely(INTEL_DEBUG & DEBUG_BATCH)) {
       gen_print_batch(&batch->decoder, batch->batch.map,
                       4 * USED_BATCH(*batch),
-                      batch->batch.bo->gtt_offset);
+                      batch->batch.bo->gtt_offset, false);
    }
 
    if (brw->ctx.Const.ResetStrategy == GL_LOSE_CONTEXT_ON_RESET_ARB)