turnip: Use the new common device lost tracking

Signed-off-by: Hyunjun Ko <zzoon@igalia.com>
Reviewed-by: Danylo Piliaiev <dpiliaiev@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14105>
This commit is contained in:
Hyunjun Ko
2021-11-18 04:05:27 +00:00
committed by Marge Bot
parent 14a4600b62
commit f976f71fb0
5 changed files with 7 additions and 41 deletions

View File

@@ -1569,7 +1569,6 @@ tu_CreateDevice(VkPhysicalDevice physicalDevice,
device->instance = physical_device->instance;
device->physical_device = physical_device;
device->fd = physical_device->local_fd;
device->_lost = false;
mtx_init(&device->bo_mutex, mtx_plain);
pthread_mutex_init(&device->submit_mutex, NULL);
@@ -1818,27 +1817,6 @@ tu_DestroyDevice(VkDevice _device, const VkAllocationCallbacks *pAllocator)
vk_free(&device->vk.alloc, device);
}
VkResult
_tu_device_set_lost(struct tu_device *device,
const char *msg, ...)
{
/* Set the flag indicating that waits should return in finite time even
* after device loss.
*/
p_atomic_inc(&device->_lost);
/* TODO: Report the log message through VkDebugReportCallbackEXT instead */
va_list ap;
va_start(ap, msg);
mesa_loge_v(msg, ap);
va_end(ap);
if (env_var_as_boolean("TU_ABORT_ON_DEVICE_LOSS", false))
abort();
return VK_ERROR_DEVICE_LOST;
}
VkResult
tu_get_scratch_bo(struct tu_device *dev, uint64_t size, struct tu_bo **bo)
{
@@ -1898,7 +1876,7 @@ tu_QueueWaitIdle(VkQueue _queue)
{
TU_FROM_HANDLE(tu_queue, queue, _queue);
if (tu_device_is_lost(queue->device))
if (vk_device_is_lost(&queue->device->vk))
return VK_ERROR_DEVICE_LOST;
if (queue->fence < 0)

View File

@@ -1189,7 +1189,7 @@ tu_queue_submit_locked(struct tu_queue *queue, struct tu_queue_submit *submit)
mtx_unlock(&queue->device->bo_mutex);
if (ret)
return tu_device_set_lost(queue->device, "submit failed: %s\n",
return vk_device_set_lost(&queue->device->vk, "submit failed: %s\n",
strerror(errno));
/* restore permanent payload on wait */
@@ -1570,7 +1570,7 @@ tu_WaitForFences(VkDevice _device,
{
TU_FROM_HANDLE(tu_device, device, _device);
if (tu_device_is_lost(device))
if (vk_device_is_lost(&device->vk))
return VK_ERROR_DEVICE_LOST;
uint32_t handles[fenceCount];
@@ -1600,7 +1600,7 @@ tu_ResetFences(VkDevice _device, uint32_t fenceCount, const VkFence *pFences)
.count_handles = fenceCount,
});
if (ret) {
tu_device_set_lost(device, "DRM_IOCTL_SYNCOBJ_RESET failure: %s",
vk_device_set_lost(&device->vk, "DRM_IOCTL_SYNCOBJ_RESET failure: %s",
strerror(errno));
}

View File

@@ -432,7 +432,7 @@ tu_QueueSubmit(VkQueue _queue,
int ret = safe_ioctl(queue->device->physical_device->local_fd,
IOCTL_KGSL_GPU_COMMAND, &req);
if (ret) {
result = tu_device_set_lost(queue->device,
result = vk_device_set_lost(&queue->device->vk,
"submit failed: %s\n", strerror(errno));
goto fail;
}
@@ -447,7 +447,7 @@ tu_QueueSubmit(VkQueue _queue,
if (i == submitCount - 1) {
int fd = timestamp_to_fd(queue, req.timestamp);
if (fd < 0) {
result = tu_device_set_lost(queue->device,
result = vk_device_set_lost(&queue->device->vk,
"Failed to create sync file for timestamp: %s\n",
strerror(errno));
goto fail;

View File

@@ -379,7 +379,6 @@ struct tu_device
struct tu_physical_device *physical_device;
int fd;
int _lost;
struct ir3_compiler *compiler;
@@ -452,17 +451,6 @@ void tu_init_clear_blit_shaders(struct tu_device *dev);
void tu_destroy_clear_blit_shaders(struct tu_device *dev);
VkResult _tu_device_set_lost(struct tu_device *device,
const char *msg, ...) PRINTFLIKE(2, 3);
#define tu_device_set_lost(dev, ...) \
_tu_device_set_lost(dev, __VA_ARGS__)
static inline bool
tu_device_is_lost(struct tu_device *device)
{
return unlikely(p_atomic_read(&device->_lost));
}
VkResult
tu_device_submit_deferred_locked(struct tu_device *dev);

View File

@@ -541,7 +541,7 @@ tu_GetQueryPoolResults(VkDevice _device,
TU_FROM_HANDLE(tu_query_pool, pool, queryPool);
assert(firstQuery + queryCount <= pool->size);
if (tu_device_is_lost(device))
if (vk_device_is_lost(&device->vk))
return VK_ERROR_DEVICE_LOST;
switch (pool->type) {