intel/decoders: handle decoding MI_BBS from ring

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>
This commit is contained in:
Lionel Landwerlin 2018-08-28 11:41:42 +01:00
parent ec526d6ba0
commit acb50d6b1f
11 changed files with 19 additions and 17 deletions

View File

@ -805,7 +805,7 @@ struct custom_decoder {
void void
gen_print_batch(struct gen_batch_decode_ctx *ctx, gen_print_batch(struct gen_batch_decode_ctx *ctx,
const uint32_t *batch, uint32_t batch_size, 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); const uint32_t *p, *end = batch + batch_size / sizeof(uint32_t);
int length; int length;
@ -887,7 +887,7 @@ gen_print_batch(struct gen_batch_decode_ctx *ctx,
next_batch_addr); next_batch_addr);
} else { } else {
gen_print_batch(ctx, next_batch.map, next_batch.size, gen_print_batch(ctx, next_batch.map, next_batch.size,
next_batch.addr); next_batch.addr, false);
} }
if (second_level) { if (second_level) {
/* MI_BATCH_BUFFER_START with "2nd Level Batch Buffer" set acts /* 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. * MI_BATCH_BUFFER_END.
*/ */
continue; continue;
} else { } else if (!from_ring) {
/* MI_BATCH_BUFFER_START with "2nd Level Batch Buffer" unset acts /* MI_BATCH_BUFFER_START with "2nd Level Batch Buffer" unset acts
* like a goto. Nothing after it will ever get processed. In * like a goto. Nothing after it will ever get processed. In
* order to prevent the recursion from growing, we just reset the * order to prevent the recursion from growing, we just reset the

View 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, void gen_print_batch(struct gen_batch_decode_ctx *ctx,
const uint32_t *batch, uint32_t batch_size, const uint32_t *batch, uint32_t batch_size,
uint64_t batch_addr); uint64_t batch_addr, bool from_ring);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -166,7 +166,7 @@ handle_execlist_write(void *user_data, enum drm_i915_gem_engine_class engine, ui
batch_ctx.engine = engine; batch_ctx.engine = engine;
gen_print_batch(&batch_ctx, commands, gen_print_batch(&batch_ctx, commands,
MIN2(ring_buffer_tail - ring_buffer_head, ring_buffer_length), 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); 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.get_bo = get_legacy_bo;
batch_ctx.engine = engine; 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); aub_mem_clear_bo_maps(&mem);
} }

View File

@ -612,7 +612,7 @@ read_data_file(FILE *file)
batch_ctx.engine = class; batch_ctx.engine = class;
gen_print_batch(&batch_ctx, sections[s].data, gen_print_batch(&batch_ctx, sections[s].data,
sections[s].dword_count * 4, sections[s].dword_count * 4,
sections[s].gtt_offset); sections[s].gtt_offset, false);
} }
} }

View File

@ -702,7 +702,7 @@ display_batch_ring_write(void *user_data, enum drm_i915_gem_engine_class engine,
window->uses_ppgtt = false; 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 static void
@ -737,7 +737,7 @@ display_batch_execlist_write(void *user_data,
window->decode_ctx.engine = engine; window->decode_ctx.engine = engine;
aub_viewer_render_batch(&window->decode_ctx, commands, aub_viewer_render_batch(&window->decode_ctx, commands,
MIN2(ring_buffer_tail - ring_buffer_head, ring_buffer_length), 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 static void

View 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, void aub_viewer_render_batch(struct aub_viewer_decode_ctx *ctx,
const void *batch, uint32_t batch_size, const void *batch, uint32_t batch_size,
uint64_t batch_addr); uint64_t batch_addr, bool from_ring);
#endif /* AUBINATOR_VIEWER_H */ #endif /* AUBINATOR_VIEWER_H */

View File

@ -892,7 +892,7 @@ struct custom_decoder info_decoders[] = {
void void
aub_viewer_render_batch(struct aub_viewer_decode_ctx *ctx, aub_viewer_render_batch(struct aub_viewer_decode_ctx *ctx,
const void *_batch, uint32_t batch_size, const void *_batch, uint32_t batch_size,
uint64_t batch_addr) uint64_t batch_addr, bool from_ring)
{ {
struct gen_group *inst; struct gen_group *inst;
const uint32_t *p, *batch = (const uint32_t *) _batch, *end = batch + batch_size / sizeof(uint32_t); 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); next_batch_addr);
} else { } else {
aub_viewer_render_batch(ctx, next_batch.map, next_batch.size, aub_viewer_render_batch(ctx, next_batch.map, next_batch.size,
next_batch.addr); next_batch.addr, false);
} }
if (second_level) { if (second_level) {
/* MI_BATCH_BUFFER_START with "2nd Level Batch Buffer" set acts /* 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. * MI_BATCH_BUFFER_END.
*/ */
continue; continue;
} else { } else if (!from_ring) {
/* MI_BATCH_BUFFER_START with "2nd Level Batch Buffer" unset acts /* MI_BATCH_BUFFER_START with "2nd Level Batch Buffer" unset acts
* like a goto. Nothing after it will ever get processed. In * like a goto. Nothing after it will ever get processed. In
* order to prevent the recursion from growing, we just reset the * order to prevent the recursion from growing, we just reset the

View File

@ -1735,7 +1735,7 @@ anv_cmd_buffer_execbuf(struct anv_device *device,
device->cmd_buffer_being_decoded = cmd_buffer; device->cmd_buffer_being_decoded = cmd_buffer;
gen_print_batch(&device->decoder_ctx, (*bo)->bo.map, 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; device->cmd_buffer_being_decoded = NULL;
} }

View File

@ -1795,11 +1795,13 @@ get_bo_from_pool(struct gen_batch_decode_bo *ret,
/* Finding a buffer for batch decoding */ /* Finding a buffer for batch decoding */
static struct gen_batch_decode_bo 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 anv_device *device = v_batch;
struct gen_batch_decode_bo ret_bo = {}; struct gen_batch_decode_bo ret_bo = {};
assert(ppgtt);
if (get_bo_from_pool(&ret_bo, &device->dynamic_state_pool.block_pool, address)) if (get_bo_from_pool(&ret_bo, &device->dynamic_state_pool.block_pool, address))
return ret_bo; return ret_bo;
if (get_bo_from_pool(&ret_bo, &device->instruction_state_pool.block_pool, address)) if (get_bo_from_pool(&ret_bo, &device->instruction_state_pool.block_pool, address))

View File

@ -101,7 +101,7 @@ anv_device_submit_simple_batch(struct anv_device *device,
execbuf.rsvd2 = 0; execbuf.rsvd2 = 0;
if (unlikely(INTEL_DEBUG & DEBUG_BATCH)) 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); result = anv_device_execbuf(device, &execbuf, exec_bos);
if (result != VK_SUCCESS) if (result != VK_SUCCESS)

View 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)) { if (unlikely(INTEL_DEBUG & DEBUG_BATCH)) {
gen_print_batch(&batch->decoder, batch->batch.map, gen_print_batch(&batch->decoder, batch->batch.map,
4 * USED_BATCH(*batch), 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) if (brw->ctx.Const.ResetStrategy == GL_LOSE_CONTEXT_ON_RESET_ARB)