anv: return VK_ERROR_DEVICE_LOST immeditely when device is known to be lost
authorIago Toral Quiroga <itoral@igalia.com>
Wed, 22 Mar 2017 08:18:56 +0000 (09:18 +0100)
committerIago Toral Quiroga <itoral@igalia.com>
Fri, 24 Mar 2017 07:11:53 +0000 (08:11 +0100)
If we know the device has been lost we should return this error code for
any command that can report it before we attempt to do anything with the
device.

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
src/intel/vulkan/anv_device.c
src/intel/vulkan/genX_query.c

index 193db01b920de6670c498743bed6ed731bd0d470..4e4fa195a7c23746bdf2e05a2e710b41c1aef560 100644 (file)
@@ -1273,6 +1273,9 @@ VkResult anv_QueueSubmit(
    ANV_FROM_HANDLE(anv_queue, queue, _queue);
    ANV_FROM_HANDLE(anv_fence, fence, _fence);
    struct anv_device *device = queue->device;
+   if (unlikely(device->lost))
+      return VK_ERROR_DEVICE_LOST;
+
    VkResult result = VK_SUCCESS;
 
    /* We lock around QueueSubmit for three main reasons:
@@ -1371,6 +1374,9 @@ VkResult anv_DeviceWaitIdle(
     VkDevice                                    _device)
 {
    ANV_FROM_HANDLE(anv_device, device, _device);
+   if (unlikely(device->lost))
+      return VK_ERROR_DEVICE_LOST;
+
    struct anv_batch batch;
 
    uint32_t cmds[8];
@@ -1676,11 +1682,15 @@ VkResult anv_BindBufferMemory(
 }
 
 VkResult anv_QueueBindSparse(
-    VkQueue                                     queue,
+    VkQueue                                     _queue,
     uint32_t                                    bindInfoCount,
     const VkBindSparseInfo*                     pBindInfo,
     VkFence                                     fence)
 {
+   ANV_FROM_HANDLE(anv_queue, queue, _queue);
+   if (unlikely(queue->device->lost))
+      return VK_ERROR_DEVICE_LOST;
+
    return vk_error(VK_ERROR_FEATURE_NOT_PRESENT);
 }
 
@@ -1788,6 +1798,10 @@ VkResult anv_GetFenceStatus(
 {
    ANV_FROM_HANDLE(anv_device, device, _device);
    ANV_FROM_HANDLE(anv_fence, fence, _fence);
+
+   if (unlikely(device->lost))
+      return VK_ERROR_DEVICE_LOST;
+
    int64_t t = 0;
    int ret;
 
@@ -1827,6 +1841,9 @@ VkResult anv_WaitForFences(
    ANV_FROM_HANDLE(anv_device, device, _device);
    int ret;
 
+   if (unlikely(device->lost))
+      return VK_ERROR_DEVICE_LOST;
+
    /* DRM_IOCTL_I915_GEM_WAIT uses a signed 64 bit timeout and is supposed
     * to block indefinitely timeouts <= 0.  Unfortunately, this was broken
     * for a couple of kernel releases.  Since there's no way to know
@@ -2018,6 +2035,9 @@ VkResult anv_GetEventStatus(
    ANV_FROM_HANDLE(anv_device, device, _device);
    ANV_FROM_HANDLE(anv_event, event, _event);
 
+   if (unlikely(device->lost))
+      return VK_ERROR_DEVICE_LOST;
+
    if (!device->info.has_llc) {
       /* Invalidate read cache before reading event written by GPU. */
       __builtin_ia32_clflush(event);
index 2bbca66cebc2e7ea63fcadb20c7174844b430121..b1ed4d3854a5cacac0e338e6e9fcf8a06422c482 100644 (file)
@@ -150,6 +150,9 @@ VkResult genX(GetQueryPoolResults)(
           pool->type == VK_QUERY_TYPE_PIPELINE_STATISTICS ||
           pool->type == VK_QUERY_TYPE_TIMESTAMP);
 
+   if (unlikely(device->lost))
+      return VK_ERROR_DEVICE_LOST;
+
    if (pData == NULL)
       return VK_SUCCESS;