drm/amdgpu: limit visible vram if it's smaller than the BAR
authorAlex Deucher <alexander.deucher@amd.com>
Wed, 9 Dec 2015 20:36:40 +0000 (15:36 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 17 Dec 2015 16:56:41 +0000 (11:56 -0500)
In some cases the amount of vram may be less than the BAR size,
if so, limit visible vram to the amount of actual vram, not the
BAR size.

Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c

index 7427d8cd4c43fae6068c8a3455ac98f3627ff044..868505753a9ad56ae7725c2521eda28891ed4bfe 100644 (file)
@@ -370,6 +370,10 @@ static int gmc_v7_0_mc_init(struct amdgpu_device *adev)
        adev->mc.real_vram_size = RREG32(mmCONFIG_MEMSIZE) * 1024ULL * 1024ULL;
        adev->mc.visible_vram_size = adev->mc.aper_size;
 
+       /* In case the PCI BAR is larger than the actual amount of vram */
+       if (adev->mc.visible_vram_size > adev->mc.real_vram_size)
+               adev->mc.visible_vram_size = adev->mc.real_vram_size;
+
        /* unless the user had overridden it, set the gart
         * size equal to the 1024 or vram, whichever is larger.
         */
index cb0e50ebb5285cef90b4a2879cd3cd800129c296..a2d869d30cf47f31c0eaf03911b8c33ab0e93b0f 100644 (file)
@@ -476,6 +476,10 @@ static int gmc_v8_0_mc_init(struct amdgpu_device *adev)
        adev->mc.real_vram_size = RREG32(mmCONFIG_MEMSIZE) * 1024ULL * 1024ULL;
        adev->mc.visible_vram_size = adev->mc.aper_size;
 
+       /* In case the PCI BAR is larger than the actual amount of vram */
+       if (adev->mc.visible_vram_size > adev->mc.real_vram_size)
+               adev->mc.visible_vram_size = adev->mc.real_vram_size;
+
        /* unless the user had overridden it, set the gart
         * size equal to the 1024 or vram, whichever is larger.
         */