radv: fix RADV_DEBUG=hang with multiple cmdbuffer per submission

With RADV_DEBUG=hang, there is only one cmdbuffer per submission and
this has been broken recently.

This fixes a segfault when generating GPU hang reports.

Fixes: 76deaa1b1a ("radv: Refactor command buffer handling in radv_queue_submit_normal.")
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20860>
(cherry picked from commit 7b76d46e38)
This commit is contained in:
Samuel Pitoiset 2023-01-23 16:43:32 +01:00 committed by Dylan Baker
parent 497e3028f0
commit 450ac592e2
2 changed files with 4 additions and 2 deletions

View file

@ -715,7 +715,7 @@
"description": "radv: fix RADV_DEBUG=hang with multiple cmdbuffer per submission",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "76deaa1b1a92ea6997d298e9b6ac1ed6433ba369"
},

View file

@ -5819,6 +5819,7 @@ radv_queue_submit_normal(struct radv_queue *queue, struct vk_queue_submit *submi
const bool last_submit = j + advance == cmd_buffer_count;
bool submit_ace = false;
unsigned num_submitted_cs = 0;
unsigned cs_idx = 0;
if (queue->device->trace_bo)
*queue->device->trace_id_ptr = 0;
@ -5841,6 +5842,7 @@ radv_queue_submit_normal(struct radv_queue *queue, struct vk_queue_submit *submi
can_patch &= !(cmd_buffer->usage_flags & VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT);
cs_array[num_submitted_cs++] = cmd_buffer->cs;
cs_idx = num_submitted_cs - 1;
}
/* Add gang wait postambles to make sure the gang leader waits for the whole gang. */
@ -5864,7 +5866,7 @@ radv_queue_submit_normal(struct radv_queue *queue, struct vk_queue_submit *submi
goto fail;
if (queue->device->trace_bo) {
radv_check_gpu_hangs(queue, cs_array[j]);
radv_check_gpu_hangs(queue, cs_array[cs_idx]);
}
if (queue->device->tma_bo) {