summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/intel/vulkan/anv_device.c28
-rw-r--r--src/intel/vulkan/anv_private.h11
-rw-r--r--src/intel/vulkan/anv_queue.c14
-rw-r--r--src/intel/vulkan/genX_query.c4
4 files changed, 36 insertions, 21 deletions
diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
index 87fe5e4dbbf..b4034145a55 100644
--- a/src/intel/vulkan/anv_device.c
+++ b/src/intel/vulkan/anv_device.c
@@ -1711,7 +1711,7 @@ VkResult anv_CreateDevice(
device->instance = physical_device->instance;
device->chipset_id = physical_device->chipset_id;
device->no_hw = physical_device->no_hw;
- device->lost = false;
+ device->_lost = false;
if (pAllocator)
device->alloc = *pAllocator;
@@ -2048,6 +2048,12 @@ void anv_GetDeviceQueue2(
*pQueue = NULL;
}
+void
+anv_device_set_lost(struct anv_device *device, const char *msg, ...)
+{
+ device->_lost = true;
+}
+
VkResult
anv_device_query_status(struct anv_device *device)
{
@@ -2055,24 +2061,24 @@ anv_device_query_status(struct anv_device *device)
* for it. However, it doesn't hurt to check and it potentially lets us
* avoid an ioctl.
*/
- if (unlikely(device->lost))
+ if (anv_device_is_lost(device))
return VK_ERROR_DEVICE_LOST;
uint32_t active, pending;
int ret = anv_gem_gpu_get_reset_stats(device, &active, &pending);
if (ret == -1) {
/* We don't know the real error. */
- device->lost = true;
+ anv_device_set_lost(device, "get_reset_stats failed: %m");
return vk_errorf(device->instance, device, VK_ERROR_DEVICE_LOST,
"get_reset_stats failed: %m");
}
if (active) {
- device->lost = true;
+ anv_device_set_lost(device, "GPU hung on one of our command buffers");
return vk_errorf(device->instance, device, VK_ERROR_DEVICE_LOST,
"GPU hung on one of our command buffers");
} else if (pending) {
- device->lost = true;
+ anv_device_set_lost(device, "GPU hung with commands in-flight");
return vk_errorf(device->instance, device, VK_ERROR_DEVICE_LOST,
"GPU hung with commands in-flight");
}
@@ -2092,7 +2098,7 @@ anv_device_bo_busy(struct anv_device *device, struct anv_bo *bo)
return VK_NOT_READY;
} else if (ret == -1) {
/* We don't know the real error. */
- device->lost = true;
+ anv_device_set_lost(device, "gem wait failed: %m");
return vk_errorf(device->instance, device, VK_ERROR_DEVICE_LOST,
"gem wait failed: %m");
}
@@ -2115,7 +2121,7 @@ anv_device_wait(struct anv_device *device, struct anv_bo *bo,
return VK_TIMEOUT;
} else if (ret == -1) {
/* We don't know the real error. */
- device->lost = true;
+ anv_device_set_lost(device, "gem wait failed: %m");
return vk_errorf(device->instance, device, VK_ERROR_DEVICE_LOST,
"gem wait failed: %m");
}
@@ -2132,7 +2138,7 @@ VkResult anv_DeviceWaitIdle(
VkDevice _device)
{
ANV_FROM_HANDLE(anv_device, device, _device);
- if (unlikely(device->lost))
+ if (anv_device_is_lost(device))
return VK_ERROR_DEVICE_LOST;
struct anv_batch batch;
@@ -2806,7 +2812,7 @@ VkResult anv_QueueBindSparse(
VkFence fence)
{
ANV_FROM_HANDLE(anv_queue, queue, _queue);
- if (unlikely(queue->device->lost))
+ if (anv_device_is_lost(queue->device))
return VK_ERROR_DEVICE_LOST;
return vk_error(VK_ERROR_FEATURE_NOT_PRESENT);
@@ -2864,7 +2870,7 @@ VkResult anv_GetEventStatus(
ANV_FROM_HANDLE(anv_device, device, _device);
ANV_FROM_HANDLE(anv_event, event, _event);
- if (unlikely(device->lost))
+ if (anv_device_is_lost(device))
return VK_ERROR_DEVICE_LOST;
if (!device->info.has_llc) {
@@ -3094,7 +3100,7 @@ VkResult anv_GetCalibratedTimestampsEXT(
&pTimestamps[d]);
if (ret != 0) {
- device->lost = TRUE;
+ anv_device_set_lost(device, "Failed to get a timestamp");
return vk_errorf(device->instance, device, VK_ERROR_DEVICE_LOST,
"Failed to read the TIMESTAMP register: %m");
}
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index a3a041ab322..a3ab971b6fd 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -1028,7 +1028,7 @@ struct anv_device {
pthread_mutex_t mutex;
pthread_cond_t queue_submit;
- bool lost;
+ bool _lost;
};
static inline struct anv_state_pool *
@@ -1075,6 +1075,15 @@ anv_state_flush(struct anv_device *device, struct anv_state state)
void anv_device_init_blorp(struct anv_device *device);
void anv_device_finish_blorp(struct anv_device *device);
+void anv_device_set_lost(struct anv_device *device,
+ const char *msg, ...);
+
+static inline bool
+anv_device_is_lost(struct anv_device *device)
+{
+ return unlikely(device->_lost);
+}
+
VkResult anv_device_execbuf(struct anv_device *device,
struct drm_i915_gem_execbuffer2 *execbuf,
struct anv_bo **execbuf_bos);
diff --git a/src/intel/vulkan/anv_queue.c b/src/intel/vulkan/anv_queue.c
index cf063701b8d..8e9f743fcb7 100644
--- a/src/intel/vulkan/anv_queue.c
+++ b/src/intel/vulkan/anv_queue.c
@@ -42,7 +42,7 @@ anv_device_execbuf(struct anv_device *device,
int ret = device->no_hw ? 0 : anv_gem_execbuffer(device, execbuf);
if (ret != 0) {
/* We don't know the real error. */
- device->lost = true;
+ anv_device_set_lost(device, "execbuf2 failed: %m");
return vk_errorf(device->instance, device, VK_ERROR_DEVICE_LOST,
"execbuf2 failed: %m");
}
@@ -245,7 +245,7 @@ out:
*/
result = vk_errorf(device->instance, device, VK_ERROR_DEVICE_LOST,
"vkQueueSubmit() failed");
- device->lost = true;
+ anv_device_set_lost(device, "vkQueueSubmit() failed");
}
pthread_mutex_unlock(&device->mutex);
@@ -398,7 +398,7 @@ VkResult anv_GetFenceStatus(
ANV_FROM_HANDLE(anv_device, device, _device);
ANV_FROM_HANDLE(anv_fence, fence, _fence);
- if (unlikely(device->lost))
+ if (anv_device_is_lost(device))
return VK_ERROR_DEVICE_LOST;
struct anv_fence_impl *impl =
@@ -438,7 +438,7 @@ VkResult anv_GetFenceStatus(
return VK_NOT_READY;
} else {
/* We don't know the real error. */
- device->lost = true;
+ anv_device_set_lost(device, "drm_syncobj_wait failed: %m");
return vk_errorf(device->instance, device, VK_ERROR_DEVICE_LOST,
"drm_syncobj_wait failed: %m");
}
@@ -526,7 +526,7 @@ anv_wait_for_syncobj_fences(struct anv_device *device,
return VK_TIMEOUT;
} else {
/* We don't know the real error. */
- device->lost = true;
+ anv_device_set_lost(device, "drm_syncobj_wait failed: %m");
return vk_errorf(device->instance, device, VK_ERROR_DEVICE_LOST,
"drm_syncobj_wait failed: %m");
}
@@ -670,7 +670,7 @@ anv_wait_for_bo_fences(struct anv_device *device,
}
done:
- if (unlikely(device->lost))
+ if (anv_device_is_lost(device))
return VK_ERROR_DEVICE_LOST;
return result;
@@ -760,7 +760,7 @@ VkResult anv_WaitForFences(
{
ANV_FROM_HANDLE(anv_device, device, _device);
- if (unlikely(device->lost))
+ if (anv_device_is_lost(device))
return VK_ERROR_DEVICE_LOST;
if (anv_all_fences_syncobj(fenceCount, pFences)) {
diff --git a/src/intel/vulkan/genX_query.c b/src/intel/vulkan/genX_query.c
index 7533ec05095..7dd9112d296 100644
--- a/src/intel/vulkan/genX_query.c
+++ b/src/intel/vulkan/genX_query.c
@@ -181,7 +181,7 @@ wait_for_available(struct anv_device *device,
continue;
} else if (ret == -1) {
/* We don't know the real error. */
- device->lost = true;
+ anv_device_set_lost(device, "gem wait failed: %m");
return vk_errorf(device->instance, device, VK_ERROR_DEVICE_LOST,
"gem wait failed: %m");
} else {
@@ -224,7 +224,7 @@ VkResult genX(GetQueryPoolResults)(
pool->type == VK_QUERY_TYPE_PIPELINE_STATISTICS ||
pool->type == VK_QUERY_TYPE_TIMESTAMP);
- if (unlikely(device->lost))
+ if (anv_device_is_lost(device))
return VK_ERROR_DEVICE_LOST;
if (pData == NULL)