From 64473fd8f7d5d72c4cdb599fc2da8a15e465344e Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Wed, 25 Dec 2019 23:26:48 +0200 Subject: [PATCH] anv: 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: --- src/intel/vulkan/anv_batch_chain.c | 8 +++++++- src/intel/vulkan/anv_device.c | 12 +++++++++++- src/intel/vulkan/genX_cmd_buffer.c | 10 ++-------- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/intel/vulkan/anv_batch_chain.c b/src/intel/vulkan/anv_batch_chain.c index acbc07816b1..67202307b54 100644 --- a/src/intel/vulkan/anv_batch_chain.c +++ b/src/intel/vulkan/anv_batch_chain.c @@ -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; diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index ec30e2d0251..e3e3d755d81 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -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; diff --git a/src/intel/vulkan/genX_cmd_buffer.c b/src/intel/vulkan/genX_cmd_buffer.c index 9c67e6796db..91ea16a0105 100644 --- a/src/intel/vulkan/genX_cmd_buffer.c +++ b/src/intel/vulkan/genX_cmd_buffer.c @@ -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; } } -- 2.30.2