anv/xe: rework set_lost handling in xe_exec_ioctl()

Move the handling to inside xe_exec_ioctl() and also rework things in
a way where we can tell from which caller the error is coming from.

v2:
 - properly return VkResult (José).
 - adjust the patch due to reordering the series.

Reviewed-by: Rohan Garg <rohan.garg@intel.com> (v1)
Reviewed-by: José Roberto de Souza <jose.souza@intel.com>
Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37559>
This commit is contained in:
Paulo Zanoni 2025-09-17 14:49:19 -07:00 committed by Marge Bot
parent e694c7e84e
commit 0932d0c7e0

View file

@ -132,13 +132,22 @@ xe_exec_print_debug(struct anv_queue *queue, uint32_t cmd_buffer_count,
perf_query_pool, perf_query_pass);
}
static int
xe_exec_ioctl(struct anv_device *device, struct drm_xe_exec *exec)
{
if (unlikely(device->info->no_hw))
return 0;
#define xe_exec_ioctl(d, e) xe_exec_ioctl_impl((d), (e), __func__, __LINE__)
return intel_ioctl(device->fd, DRM_IOCTL_XE_EXEC, exec);
static VkResult
xe_exec_ioctl_impl(struct anv_device *device, struct drm_xe_exec *exec,
const char *func, int line)
{
int ret;
if (unlikely(device->info->no_hw))
return VK_SUCCESS;
ret = intel_ioctl(device->fd, DRM_IOCTL_XE_EXEC, exec);
if (ret)
return vk_device_set_lost(&device->vk, "%s(%d) failed: %m", func, line);
return VK_SUCCESS;
}
VkResult
@ -206,8 +215,9 @@ xe_queue_exec_async(struct anv_async_submit *submit,
xe_exec_print_debug(queue, 0, NULL, NULL, 0, &exec);
anv_async_submit_print_batch(submit);
if (xe_exec_ioctl(device, &exec))
return vk_device_set_lost(&device->vk, "anv_xe_queue_exec_locked failed: %m");
VkResult result = xe_exec_ioctl(device, &exec);
if (result != VK_SUCCESS)
return result;
return anv_queue_post_submit(queue, VK_SUCCESS);
}
@ -252,8 +262,7 @@ xe_companion_rcs_queue_exec_locked(struct anv_queue *queue,
anv_measure_submit(companion_rcs_cmd_buffer);
xe_exec_print_debug(queue, 1, &companion_rcs_cmd_buffer, NULL, 0, &exec);
if (xe_exec_ioctl(device, &exec))
result = vk_device_set_lost(&device->vk, "anv_xe_queue_exec_locked failed: %m");
result = xe_exec_ioctl(device, &exec);
vk_free(&device->vk.alloc, xe_syncs);
@ -373,16 +382,13 @@ xe_queue_exec_locked(struct anv_queue *queue,
xe_syncs[1].timeline_value = intel_bind_timeline_get_last_point(&device->perf_timeline);
}
if (result == VK_SUCCESS) {
if (xe_exec_ioctl(device, &perf_query_exec))
result = vk_device_set_lost(&device->vk, "perf_query_exec failed: %m");
}
if (result == VK_SUCCESS)
result = xe_exec_ioctl(device, &perf_query_exec);
}
if (result == VK_SUCCESS) {
if (xe_exec_ioctl(device, &exec))
result = vk_device_set_lost(&device->vk, "anv_xe_queue_exec_locked failed: %m");
}
if (result == VK_SUCCESS)
result = xe_exec_ioctl(device, &exec);
vk_free(&device->vk.alloc, xe_syncs);
if (cmd_buffer_count != 0 && cmd_buffers[0]->companion_rcs_cmd_buffer &&