radv: return VK_ERROR_DEVICE_LOST if wait-for-idle failed or expired
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Fri, 10 Jul 2020 12:45:19 +0000 (14:45 +0200)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Sun, 12 Jul 2020 11:17:42 +0000 (13:17 +0200)
When ctx_wait_idle failed, something really bad happened likely
a GPU hang. Make sure to return the appropriate Vulkan error code
in this case.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5843>

src/amd/vulkan/radv_device.c

index 7a67f31fef723946cb819ee087a463a3c06aea4a..58299a0e0e4eb61fdaaf7216f1addc3cad1fc304 100644 (file)
@@ -5024,9 +5024,11 @@ VkResult radv_QueueWaitIdle(
        }
        pthread_mutex_unlock(&queue->pending_mutex);
 
-       queue->device->ws->ctx_wait_idle(queue->hw_ctx,
-                                        radv_queue_family_to_ring(queue->queue_family_index),
-                                        queue->queue_idx);
+       if (!queue->device->ws->ctx_wait_idle(queue->hw_ctx,
+                                             radv_queue_family_to_ring(queue->queue_family_index),
+                                             queue->queue_idx))
+               return VK_ERROR_DEVICE_LOST;
+
        return VK_SUCCESS;
 }
 
@@ -5037,7 +5039,11 @@ VkResult radv_DeviceWaitIdle(
 
        for (unsigned i = 0; i < RADV_MAX_QUEUE_FAMILIES; i++) {
                for (unsigned q = 0; q < device->queue_count[i]; q++) {
-                       radv_QueueWaitIdle(radv_queue_to_handle(&device->queues[i][q]));
+                       VkResult result =
+                               radv_QueueWaitIdle(radv_queue_to_handle(&device->queues[i][q]));
+
+                       if (result != VK_SUCCESS)
+                               return result;
                }
        }
        return VK_SUCCESS;