aboutsummaryrefslogtreecommitdiffstats
path: root/meta-v1000/recipes-kernel/linux/linux-yocto-4.14.71/1614-drm-amdgpu-Consolidate-2-eviction_valuable-calls.patch
blob: 17ac84ac640c10cdec7c2452d5a01860cf9de8ed (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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
From 4b6d7d4d5acd955ef045417556608c13a1ce784a Mon Sep 17 00:00:00 2001
From: Kent Russell <kent.russell@amd.com>
Date: Mon, 6 Mar 2017 08:09:41 -0500
Subject: [PATCH 1614/4131] drm/amdgpu: Consolidate 2 eviction_valuable calls

There were two differing eviction_valuable functions. Consolidate them
by moving the kfd-based one into the original function. This also
addresses an unused-function warning.

Change-Id: I42e369813ad8f2b7d4bd018b7fcc913581297361
Signed-off-by: Kent Russell <kent.russell@amd.com>

 Conflicts:
	drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 50 ++++++++++++---------------------
 1 file changed, 18 insertions(+), 32 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index 48e74d3..c4b1c9d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -209,37 +209,6 @@ static int amdgpu_init_mem_type(struct ttm_bo_device *bdev, uint32_t type,
 	return 0;
 }
 
-static bool amdgpu_bo_eviction_valuable(struct ttm_buffer_object *bo,
-					const struct ttm_place *place)
-{
-	struct reservation_object_list *flist;
-	struct fence *f;
-	int i;
-
-	/* Don't evict this BO if it's outside of the
-	 * requested placement range
-	 */
-	if (!ttm_bo_eviction_valuable(bo, place))
-		return false;
-
-	/* If bo is a KFD BO, check if the bo belongs to the current process.
-	 * If true, then return false as any KFD process needs all its BOs to
-	 * be resident to run successfully
-	 */
-	flist = reservation_object_get_list(bo->resv);
-	if (!flist)
-		return true;
-
-	for (i = 0; i < flist->shared_count; ++i) {
-		f = rcu_dereference_protected(flist->shared[i],
-			reservation_object_held(bo->resv));
-		if (amd_kfd_fence_check_mm(f, current->mm))
-			return false;
-	}
-
-	return true;
-}
-
 static void amdgpu_evict_flags(struct ttm_buffer_object *bo,
 				struct ttm_placement *placement)
 {
@@ -1235,9 +1204,26 @@ uint64_t amdgpu_ttm_tt_pte_flags(struct amdgpu_device *adev, struct ttm_tt *ttm,
 static bool amdgpu_ttm_bo_eviction_valuable(struct ttm_buffer_object *bo,
 					    const struct ttm_place *place)
 {
+	struct reservation_object_list *flist;
+	struct fence *f;
+	int i;
 	unsigned long num_pages = bo->mem.num_pages;
 	struct drm_mm_node *node = bo->mem.mm_node;
 
+	/* If bo is a KFD BO, check if the bo belongs to the current process.
+	 * If true, then return false as any KFD process needs all its BOs to
+	 * be resident to run successfully
+	 */
+	flist = reservation_object_get_list(bo->resv);
+	if (flist) {
+		for (i = 0; i < flist->shared_count; ++i) {
+			f = rcu_dereference_protected(flist->shared[i],
+				reservation_object_held(bo->resv));
+			if (amd_kfd_fence_check_mm(f, current->mm))
+				return false;
+		}
+	}
+
 	if (bo->mem.start != AMDGPU_BO_INVALID_OFFSET)
 		return ttm_bo_eviction_valuable(bo, place);
 
@@ -1331,7 +1317,7 @@ static struct ttm_bo_driver amdgpu_bo_driver = {
 	.ttm_tt_unpopulate = &amdgpu_ttm_tt_unpopulate,
 	.invalidate_caches = &amdgpu_invalidate_caches,
 	.init_mem_type = &amdgpu_init_mem_type,
-	.eviction_valuable = amdgpu_bo_eviction_valuable,
+	.eviction_valuable = amdgpu_ttm_bo_eviction_valuable,
 	.evict_flags = &amdgpu_evict_flags,
 	.move = &amdgpu_bo_move,
 	.verify_access = &amdgpu_verify_access,
-- 
2.7.4