From: Lionel Landwerlin Date: Tue, 24 Dec 2019 01:13:52 +0000 (+0200) Subject: i965: add identifier BO X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=507b1ca10c62833b515dcbedf9ee56e3812b88cb;p=mesa.git i965: add identifier BO A buffer added to all execbufs so that we can attribute a batch that caused a hang to a particular driver. v2: Reuse workaround BO Signed-off-by: Lionel Landwerlin Part-of: --- diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index 96b7edd3f75..6cf3769c9a3 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -723,7 +723,17 @@ struct brw_context uint32_t hw_ctx; - /** BO for post-sync nonzero writes for gen6 workaround. */ + /** + * BO for post-sync nonzero writes for gen6 workaround. + * + * This buffer also contains a marker + description of the driver. This + * buffer is added to all execbufs syscalls so that we can identify the + * driver that generated a hang by looking at the content of the buffer in + * the error state. + * + * Read/write should go at workaround_bo_offset in that buffer to avoid + * overriding the debug data. + */ struct brw_bo *workaround_bo; uint32_t workaround_bo_offset; uint8_t pipe_controls_since_last_cs_stall; diff --git a/src/mesa/drivers/dri/i965/brw_pipe_control.c b/src/mesa/drivers/dri/i965/brw_pipe_control.c index dbeb0acc20e..257ac748ada 100644 --- a/src/mesa/drivers/dri/i965/brw_pipe_control.c +++ b/src/mesa/drivers/dri/i965/brw_pipe_control.c @@ -371,6 +371,27 @@ brw_emit_mi_flush(struct brw_context *brw) brw_emit_pipe_control_flush(brw, flags); } +static bool +init_identifier_bo(struct brw_context *brw) +{ + void *bo_map; + + if (!can_do_exec_capture(brw->screen)) + return true; + + bo_map = brw_bo_map(NULL, brw->workaround_bo, MAP_READ | MAP_WRITE); + if (!bo_map) + return false; + + brw->workaround_bo->kflags |= EXEC_OBJECT_CAPTURE; + brw->workaround_bo_offset = + ALIGN(intel_debug_write_identifiers(bo_map, 4096, "i965") + 8, 8); + + brw_bo_unmap(brw->workaround_bo); + + return true; +} + int brw_init_pipe_control(struct brw_context *brw, const struct gen_device_info *devinfo) @@ -418,6 +439,9 @@ brw_init_pipe_control(struct brw_context *brw, if (brw->workaround_bo == NULL) return -ENOMEM; + if (!init_identifier_bo(brw)) + return -ENOMEM; /* Couldn't map workaround_bo?? */ + brw->workaround_bo_offset = 0; brw->pipe_controls_since_last_cs_stall = 0; diff --git a/src/mesa/drivers/dri/i965/intel_batchbuffer.c b/src/mesa/drivers/dri/i965/intel_batchbuffer.c index bfb39c1ea86..089ff79d658 100644 --- a/src/mesa/drivers/dri/i965/intel_batchbuffer.c +++ b/src/mesa/drivers/dri/i965/intel_batchbuffer.c @@ -277,6 +277,13 @@ intel_batchbuffer_reset(struct brw_context *brw) if (batch->state_batch_sizes) _mesa_hash_table_u64_clear(batch->state_batch_sizes, NULL); + + /* Always add workaround_bo which contains a driver identifier to be + * recorded in error states. + */ + struct brw_bo *identifier_bo = brw->workaround_bo; + if (identifier_bo) + add_exec_bo(batch, identifier_bo); } static void