[PATCH] drm/amdgpu: adjust gtt memory size

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Change-Id: If00d5b97ba9e30f9b7f68fdfc134a0f8b3ad2add
Signed-off-by: Ken Wang <Qingqing.Wang at amd.com>
---
 drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c | 7 ++++++-
 drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c | 7 ++++++-
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c
index a3b6048..0b095d5 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c
@@ -336,6 +336,11 @@ static int gmc_v7_0_mc_init(struct amdgpu_device *adev)
 {
 	u32 tmp;
 	int chansize, numchan;
+	u64 sysmem_size;
+	struct sysinfo si;
+
+	si_meminfo(&si);
+	sysmem_size = si.totalram * si.mem_unit;
 
 	/* Get VRAM informations */
 	tmp = RREG32(mmMC_ARB_RAMCFG);
@@ -392,7 +397,7 @@ static int gmc_v7_0_mc_init(struct amdgpu_device *adev)
 	 * size equal to the 1024 or vram, whichever is larger.
 	 */
 	if (amdgpu_gart_size == -1)
-		adev->mc.gtt_size = max((1024ULL << 20), adev->mc.mc_vram_size);
+		adev->mc.gtt_size = max((1024ULL << 20), min(adev->mc.mc_vram_size, sysmem_size/2));
 	else
 		adev->mc.gtt_size = (uint64_t)amdgpu_gart_size << 20;
 
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
index 02b6872..790bf7a 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
@@ -413,6 +413,11 @@ static int gmc_v8_0_mc_init(struct amdgpu_device *adev)
 {
 	u32 tmp;
 	int chansize, numchan;
+	u64 sysmem_size;
+	struct sysinfo si;
+
+	si_meminfo(&si);
+	sysmem_size = si.totalram * si.mem_unit;
 
 	/* Get VRAM informations */
 	tmp = RREG32(mmMC_ARB_RAMCFG);
@@ -469,7 +474,7 @@ static int gmc_v8_0_mc_init(struct amdgpu_device *adev)
 	 * size equal to the 1024 or vram, whichever is larger.
 	 */
 	if (amdgpu_gart_size == -1)
-		adev->mc.gtt_size = max((1024ULL << 20), adev->mc.mc_vram_size);
+		adev->mc.gtt_size = max((1024ULL << 20), min(adev->mc.mc_vram_size, sysmem_size/2));
 	else
 		adev->mc.gtt_size = (uint64_t)amdgpu_gart_size << 20;
 
-- 
2.7.4



[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux