From: jsg Date: Thu, 27 Jan 2022 23:10:02 +0000 (+0000) Subject: drm/amdgpu: fixup bad vram size on gmc v8 X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=8f5eade93abdfc513ba9a9bcd18f48a997104bae;p=openbsd drm/amdgpu: fixup bad vram size on gmc v8 From Zongmin Zhou 493b87970061f044c5cf795cfd1d679d114844ed in linux 5.15.y/5.15.17 11544d77e3974924c5a9c8a8320b996a3e9b2f8b in mainline linux --- diff --git a/sys/dev/pci/drm/amd/amdgpu/gmc_v8_0.c b/sys/dev/pci/drm/amd/amdgpu/gmc_v8_0.c index 339ffd9b691..587206dd388 100644 --- a/sys/dev/pci/drm/amd/amdgpu/gmc_v8_0.c +++ b/sys/dev/pci/drm/amd/amdgpu/gmc_v8_0.c @@ -515,10 +515,10 @@ static void gmc_v8_0_mc_program(struct amdgpu_device *adev) static int gmc_v8_0_mc_init(struct amdgpu_device *adev) { int r; + u32 tmp; adev->gmc.vram_width = amdgpu_atombios_get_vram_width(adev); if (!adev->gmc.vram_width) { - u32 tmp; int chansize, numchan; /* Get VRAM informations */ @@ -562,8 +562,15 @@ static int gmc_v8_0_mc_init(struct amdgpu_device *adev) adev->gmc.vram_width = numchan * chansize; } /* size in MB on si */ - adev->gmc.mc_vram_size = RREG32(mmCONFIG_MEMSIZE) * 1024ULL * 1024ULL; - adev->gmc.real_vram_size = RREG32(mmCONFIG_MEMSIZE) * 1024ULL * 1024ULL; + tmp = RREG32(mmCONFIG_MEMSIZE); + /* some boards may have garbage in the upper 16 bits */ + if (tmp & 0xffff0000) { + DRM_INFO("Probable bad vram size: 0x%08x\n", tmp); + if (tmp & 0xffff) + tmp &= 0xffff; + } + adev->gmc.mc_vram_size = tmp * 1024ULL * 1024ULL; + adev->gmc.real_vram_size = adev->gmc.mc_vram_size; if (!(adev->flags & AMD_IS_APU)) { r = amdgpu_device_resize_fb_bar(adev);