i965: add identifier BO
authorLionel Landwerlin <lionel.g.landwerlin@intel.com>
Tue, 24 Dec 2019 01:13:52 +0000 (03:13 +0200)
committerMarge Bot <eric+marge@anholt.net>
Wed, 20 May 2020 15:58:22 +0000 (15:58 +0000)
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 <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3203>

src/mesa/drivers/dri/i965/brw_context.h
src/mesa/drivers/dri/i965/brw_pipe_control.c
src/mesa/drivers/dri/i965/intel_batchbuffer.c

index 96b7edd3f758e02e3c79690b5cf16f8853b838d4..6cf3769c9a30ce6823406d0a42f4af9797dbde09 100644 (file)
@@ -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;
index dbeb0acc20e2aa61b0198e50a5bec36f519a0581..257ac748adae59679169ef57a4d87108ab67c1a1 100644 (file)
@@ -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;
 
index bfb39c1ea86a7e99d5777493cb33775ea721786d..089ff79d658f76aa302fbcd45e773bf995e5a94d 100644 (file)
@@ -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