<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Mar 6, 2017 at 11:15 PM, Iago Toral Quiroga <span dir="ltr"><<a href="mailto:itoral@igalia.com" target="_blank">itoral@igalia.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">There is a CTS tests that creates that situation by forcing OOM during a queue<br>
submision and then trying again without the OOM enforcement. The driver returns<br>
the appropriate out of memory error on the first try, but the relocations had<br>
already been computed and stored, so in the second attempt, we duplicate the<br>
deltas and end up with offsets outside the BO limits.<br></blockquote><div><br></div><div>This is something that has come up internally within Khronos.  The correct result (once the spec change lands) will be that basically all vkQueueSubmit errors will actually result in VK_ERROR_DEVICE_LOST precisely because of these sorts of issues.  I've been meaning to send out a patch that makes vkQueueSubmit turn all errors into DEVICE_LOST but haven't gotten around to it yet.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Fixes:<br>
dEQP-VK.api.out_of_host_<wbr>memory.complex<br>
---<br>
 src/intel/vulkan/anv_batch_<wbr>chain.c | 12 ++++++++++--<br>
 src/intel/vulkan/anv_cmd_<wbr>buffer.c  |  2 ++<br>
 src/intel/vulkan/anv_private.h     |  6 ++++++<br>
 3 files changed, 18 insertions(+), 2 deletions(-)<br>
<br>
diff --git a/src/intel/vulkan/anv_batch_<wbr>chain.c b/src/intel/vulkan/anv_batch_<wbr>chain.c<br>
index aae5f78..7df4ef2 100644<br>
--- a/src/intel/vulkan/anv_batch_<wbr>chain.c<br>
+++ b/src/intel/vulkan/anv_batch_<wbr>chain.c<br>
@@ -1242,8 +1242,16 @@ anv_cmd_buffer_execbuf(struct anv_device *device,<br>
    struct anv_execbuf execbuf;<br>
    anv_execbuf_init(&execbuf);<br>
<br>
-   adjust_relocations_from_state_<wbr>pool(ss_pool, &cmd_buffer->surface_relocs,<br>
-                                      cmd_buffer->last_ss_pool_<wbr>center);<br>
+   /* Remember if we have adjusted the relocation offsets so we only ever do<br>
+    * this once<br>
+    */<br>
+   struct anv_cmd_state *state = &cmd_buffer->state;<br>
+   if (!state->adjusted_relocation_<wbr>offsets) {<br>
+       adjust_relocations_from_state_<wbr>pool(ss_pool, &cmd_buffer->surface_relocs,<br>
+                                          cmd_buffer->last_ss_pool_<wbr>center);<br>
+      state->adjusted_relocation_<wbr>offsets = true;<br>
+   }<br>
+<br>
    VkResult result =<br>
       anv_execbuf_add_bo(&execbuf, &ss_pool->bo, &cmd_buffer->surface_relocs,<br>
                          &cmd_buffer->pool->alloc);<br>
diff --git a/src/intel/vulkan/anv_cmd_<wbr>buffer.c b/src/intel/vulkan/anv_cmd_<wbr>buffer.c<br>
index dd5e6c8..adc7c19 100644<br>
--- a/src/intel/vulkan/anv_cmd_<wbr>buffer.c<br>
+++ b/src/intel/vulkan/anv_cmd_<wbr>buffer.c<br>
@@ -142,6 +142,7 @@ anv_cmd_state_reset(struct anv_cmd_buffer *cmd_buffer)<br>
    state->need_query_wa = true;<br>
    state->pma_fix_enabled = false;<br>
    state->hiz_enabled = false;<br>
+   state->adjusted_relocation_<wbr>offsets = false;<br>
<br>
    if (state->attachments != NULL) {<br>
       vk_free(&cmd_buffer->pool-><wbr>alloc, state->attachments);<br>
@@ -198,6 +199,7 @@ static VkResult anv_create_cmd_buffer(<br>
    cmd_buffer->pool = pool;<br>
    cmd_buffer->level = level;<br>
    cmd_buffer->state.attachments = NULL;<br>
+   cmd_buffer->state.adjusted_<wbr>relocation_offsets = false;<br>
<br>
    result = anv_cmd_buffer_init_batch_bo_<wbr>chain(cmd_buffer);<br>
    if (result != VK_SUCCESS)<br>
diff --git a/src/intel/vulkan/anv_<wbr>private.h b/src/intel/vulkan/anv_<wbr>private.h<br>
index 46b51a9..15d1401 100644<br>
--- a/src/intel/vulkan/anv_<wbr>private.h<br>
+++ b/src/intel/vulkan/anv_<wbr>private.h<br>
@@ -1309,6 +1309,12 @@ struct anv_cmd_state {<br>
     */<br>
    struct anv_state                             null_surface_state;<br>
<br>
+   /**<br>
+    * A flag indicating whether we have adjusted relation offsets for this<br>
+    * command buffer.<br>
+    */<br>
+   bool                                         adjusted_relocation_offsets;<br>
+<br>
    struct {<br>
       struct anv_buffer *                       index_buffer;<br>
       uint32_t                                  index_type; /**< 3DSTATE_INDEX_BUFFER.<wbr>IndexFormat */<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.7.4<br>
<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div></div>