From d3f8571e84f07b008a6d4be8ffc5e5825b3c3324 Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Wed, 15 Oct 2025 09:52:23 +0200 Subject: [PATCH] radeonsi: limit the sqtt buffer size MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We don't want the buffer size to wraparound to 0. Reviewed-by: Marek Olšák Part-of: --- src/gallium/drivers/radeonsi/si_sqtt.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/gallium/drivers/radeonsi/si_sqtt.c b/src/gallium/drivers/radeonsi/si_sqtt.c index 8ad7e747be1..f9ff76c8125 100644 --- a/src/gallium/drivers/radeonsi/si_sqtt.c +++ b/src/gallium/drivers/radeonsi/si_sqtt.c @@ -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;