anv: return VK_ERROR_DEVICE_LOST immeditely when device is known to be lost

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>
This commit is contained in:
Iago Toral Quiroga
2017-03-22 09:18:56 +01:00
parent 50c8d2c1f7
commit 4da1832c00
2 changed files with 24 additions and 1 deletions

View File

@@ -1273,6 +1273,9 @@ VkResult anv_QueueSubmit(
ANV_FROM_HANDLE(anv_queue, queue, _queue); ANV_FROM_HANDLE(anv_queue, queue, _queue);
ANV_FROM_HANDLE(anv_fence, fence, _fence); ANV_FROM_HANDLE(anv_fence, fence, _fence);
struct anv_device *device = queue->device; struct anv_device *device = queue->device;
if (unlikely(device->lost))
return VK_ERROR_DEVICE_LOST;
VkResult result = VK_SUCCESS; VkResult result = VK_SUCCESS;
/* We lock around QueueSubmit for three main reasons: /* We lock around QueueSubmit for three main reasons:
@@ -1371,6 +1374,9 @@ VkResult anv_DeviceWaitIdle(
VkDevice _device) VkDevice _device)
{ {
ANV_FROM_HANDLE(anv_device, device, _device); ANV_FROM_HANDLE(anv_device, device, _device);
if (unlikely(device->lost))
return VK_ERROR_DEVICE_LOST;
struct anv_batch batch; struct anv_batch batch;
uint32_t cmds[8]; uint32_t cmds[8];
@@ -1676,11 +1682,15 @@ VkResult anv_BindBufferMemory(
} }
VkResult anv_QueueBindSparse( VkResult anv_QueueBindSparse(
VkQueue queue, VkQueue _queue,
uint32_t bindInfoCount, uint32_t bindInfoCount,
const VkBindSparseInfo* pBindInfo, const VkBindSparseInfo* pBindInfo,
VkFence fence) 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); 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_device, device, _device);
ANV_FROM_HANDLE(anv_fence, fence, _fence); ANV_FROM_HANDLE(anv_fence, fence, _fence);
if (unlikely(device->lost))
return VK_ERROR_DEVICE_LOST;
int64_t t = 0; int64_t t = 0;
int ret; int ret;
@@ -1827,6 +1841,9 @@ VkResult anv_WaitForFences(
ANV_FROM_HANDLE(anv_device, device, _device); ANV_FROM_HANDLE(anv_device, device, _device);
int ret; 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 /* DRM_IOCTL_I915_GEM_WAIT uses a signed 64 bit timeout and is supposed
* to block indefinitely timeouts <= 0. Unfortunately, this was broken * to block indefinitely timeouts <= 0. Unfortunately, this was broken
* for a couple of kernel releases. Since there's no way to know * 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_device, device, _device);
ANV_FROM_HANDLE(anv_event, event, _event); ANV_FROM_HANDLE(anv_event, event, _event);
if (unlikely(device->lost))
return VK_ERROR_DEVICE_LOST;
if (!device->info.has_llc) { if (!device->info.has_llc) {
/* Invalidate read cache before reading event written by GPU. */ /* Invalidate read cache before reading event written by GPU. */
__builtin_ia32_clflush(event); __builtin_ia32_clflush(event);

View File

@@ -150,6 +150,9 @@ VkResult genX(GetQueryPoolResults)(
pool->type == VK_QUERY_TYPE_PIPELINE_STATISTICS || pool->type == VK_QUERY_TYPE_PIPELINE_STATISTICS ||
pool->type == VK_QUERY_TYPE_TIMESTAMP); pool->type == VK_QUERY_TYPE_TIMESTAMP);
if (unlikely(device->lost))
return VK_ERROR_DEVICE_LOST;
if (pData == NULL) if (pData == NULL)
return VK_SUCCESS; return VK_SUCCESS;