aboutsummaryrefslogtreecommitdiffstats
path: root/common/recipes-kernel/linux/files/0353-drm-amdgpu-group-userptr-in-the-BO-list-v2.patch
blob: 2b26410b4e6d5df64d519ae4cda4a1b0ff7a4de5 (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
From fff6698938982f36960e290820d12d49d52714a0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Christian=20K=C3=B6nig?= <christian.koenig@amd.com>
Date: Mon, 22 Feb 2016 15:40:59 +0100
Subject: [PATCH 0353/1110] drm/amdgpu: group userptr in the BO list v2
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

We need them together with the next patch.

v2: Don't take bo reference twice

Signed-off-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>
Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Kalyan Alle <kalyan.alle@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c
index 3406527..82f8caf 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c
@@ -91,7 +91,7 @@ static int amdgpu_bo_list_set(struct amdgpu_device *adev,
 	struct amdgpu_bo *gws_obj = adev->gds.gws_gfx_bo;
 	struct amdgpu_bo *oa_obj = adev->gds.oa_gfx_bo;
 
-	bool has_userptr = false;
+        unsigned last_entry = 0, first_userptr = num_entries;
 	unsigned i;
 
 	array = drm_malloc_ab(num_entries, sizeof(struct amdgpu_bo_list_entry));
@@ -100,8 +100,9 @@ static int amdgpu_bo_list_set(struct amdgpu_device *adev,
 	memset(array, 0, num_entries * sizeof(struct amdgpu_bo_list_entry));
 
 	for (i = 0; i < num_entries; ++i) {
-		struct amdgpu_bo_list_entry *entry = &array[i];
+                struct amdgpu_bo_list_entry *entry;
 		struct drm_gem_object *gobj;
+                struct amdgpu_bo *bo;
                 struct mm_struct *usermm;
 
 		gobj = drm_gem_object_lookup(adev->ddev, filp, info[i].bo_handle);
@@ -111,19 +112,25 @@ static int amdgpu_bo_list_set(struct amdgpu_device *adev,
 			goto error_free;
                 }
 
-		entry->robj = amdgpu_bo_ref(gem_to_amdgpu_bo(gobj));
+                bo = amdgpu_bo_ref(gem_to_amdgpu_bo(gobj));
 		drm_gem_object_unreference_unlocked(gobj);
-		entry->priority = min(info[i].bo_priority,
-				      AMDGPU_BO_LIST_MAX_PRIORITY);
-                usermm = amdgpu_ttm_tt_get_usermm(entry->robj->tbo.ttm);
+
+                usermm = amdgpu_ttm_tt_get_usermm(bo->tbo.ttm);
                 if (usermm) {
                         if (usermm != current->mm) {
-                                amdgpu_bo_unref(&entry->robj);
+                                amdgpu_bo_unref(&bo);
                                 r = -EPERM;
                                 goto error_free;
                         }
                         has_userptr = true;
+                        entry = &array[--first_userptr];
+                } else {
+                        entry = &array[last_entry++];
                 }
+                
+		entry->robj = bo;
+                entry->priority = min(info[i].bo_priority,
+                                      AMDGPU_BO_LIST_MAX_PRIORITY);
 		entry->tv.bo = &entry->robj->tbo;
 		entry->tv.shared = true;
 
@@ -145,7 +152,7 @@ static int amdgpu_bo_list_set(struct amdgpu_device *adev,
 	list->gds_obj = gds_obj;
 	list->gws_obj = gws_obj;
 	list->oa_obj = oa_obj;
-	list->has_userptr = has_userptr;
+        list->first_userptr = first_userptr;
 	list->array = array;
 	list->num_entries = num_entries;
 
-- 
2.7.4