<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Mar 23, 2017 at 2:32 AM, 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">The Vulkan specs say:<br>
<br>
   "A logical device may become lost because of hardware errors, execution<br>
    timeouts, power management events and/or platform-specific events. This<br>
    may cause pending and future command execution to fail and cause hardware<br>
    resources to be corrupted. When this happens, certain commands will<br>
    return VK_ERROR_DEVICE_LOST (see Error Codes for a list of such commands).<br>
    After any such event, the logical device is considered lost. It is not<br>
    possible to reset the logical device to a non-lost state, however the lost<br>
    state is specific to a logical device (VkDevice), and the corresponding<br>
    physical device (VkPhysicalDevice) may be otherwise unaffected. In some<br>
    cases, the physical device may also be lost, and attempting to create a<br>
    new logical device will fail, returning VK_ERROR_DEVICE_LOST."<br>
<br>
This means that we need to track if a logical device has been lost so we can<br>
have the commands referenced by the spec return VK_ERROR_DEVICE_LOST<br>
immediately.<br>
---<br>
 src/intel/vulkan/anv_device.c  | 5 +++++<br>
 src/intel/vulkan/anv_private.h | 1 +<br>
 2 files changed, 6 insertions(+)<br>
<br>
diff --git a/src/intel/vulkan/anv_device.<wbr>c b/src/intel/vulkan/anv_device.<wbr>c<br>
index a11cb32..19bac84 100644<br>
--- a/src/intel/vulkan/anv_device.<wbr>c<br>
+++ b/src/intel/vulkan/anv_device.<wbr>c<br>
@@ -929,6 +929,7 @@ anv_device_submit_simple_<wbr>batch(struct anv_device *device,<br>
    ret = anv_gem_wait(device, bo.gem_handle, &timeout);<br>
    if (ret != 0) {<br>
       /* We don't know the real error. */<br>
+      device->lost = true;<br>
       result = vk_errorf(VK_ERROR_DEVICE_<wbr>LOST, "execbuf2 failed: %m");<br>
       goto fail;<br>
    }<br>
@@ -973,6 +974,7 @@ VkResult anv_CreateDevice(<br>
    device->_loader_data.<wbr>loaderMagic = ICD_LOADER_MAGIC;<br>
    device->instance = physical_device->instance;<br>
    device->chipset_id = physical_device->chipset_id;<br>
+   device->lost = false;<br>
<br>
    if (pAllocator)<br>
       device->alloc = *pAllocator;<br>
@@ -1250,6 +1252,7 @@ anv_device_execbuf(struct anv_device *device,<br>
    int ret = anv_gem_execbuffer(device, execbuf);<br>
    if (ret != 0) {<br>
       /* We don't know the real error. */<br>
+      device->lost = true;<br>
       return vk_errorf(VK_ERROR_DEVICE_<wbr>LOST, "execbuf2 failed: %m");<br>
    }<br>
<br>
@@ -1339,6 +1342,7 @@ out:<br>
        * submit the same job again to this device.<br>
        */<br>
       result = VK_ERROR_DEVICE_LOST;<br>
+      device->lost = true;<br>
<br>
       /* If we return VK_ERROR_DEVICE LOST here, we need to ensure that<br>
        * vkWaitForFences() and vkGetFenceStatus() return a valid result<br>
@@ -1865,6 +1869,7 @@ VkResult anv_WaitForFences(<br>
                return VK_TIMEOUT;<br>
             } else if (ret == -1) {<br>
                /* We don't know the real error. */<br>
+                device->lost = true;<br>
                return vk_errorf(VK_ERROR_DEVICE_<wbr>LOST, "gem wait failed: %m");<br>
             } else {<br>
                fence->state = ANV_FENCE_STATE_SIGNALED;<br>
diff --git a/src/intel/vulkan/anv_<wbr>private.h b/src/intel/vulkan/anv_<wbr>private.h<br>
index fd82ce9..68f7359 100644<br>
--- a/src/intel/vulkan/anv_<wbr>private.h<br>
+++ b/src/intel/vulkan/anv_<wbr>private.h<br>
@@ -619,6 +619,7 @@ struct anv_device {<br>
<br>
     pthread_mutex_t                             mutex;<br>
     pthread_cond_t                              queue_submit;<br>
+    bool                                        lost;<br>
 };<br>
<br>
 static void inline<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>