aboutsummaryrefslogtreecommitdiffstats
path: root/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/3705-drm-amdgpu-Compute-GPU-VM-space-if-unchanged-from-de.patch
blob: 008aee894d155f15f021fca7f3790bb4be0ad487 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
From 89c5d94ac1687ff38fc3ef5ada7772be1d0eb5c1 Mon Sep 17 00:00:00 2001
From: Kent Russell <kent.russell@amd.com>
Date: Fri, 23 Feb 2018 11:49:46 -0500
Subject: [PATCH 3705/4131] drm/amdgpu: Compute GPU VM space if unchanged from
 default

Change-Id: I9a20db93c2ad75a0cd07c7d084e9faee5d554cf4
Signed-off-by: Kent Russell <kent.russell@amd.com>
Signed-off-by: Kalyan Alle <kalyan.alle@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 29 ++++++++++++++++++++++++++---
 1 file changed, 26 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index e8501a4..953d2fb 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -763,9 +763,32 @@ static void amdgpu_device_check_block_size(struct amdgpu_device *adev)
 
 static void amdgpu_device_check_vm_size(struct amdgpu_device *adev)
 {
-	/* no need to check the default value */
-	if (amdgpu_vm_size == -1)
-		return;
+	struct sysinfo si;
+	int phys_ram_gb, amdgpu_vm_size_aligned;
+
+	/* Compute the GPU VM space only if the user
+	* hasn't changed it from the default.
+	* In order for Raven ATC memory to work, vm size should be 256TB.
+	* So we do not compute the new vm size here for Raven.
+	*/
+	if (amdgpu_vm_size == -1 && adev->asic_type != CHIP_RAVEN) {
+		/* Computation depends on the amount of physical RAM available.
+		* Cannot exceed 1TB.
+		*/
+		si_meminfo(&si);
+		phys_ram_gb = ((uint64_t)si.totalram * si.mem_unit) >> 30;
+		amdgpu_vm_size = min(phys_ram_gb * 3 + 16, 1024);
+
+		/* GPUVM sizes are almost never perfect powers of two.
+		* Round up to nearest power of two starting from
+		* the minimum allowed but aligned size of 32GB
+		*/
+		amdgpu_vm_size_aligned = 32;
+		while (amdgpu_vm_size > amdgpu_vm_size_aligned)
+			amdgpu_vm_size_aligned *= 2;
+
+		amdgpu_vm_size = amdgpu_vm_size_aligned;
+	}
 
 	if (amdgpu_vm_size != -1 && amdgpu_vm_size < 1) {
 		dev_warn(adev->dev, "VM size (%d) too small, min is 1GB\n",
-- 
2.7.4