From b9266a122bb9e20fe22a414ada181b3f649a3134 Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Mon, 10 Nov 2025 10:45:39 +0200 Subject: [PATCH] anv: ensure shader printf is functional on all backends Also ensure the printfs are read even if the device is lost or ran into a fault. Signed-off-by: Lionel Landwerlin Reviewed-by: Ivan Briano Part-of: --- src/intel/vulkan/anv_queue.c | 27 ++++++++++++++++++++------- src/intel/vulkan/i915/anv_device.c | 21 ++++++++++++--------- src/intel/vulkan/xe/anv_device.c | 18 +++++++++++------- 3 files changed, 43 insertions(+), 23 deletions(-) diff --git a/src/intel/vulkan/anv_queue.c b/src/intel/vulkan/anv_queue.c index 42c3b57572b..db2ee8cee2c 100644 --- a/src/intel/vulkan/anv_queue.c +++ b/src/intel/vulkan/anv_queue.c @@ -153,11 +153,26 @@ anv_QueueWaitIdle(VkQueue _queue) if (queue->vk.submit.mode != VK_QUEUE_SUBMIT_MODE_THREADED) { int ret = anv_xe_wait_exec_queue_idle(device, queue->exec_queue_id); - if (ret == 0) - return VK_SUCCESS; - if (ret == -ECANCELED) - return VK_ERROR_DEVICE_LOST; - return vk_errorf(device, VK_ERROR_UNKNOWN, "anv_xe_wait_exec_queue_idle failed: %m"); + VkResult result; + switch (ret) { + case 0: + result = VK_SUCCESS; + break; + case -ECANCELED: + result = VK_ERROR_DEVICE_LOST; + break; + default: + result = vk_errorf(device, VK_ERROR_UNKNOWN, "anv_xe_wait_exec_queue_idle failed: %m"); + break; + } + + if (INTEL_DEBUG(DEBUG_SHADER_PRINT)) { + VkResult print_result = + vk_check_printf_status(&device->vk, &device->printf); + result = result != VK_SUCCESS ? result : print_result; + } + + return result; } FALLTHROUGH; case INTEL_KMD_TYPE_I915: @@ -165,6 +180,4 @@ anv_QueueWaitIdle(VkQueue _queue) default: UNREACHABLE("Missing"); } - - return VK_SUCCESS; } diff --git a/src/intel/vulkan/i915/anv_device.c b/src/intel/vulkan/i915/anv_device.c index a2a3dded0fc..ecbe7663f1c 100644 --- a/src/intel/vulkan/i915/anv_device.c +++ b/src/intel/vulkan/i915/anv_device.c @@ -365,25 +365,28 @@ anv_i915_device_check_status(struct vk_device *vk_device) result = anv_gem_context_get_reset_stats(device, device->queues[i].context_id); if (result != VK_SUCCESS) - return result; + goto done; if (device->queues[i].companion_rcs_id != 0) { uint32_t context_id = device->queues[i].companion_rcs_id; result = anv_gem_context_get_reset_stats(device, context_id); - if (result != VK_SUCCESS) { - return result; - } + if (result != VK_SUCCESS) + goto done; } } } else { result = anv_gem_context_get_reset_stats(device, device->context_id); } - if (result != VK_SUCCESS) - return result; - - if (INTEL_DEBUG(DEBUG_SHADER_PRINT)) - result = vk_check_printf_status(vk_device, &device->printf); + done: + if (INTEL_DEBUG(DEBUG_SHADER_PRINT)) { + VkResult print_result = + vk_check_printf_status(vk_device, &device->printf); + /* Report the device error if there is one, only report the printf error + * if no device error. + */ + result = result != VK_SUCCESS ? result : print_result; + } return result; } diff --git a/src/intel/vulkan/xe/anv_device.c b/src/intel/vulkan/xe/anv_device.c index 9fc84df9c98..04d199f3c20 100644 --- a/src/intel/vulkan/xe/anv_device.c +++ b/src/intel/vulkan/xe/anv_device.c @@ -198,21 +198,25 @@ anv_xe_device_check_status(struct vk_device *vk_device) for (uint32_t i = 0; i < device->queue_count; i++) { result = anv_xe_get_device_status(device, device->queues[i].exec_queue_id); if (result != VK_SUCCESS) - return result; + goto done; if (device->queues[i].companion_rcs_id != 0) { uint32_t exec_queue_id = device->queues[i].companion_rcs_id; result = anv_xe_get_device_status(device, exec_queue_id); if (result != VK_SUCCESS) - return result; + goto done; } } - if (result != VK_SUCCESS) - return result; - - if (INTEL_DEBUG(DEBUG_SHADER_PRINT)) - result = vk_check_printf_status(vk_device, &device->printf); + done: + if (INTEL_DEBUG(DEBUG_SHADER_PRINT)) { + VkResult print_result = + vk_check_printf_status(vk_device, &device->printf); + /* Report the device error if there is one, only report the printf error + * if no device error. + */ + result = result != VK_SUCCESS ? result : print_result; + } return result; }