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