radeonsi: limit the sqtt buffer size

We don't want the buffer size to wraparound to 0.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37882>
This commit is contained in:
Pierre-Eric Pelloux-Prayer 2025-10-15 09:52:23 +02:00 committed by Marge Bot
parent a7bf37e3bd
commit d3f8571e84

View file

@ -266,12 +266,21 @@ si_sqtt_resize_bo(struct si_context *sctx)
struct pb_buffer_lean *bo = sctx->sqtt->bo;
radeon_bo_reference(sctx->screen->ws, &bo, NULL);
/* Double the size of the thread trace buffer per SE. */
sctx->sqtt->buffer_size *= 2;
mesa_loge("Failed to get the thread trace because the buffer "
"was too small, resizing to %d KB",
sctx->sqtt->buffer_size / 1024);
if (sctx->sqtt->buffer_size < UINT32_MAX / 2) {
/* Double the size of the thread trace buffer per SE. */
sctx->sqtt->buffer_size *= 2;
mesa_loge("Failed to get the thread trace because the buffer "
"was too small, resizing to %d kB",
sctx->sqtt->buffer_size / 1024);
} else {
mesa_loge("Failed to get the thread trace because the buffer "
"was too small (%d kB). Cancelling trace capture.",
sctx->sqtt->buffer_size / 1024);
if (sctx->sqtt->instruction_timing_enabled)
mesa_loge("Try again with AMD_THREAD_TRACE_INSTRUCTION_TIMING=false"
" to reduce the size of the captured data.");
return false;
}
/* Re-create the thread trace BO. */
return si_sqtt_init_bo(sctx);
@ -329,6 +338,7 @@ bool si_init_sqtt(struct si_context *sctx)
/* Default buffer size set to 32MB per SE. */
sctx->sqtt->buffer_size =
debug_get_num_option("AMD_THREAD_TRACE_BUFFER_SIZE", 32 * 1024) * 1024;
assert(sctx->sqtt->buffer_size);
sctx->sqtt->instruction_timing_enabled =
debug_get_bool_option("AMD_THREAD_TRACE_INSTRUCTION_TIMING", true);
sctx->sqtt->start_frame = 10;