Skip to content

Commit 516e332

Browse files
Zongmin Zhougregkh
authored andcommitted
drm/amdgpu: fixup bad vram size on gmc v8
[ Upstream commit 11544d7 ] Some boards(like RX550) seem to have garbage in the upper 16 bits of the vram size register. Check for this and clamp the size properly. Fixes boards reporting bogus amounts of vram. after add this patch,the maximum GPU VRAM size is 64GB, otherwise only 64GB vram size will be used. Signed-off-by: Zongmin Zhou<zhouzongmin@kylinos.cn> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent ee88ff1 commit 516e332

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

‎drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -524,10 +524,10 @@ static void gmc_v8_0_mc_program(struct amdgpu_device *adev)
524524
static int gmc_v8_0_mc_init(struct amdgpu_device *adev)
525525
{
526526
int r;
527+
u32 tmp;
527528

528529
adev->gmc.vram_width = amdgpu_atombios_get_vram_width(adev);
529530
if (!adev->gmc.vram_width) {
530-
u32 tmp;
531531
int chansize, numchan;
532532

533533
/* Get VRAM informations */
@@ -571,8 +571,15 @@ static int gmc_v8_0_mc_init(struct amdgpu_device *adev)
571571
adev->gmc.vram_width = numchan * chansize;
572572
}
573573
/* size in MB on si */
574-
adev->gmc.mc_vram_size = RREG32(mmCONFIG_MEMSIZE) * 1024ULL * 1024ULL;
575-
adev->gmc.real_vram_size = RREG32(mmCONFIG_MEMSIZE) * 1024ULL * 1024ULL;
574+
tmp = RREG32(mmCONFIG_MEMSIZE);
575+
/* some boards may have garbage in the upper 16 bits */
576+
if (tmp & 0xffff0000) {
577+
DRM_INFO("Probable bad vram size: 0x%08x\n", tmp);
578+
if (tmp & 0xffff)
579+
tmp &= 0xffff;
580+
}
581+
adev->gmc.mc_vram_size = tmp * 1024ULL * 1024ULL;
582+
adev->gmc.real_vram_size = adev->gmc.mc_vram_size;
576583

577584
if (!(adev->flags & AMD_IS_APU)) {
578585
r = amdgpu_device_resize_fb_bar(adev);

0 commit comments

Comments
 (0)