aboutsummaryrefslogtreecommitdiffstats
path: root/common/recipes-kernel/linux/linux-yocto-4.14.71/1582-drm-amdgpu-Ignore-eviction-fence-during-map-and-vali.patch
blob: f9fa574e8df3ed8e41fd1de155a25b4c913e97d2 (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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
From 31c1e65cee3dae4b591e90481a4bd41a0e1263af Mon Sep 17 00:00:00 2001
From: Harish Kasiviswanathan <Harish.Kasiviswanathan@amd.com>
Date: Fri, 3 Feb 2017 10:55:42 -0500
Subject: [PATCH 1582/4131] drm/amdgpu: Ignore eviction fence during map and
 validate

Temporarily remove eviction fence before map and validate. This is
necessary because during map new PTs are created and cleared. Validate
needs to wait on move fences. The eviction fence shouldn't interfere in
both these activities.

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

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
index 370daae..d08d25c6 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
@@ -449,17 +449,12 @@ static int amdgpu_amdkfd_bo_invalidate(struct amdgpu_bo *bo)
 static int validate_pt_pd_bos(struct amdgpu_device *adev, struct amdgpu_vm *vm)
 {
 	struct amdgpu_bo *pd = vm->page_directory;
-	struct amdkfd_vm *kvm = container_of(vm, struct amdkfd_vm, base);
 	struct amdgpu_vm_parser param;
 	int ret;
 
 	param.domain = AMDGPU_GEM_DOMAIN_VRAM;
 	param.wait = true;
 
-	/* Remove eviction fence so that validate can wait on move fences */
-	amdgpu_amdkfd_remove_eviction_fence(pd, kvm->eviction_fence,
-					    NULL, NULL);
-
 	ret = amdgpu_vm_validate_pt_bos(adev, vm, amdgpu_amdkfd_validate,
 					&param);
 
@@ -471,9 +466,6 @@ static int validate_pt_pd_bos(struct amdgpu_device *adev, struct amdgpu_vm *vm)
 			pr_err("amdgpu: failed to validate PD\n");
 	}
 
-	/* Add the eviction fence back */
-	amdgpu_bo_fence(pd, &kvm->master->eviction_fence->base, true);
-
 	vm->last_eviction_counter = atomic64_read(&adev->num_evictions);
 
 	return ret;
@@ -944,6 +936,17 @@ static int map_bo_to_gpuvm(struct amdgpu_device *adev,
 {
 	int ret;
 	struct amdgpu_bo *bo = entry->bo_va->bo;
+	struct amdkfd_vm *kvm = container_of(entry->bo_va->vm,
+					     struct amdkfd_vm, base);
+	struct amdgpu_bo *pd = entry->bo_va->vm->page_directory;
+
+	/* Remove eviction fence from PD (and thereby from PTs too as they
+	 * share the resv. object. This is necessary because new PTs are
+	 * cleared and validate needs to wait on move fences. The eviction
+	 * fence shouldn't interfere in both these activities
+	 */
+	amdgpu_amdkfd_remove_eviction_fence(pd, kvm->master->eviction_fence,
+					    NULL, NULL);
 
 	/* Set virtual address for the allocation, allocate PTs,
 	 * if needed, and zero them.
@@ -966,6 +969,9 @@ static int map_bo_to_gpuvm(struct amdgpu_device *adev,
 		return ret;
 	}
 
+	/* Add the eviction fence back */
+	amdgpu_bo_fence(pd, &kvm->master->eviction_fence->base, true);
+
 	ret = update_gpuvm_pte(adev, entry, sync);
 	if (ret != 0) {
 		pr_err("update_gpuvm_pte() failed\n");
-- 
2.7.4