From 9490ae55612e3634ea69f8e48c13dfddfd085931 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Thu, 9 Jun 2022 14:06:12 -0400 Subject: [PATCH] ac/gpu_info: clamp gart_size_kb and vram_size_kb to fix buggy kernel driver amdgpu returns 12 TB of GTT on Kaveri, which resulted in 0 KB of GTT after the conversion to uint32_t, which caused us to report 0 as the UBO size, which disabled UBOs and downgraded the driver to OpenGL 3.0. Fixes: aee8ee17a50 - radeonsi: change max TBO/SSBO sizes again and rework max alloc size Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/6642 Reviewed-by: Pierre-Eric Pelloux-Prayer Part-of: --- src/amd/common/ac_gpu_info.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/amd/common/ac_gpu_info.c b/src/amd/common/ac_gpu_info.c index e784b1e3f03..8c35b265c4e 100644 --- a/src/amd/common/ac_gpu_info.c +++ b/src/amd/common/ac_gpu_info.c @@ -650,8 +650,8 @@ bool ac_query_gpu_info(int fd, void *dev_p, struct radeon_info *info, info->vram_vis_size = vram_vis.heap_size; } - info->gart_size_kb = DIV_ROUND_UP(info->gart_size, 1024); - info->vram_size_kb = DIV_ROUND_UP(info->vram_size, 1024); + info->gart_size_kb = MIN2(DIV_ROUND_UP(info->gart_size, 1024), UINT32_MAX); + info->vram_size_kb = MIN2(DIV_ROUND_UP(info->vram_size, 1024), UINT32_MAX); if (info->drm_minor >= 41) { amdgpu_query_video_caps_info(dev, AMDGPU_INFO_VIDEO_CAPS_DECODE,