<div dir="ltr"><div>Series is<br><br></div>Reviewed-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>><br></div><div class="gmail_extra"><br><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">If we know the device has been lost we should return this error code for<br>
any command that can report it before we attempt to do anything with the<br>
device.<br>
---<br>
 src/intel/vulkan/anv_device.c | 22 +++++++++++++++++++++-<br>
 src/intel/vulkan/genX_query.c |  3 +++<br>
 2 files changed, 24 insertions(+), 1 deletion(-)<br>
<br>
diff --git a/src/intel/vulkan/anv_device.<wbr>c b/src/intel/vulkan/anv_device.<wbr>c<br>
index 19bac84..6e1ef77 100644<br>
--- a/src/intel/vulkan/anv_device.<wbr>c<br>
+++ b/src/intel/vulkan/anv_device.<wbr>c<br>
@@ -1273,6 +1273,9 @@ VkResult anv_QueueSubmit(<br>
    ANV_FROM_HANDLE(anv_queue, queue, _queue);<br>
    ANV_FROM_HANDLE(anv_fence, fence, _fence);<br>
    struct anv_device *device = queue->device;<br>
+   if (unlikely(device->lost))<br>
+      return VK_ERROR_DEVICE_LOST;<br>
+<br>
    VkResult result = VK_SUCCESS;<br>
<br>
    /* We lock around QueueSubmit for three main reasons:<br>
@@ -1371,6 +1374,9 @@ VkResult anv_DeviceWaitIdle(<br>
     VkDevice                                    _device)<br>
 {<br>
    ANV_FROM_HANDLE(anv_device, device, _device);<br>
+   if (unlikely(device->lost))<br>
+      return VK_ERROR_DEVICE_LOST;<br>
+<br>
    struct anv_batch batch;<br>
<br>
    uint32_t cmds[8];<br>
@@ -1676,11 +1682,15 @@ VkResult anv_BindBufferMemory(<br>
 }<br>
<br>
 VkResult anv_QueueBindSparse(<br>
-    VkQueue                                     queue,<br>
+    VkQueue                                     _queue,<br>
     uint32_t                                    bindInfoCount,<br>
     const VkBindSparseInfo*                     pBindInfo,<br>
     VkFence                                     fence)<br>
 {<br>
+   ANV_FROM_HANDLE(anv_queue, queue, _queue);<br>
+   if (unlikely(queue->device->lost)<wbr>)<br>
+      return VK_ERROR_DEVICE_LOST;<br>
+<br>
    return vk_error(VK_ERROR_FEATURE_NOT_<wbr>PRESENT);<br>
 }<br>
<br>
@@ -1788,6 +1798,10 @@ VkResult anv_GetFenceStatus(<br>
 {<br>
    ANV_FROM_HANDLE(anv_device, device, _device);<br>
    ANV_FROM_HANDLE(anv_fence, fence, _fence);<br>
+<br>
+   if (unlikely(device->lost))<br>
+      return VK_ERROR_DEVICE_LOST;<br>
+<br>
    int64_t t = 0;<br>
    int ret;<br>
<br>
@@ -1827,6 +1841,9 @@ VkResult anv_WaitForFences(<br>
    ANV_FROM_HANDLE(anv_device, device, _device);<br>
    int ret;<br>
<br>
+   if (unlikely(device->lost))<br>
+      return VK_ERROR_DEVICE_LOST;<br>
+<br>
    /* DRM_IOCTL_I915_GEM_WAIT uses a signed 64 bit timeout and is supposed<br>
     * to block indefinitely timeouts <= 0.  Unfortunately, this was broken<br>
     * for a couple of kernel releases.  Since there's no way to know<br>
@@ -2018,6 +2035,9 @@ VkResult anv_GetEventStatus(<br>
    ANV_FROM_HANDLE(anv_device, device, _device);<br>
    ANV_FROM_HANDLE(anv_event, event, _event);<br>
<br>
+   if (unlikely(device->lost))<br>
+      return VK_ERROR_DEVICE_LOST;<br>
+<br>
    if (!device->info.has_llc) {<br>
       /* Invalidate read cache before reading event written by GPU. */<br>
       __builtin_ia32_clflush(event);<br>
diff --git a/src/intel/vulkan/genX_query.<wbr>c b/src/intel/vulkan/genX_query.<wbr>c<br>
index 2bbca66..b1ed4d3 100644<br>
--- a/src/intel/vulkan/genX_query.<wbr>c<br>
+++ b/src/intel/vulkan/genX_query.<wbr>c<br>
@@ -150,6 +150,9 @@ VkResult genX(GetQueryPoolResults)(<br>
           pool->type == VK_QUERY_TYPE_PIPELINE_<wbr>STATISTICS ||<br>
           pool->type == VK_QUERY_TYPE_TIMESTAMP);<br>
<br>
+   if (unlikely(device->lost))<br>
+      return VK_ERROR_DEVICE_LOST;<br>
+<br>
    if (pData == NULL)<br>
       return VK_SUCCESS;<br>
<span class="HOEnZb"><font color="#888888"><br>
--<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>