aboutsummaryrefslogtreecommitdiffstats
path: root/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/1968-drm-amdgpu-Don-t-add-KFD-eviction-fence-to-DGMA-BOs.patch
blob: 02eeeef2102b7589649ba001bfb89913d88ba4b7 (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
57
58
59
60
61
62
63
64
From b88e18b5b246f789da1adeb3a74d5f66ad1371da Mon Sep 17 00:00:00 2001
From: Harish Kasiviswanathan <Harish.Kasiviswanathan@amd.com>
Date: Fri, 13 Oct 2017 17:12:56 -0500
Subject: [PATCH 1968/4131] drm/amdgpu: Don't add KFD eviction fence to DGMA
 BOs

DGMA buffers are pinned at creation. No need to add KFD eviction fence
to it instead just increment the pin count.

Currently, when graphics does a CS on a shared (with KFD) DGMA BO it
triggers an eviction of KFD process. This happens because DGMA BO has
KFD eviction fence attached to it. This change will fix this issue.

NOTE: This is a temporary workaround. A general solution is in the works
that will avoid eviction fences being added to sync object based on
fence owner.

Change-Id: Ie8e4bf86ba808fb6ef35680637c0ffdf7ffb600e
Signed-off-by: Harish Kasiviswanathan <Harish.Kasiviswanathan@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
index ad419cf..427f7b3 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
@@ -1353,7 +1353,13 @@ int amdgpu_amdkfd_gpuvm_map_memory_to_gpu(
 		}
 	}
 
-	if (amdgpu_ttm_tt_get_usermm(bo->tbo.ttm) == NULL)
+	if (mem->domain & AMDGPU_GEM_DOMAIN_DGMA) {
+		ret = amdgpu_bo_pin(bo, mem->domain, NULL);
+		if (ret != 0) {
+			pr_err("Unable to pin DGMA BO\n");
+			goto map_bo_to_gpuvm_failed;
+		}
+	} else if (amdgpu_ttm_tt_get_usermm(bo->tbo.ttm) == NULL)
 		amdgpu_bo_fence(bo,
 				&kfd_vm->process_info->eviction_fence->base,
 				true);
@@ -1619,11 +1625,14 @@ int amdgpu_amdkfd_gpuvm_unmap_memory_from_gpu(
 	/* If BO is unmapped from all VMs, unfence it. It can be evicted if
 	 * required.
 	 */
-	if (mem->mapped_to_gpu_memory == 0 &&
-	    !amdgpu_ttm_tt_get_usermm(mem->bo->tbo.ttm))
-		amdgpu_amdkfd_remove_eviction_fence(mem->bo,
+	if (mem->mapped_to_gpu_memory == 0) {
+		if (mem->domain & AMDGPU_GEM_DOMAIN_DGMA)
+			amdgpu_bo_unpin(mem->bo);
+		else if (!amdgpu_ttm_tt_get_usermm(mem->bo->tbo.ttm))
+			amdgpu_amdkfd_remove_eviction_fence(mem->bo,
 						process_info->eviction_fence,
-						    NULL, NULL);
+						NULL, NULL);
+	}
 
 	if (mapped_before == mem->mapped_to_gpu_memory) {
 		pr_debug("BO VA 0x%llx size 0x%lx is not mapped to vm %p\n",
-- 
2.7.4