anv: add identifier BO
authorLionel Landwerlin <lionel.g.landwerlin@intel.com>
Wed, 25 Dec 2019 21:26:48 +0000 (23:26 +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/intel/vulkan/anv_batch_chain.c
src/intel/vulkan/anv_device.c
src/intel/vulkan/genX_cmd_buffer.c

index acbc07816b18e7c9ef1e056883c2e507d8d7a80d..67202307b54a6c98ee30bfcfd9c5eed383cc4b49 100644 (file)
@@ -1680,7 +1680,13 @@ anv_queue_execbuf_locked(struct anv_queue *queue,
    execbuf.alloc_scope = submit->alloc_scope;
    execbuf.perf_query_pass = submit->perf_query_pass;
 
-   VkResult result;
+   /* Always add the workaround BO as it includes a driver identifier for the
+    * error_state.
+    */
+   VkResult result =
+      anv_execbuf_add_bo(device, &execbuf, device->workaround_bo, NULL, 0);
+   if (result != VK_SUCCESS)
+      goto error;
 
    for (uint32_t i = 0; i < submit->fence_bo_count; i++) {
       int signaled;
index ec30e2d0251830d2d318e9642a126619a10368d6..e3e3d755d813e1355cc1ec5ab15860cf245690f9 100644 (file)
@@ -2926,7 +2926,8 @@ VkResult anv_CreateDevice(
          goto fail_binding_table_pool;
    }
 
-   result = anv_device_alloc_bo(device, 4096, 0 /* flags */,
+   result = anv_device_alloc_bo(device, 4096,
+                                ANV_BO_ALLOC_CAPTURE | ANV_BO_ALLOC_MAPPED /* flags */,
                                 0 /* explicit_address */,
                                 &device->workaround_bo);
    if (result != VK_SUCCESS)
@@ -2934,8 +2935,17 @@ VkResult anv_CreateDevice(
 
    device->workaround_address = (struct anv_address) {
       .bo = device->workaround_bo,
+      .offset = align_u32(
+         intel_debug_write_identifiers(device->workaround_bo->map,
+                                       device->workaround_bo->size,
+                                       "Anv") + 8, 8),
    };
 
+   if (!device->info.has_llc) {
+      gen_clflush_range(device->workaround_bo->map,
+                        device->workaround_address.offset);
+   }
+
    result = anv_device_init_trivial_batch(device);
    if (result != VK_SUCCESS)
       goto fail_workaround_bo;
index 9c67e6796dbf4c5597ca81b048d49be3ccdd32c5..91ea16a0105c4a0cff6801983077900de9952421 100644 (file)
@@ -2133,10 +2133,7 @@ genX(cmd_buffer_apply_pipe_flushes)(struct anv_cmd_buffer *cmd_buffer)
          if (bits & ANV_PIPE_END_OF_PIPE_SYNC_BIT) {
             pipe.CommandStreamerStallEnable = true;
             pipe.PostSyncOperation = WriteImmediateData;
-            pipe.Address = (struct anv_address) {
-               .bo = cmd_buffer->device->workaround_bo,
-               .offset = 0
-            };
+            pipe.Address = cmd_buffer->device->workaround_address;
          }
 
          /*
@@ -2206,10 +2203,7 @@ genX(cmd_buffer_apply_pipe_flushes)(struct anv_cmd_buffer *cmd_buffer)
           */
          anv_batch_emit(&cmd_buffer->batch, GENX(MI_LOAD_REGISTER_MEM), lrm) {
             lrm.RegisterAddress  = 0x243C; /* GEN7_3DPRIM_START_INSTANCE */
-            lrm.MemoryAddress = (struct anv_address) {
-               .bo = cmd_buffer->device->workaround_bo,
-               .offset = 0
-            };
+            lrm.MemoryAddress = cmd_buffer->device->workaround_address;
          }
       }