[Mesa-dev] [PATCH 3/3] anv: return VK_ERROR_DEVICE_LOST immeditely when device is known to be lost

Jason Ekstrand jason at jlekstrand.net
Thu Mar 23 15:18:40 UTC 2017


Series is

Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>

On Thu, Mar 23, 2017 at 2:32 AM, Iago Toral Quiroga <itoral at igalia.com>
wrote:

> 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.
> ---
>  src/intel/vulkan/anv_device.c | 22 +++++++++++++++++++++-
>  src/intel/vulkan/genX_query.c |  3 +++
>  2 files changed, 24 insertions(+), 1 deletion(-)
>
> diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
> index 19bac84..6e1ef77 100644
> --- a/src/intel/vulkan/anv_device.c
> +++ b/src/intel/vulkan/anv_device.c
> @@ -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);
> diff --git a/src/intel/vulkan/genX_query.c b/src/intel/vulkan/genX_query.c
> index 2bbca66..b1ed4d3 100644
> --- a/src/intel/vulkan/genX_query.c
> +++ b/src/intel/vulkan/genX_query.c
> @@ -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;
>
> --
> 2.7.4
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20170323/7db14dcf/attachment.html>


More information about the mesa-dev mailing list