radv, radeonsi: do sqtt buffer_size calc using uint64

The final size is uint64_t so use it from the start to avoid
overflow issues.

Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41383>
This commit is contained in:
Pierre-Eric Pelloux-Prayer 2026-05-06 10:58:33 +02:00 committed by Marge Bot
parent 5801ad2308
commit 2854c1b778
2 changed files with 6 additions and 7 deletions

View file

@ -346,18 +346,18 @@ radv_sqtt_init_bo(struct radv_device *device)
VkDeviceMemory memory, staging_memory;
VkBuffer buffer, staging_buffer;
VkResult result;
uint64_t size;
uint64_t per_se_size, size;
uint64_t va;
void *ptr;
/* The buffer size and address need to be aligned in HW regs. Align the
* size as early as possible so that we do all the allocation & addressing
* correctly. */
device->sqtt.buffer_size = align64(device->sqtt.buffer_size, 1ull << SQTT_BUFFER_ALIGN_SHIFT);
per_se_size = align64(device->sqtt.buffer_size, 1ull << SQTT_BUFFER_ALIGN_SHIFT);
/* Compute total size of the thread trace BO for all SEs. */
size = align64(sizeof(struct ac_sqtt_data_info) * max_se, 1ull << SQTT_BUFFER_ALIGN_SHIFT);
size += device->sqtt.buffer_size * (uint64_t)max_se;
size += per_se_size * (uint64_t)max_se;
/* Allocate the SQTT buffer (it must be in VRAM). */
const uint32_t memory_type_index = radv_find_memory_index(

View file

@ -24,18 +24,17 @@ si_emit_spi_config_cntl(struct si_context *sctx,
static bool si_sqtt_init_bo(struct si_context *sctx)
{
unsigned max_se = sctx->screen->info.max_se;
uint64_t size;
uint64_t per_se_size, size;
/* The buffer size and address need to be aligned in HW regs. Align the
* size as early as possible so that we do all the allocation & addressing
* correctly. */
sctx->sqtt->buffer_size =
align64(sctx->sqtt->buffer_size, 1ull << SQTT_BUFFER_ALIGN_SHIFT);
per_se_size = align64(sctx->sqtt->buffer_size, 1ull << SQTT_BUFFER_ALIGN_SHIFT);
/* Compute total size of the thread trace BO for all SEs. */
size = align64(sizeof(struct ac_sqtt_data_info) * max_se,
1ull << SQTT_BUFFER_ALIGN_SHIFT);
size += sctx->sqtt->buffer_size * (uint64_t)max_se;
size += per_se_size * (uint64_t)max_se;
if (size > UINT32_MAX)
return false;