aboutsummaryrefslogtreecommitdiffstats
path: root/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/1975-fixing-the-compilation-issues-v2.patch
blob: 6250842ab4cbb7e2b588b7f09c9bd6362f6dfc58 (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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
From bcc6a8a8dbad9b1741106266dfbc3e058df4d5af Mon Sep 17 00:00:00 2001
From: Kalyan Alle <kalyan.alle@amd.com>
Date: Mon, 23 Apr 2018 12:45:11 +0530
Subject: [PATCH 1975/4131] fixing the compilation issues v2

This Patch fixes the compilation issues while porting
Till commit :4b6e17791af0d6f531d5e5409ee007d78d9457d4
repo:brahma/ec/linux , branch : amd-18.10

Signed-off-by: kalyan alle <kalyan.alle@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c       |   2 +-
 drivers/gpu/drm/amd/powerplay/amd_powerplay.c |  20 +++--
 drivers/gpu/drm/drm_syncobj.c                 | 123 +++++++++++++++++++-------
 include/drm/drm_syncobj.h                     |   6 +-
 include/uapi/drm/amdgpu_drm.h                 |  26 +++++-
 5 files changed, 135 insertions(+), 42 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
index 23101b0..9391db0 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
@@ -142,7 +142,7 @@ void amdgpu_gfx_compute_queue_acquire(struct amdgpu_device *adev)
 		if (mec >= adev->gfx.mec.num_mec)
 			break;
 		
-		if (multiple_policy) {
+		if (multipipe_policy) {
 			/* policy: amdgpu owns the first two queues of the first MEC */
 			if (mec == 0 && queue < 2)
 				set_bit(i, adev->gfx.mec.queue_bitmap);
diff --git a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
index 1910524..2010bbd 100644
--- a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
+++ b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
@@ -1163,7 +1163,9 @@ static int pp_dpm_switch_power_profile(void *handle,
 	return 0;
 }
 
-static int amd_powerplay_display_configuration_change(void *handle,
+/* export this function to DAL */
+
+static int pp_display_configuration_change(void *handle,
 	const struct amd_pp_display_configuration *display_config)
 {
 	struct pp_hwmgr  *hwmgr;
@@ -1182,7 +1184,7 @@ static int amd_powerplay_display_configuration_change(void *handle,
 	return 0;
 }
 
-static int amd_powerplay_get_display_power_level(void *handle,
+static int pp_get_display_power_level(void *handle,
 		struct amd_pp_simple_clock_info *output)
 {
 	struct pp_hwmgr  *hwmgr;
@@ -1205,7 +1207,7 @@ static int amd_powerplay_get_display_power_level(void *handle,
 	return ret;
 }
 
-static int amd_powerplay_get_current_clocks(void *handle,
+static int pp_get_current_clocks(void *handle,
 		struct amd_pp_clock_info *clocks)
 {
 	struct amd_pp_simple_clock_info simple_clocks;
@@ -1259,7 +1261,7 @@ static int amd_powerplay_get_current_clocks(void *handle,
 	return 0;
 }
 
-static int amd_powerplay_get_clock_by_type(void *handle, enum amd_pp_clock_type type, struct amd_pp_clocks *clocks)
+static int pp_get_clock_by_type(void *handle, enum amd_pp_clock_type type, struct amd_pp_clocks *clocks)
 {
 	struct pp_hwmgr  *hwmgr;
 	struct pp_instance *pp_handle = (struct pp_instance *)handle;
@@ -1281,7 +1283,7 @@ static int amd_powerplay_get_clock_by_type(void *handle, enum amd_pp_clock_type
 	return ret;
 }
 
-static int amd_powerplay_get_clock_by_type_with_latency(void *handle,
+static int pp_get_clock_by_type_with_latency(void *handle,
 		enum amd_pp_clock_type type,
 		struct pp_clock_levels_with_latency *clocks)
 {
@@ -1303,7 +1305,7 @@ static int amd_powerplay_get_clock_by_type_with_latency(void *handle,
 	return ret;
 }
 
-static int amd_powerplay_get_clock_by_type_with_voltage(void *handle,
+static int pp_get_clock_by_type_with_voltage(void *handle,
 		enum amd_pp_clock_type type,
 		struct pp_clock_levels_with_voltage *clocks)
 {
@@ -1328,7 +1330,7 @@ static int amd_powerplay_get_clock_by_type_with_voltage(void *handle,
 	return ret;
 }
 
-static int amd_powerplay_set_watermarks_for_clocks_ranges(void *handle,
+static int pp_set_watermarks_for_clocks_ranges(void *handle,
 		struct pp_wm_sets_with_clock_ranges_soc15 *wm_with_clock_ranges)
 {
 	struct pp_hwmgr *hwmgr;
@@ -1352,7 +1354,7 @@ static int amd_powerplay_set_watermarks_for_clocks_ranges(void *handle,
 	return ret;
 }
 
-static int amd_powerplay_display_clock_voltage_request(void *handle,
+static int pp_display_clock_voltage_request(void *handle,
 		struct pp_display_clock_request *clock)
 {
 	struct pp_hwmgr *hwmgr;
@@ -1375,7 +1377,7 @@ static int amd_powerplay_display_clock_voltage_request(void *handle,
 	return ret;
 }
 
-static int amd_powerplay_get_display_mode_validation_clocks(void *handle,
+static int pp_get_display_mode_validation_clocks(void *handle,
 		struct amd_pp_simple_clock_info *clocks)
 {
 	struct pp_hwmgr  *hwmgr;
diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c
index 7bcf570..5cd8269 100644
--- a/drivers/gpu/drm/drm_syncobj.c
+++ b/drivers/gpu/drm/drm_syncobj.c
@@ -262,42 +262,83 @@ void drm_syncobj_free(struct kref *kref)
 }
 EXPORT_SYMBOL(drm_syncobj_free);
 
-static int drm_syncobj_create(struct drm_file *file_private,
-			      u32 *handle, uint32_t flags)
+/**
+ * drm_syncobj_create - create a new syncobj
+ * @out_syncobj: returned syncobj
+ * @flags: DRM_SYNCOBJ_* flags
+ * @fence: if non-NULL, the syncobj will represent this fence
+ */
+int drm_syncobj_create(struct drm_syncobj **out_syncobj, uint32_t flags,
+                       struct dma_fence *fence)
 {
-	int ret;
-	struct drm_syncobj *syncobj;
+        int ret;
+        struct drm_syncobj *syncobj;
 
-	syncobj = kzalloc(sizeof(struct drm_syncobj), GFP_KERNEL);
-	if (!syncobj)
-		return -ENOMEM;
+        syncobj = kzalloc(sizeof(struct drm_syncobj), GFP_KERNEL);
+        if (!syncobj)
+                return -ENOMEM;
 
-	kref_init(&syncobj->refcount);
-	INIT_LIST_HEAD(&syncobj->cb_list);
-	spin_lock_init(&syncobj->lock);
+        kref_init(&syncobj->refcount);
+        INIT_LIST_HEAD(&syncobj->cb_list);
+        spin_lock_init(&syncobj->lock);
 
-	if (flags & DRM_SYNCOBJ_CREATE_SIGNALED) {
-		ret = drm_syncobj_assign_null_handle(syncobj);
-		if (ret < 0) {
-			drm_syncobj_put(syncobj);
-			return ret;
-		}
-	}
+        if (flags & DRM_SYNCOBJ_CREATE_SIGNALED) {
+                ret = drm_syncobj_assign_null_handle(syncobj);
+                if (ret < 0) {
+                        drm_syncobj_put(syncobj);
+                        return ret;
+                }
+        }
 
-	idr_preload(GFP_KERNEL);
-	spin_lock(&file_private->syncobj_table_lock);
-	ret = idr_alloc(&file_private->syncobj_idr, syncobj, 1, 0, GFP_NOWAIT);
-	spin_unlock(&file_private->syncobj_table_lock);
+        if (fence)
+                drm_syncobj_replace_fence(syncobj, fence);
 
-	idr_preload_end();
+        *out_syncobj = syncobj;
+        return 0;
+}
+EXPORT_SYMBOL(drm_syncobj_create);
 
-	if (ret < 0) {
-		drm_syncobj_put(syncobj);
-		return ret;
-	}
+/**
+ * drm_syncobj_get_handle - get a handle from a syncobj
+ */
+int drm_syncobj_get_handle(struct drm_file *file_private,
+                           struct drm_syncobj *syncobj, u32 *handle)
+{
+        int ret;
 
-	*handle = ret;
-	return 0;
+        /* take a reference to put in the idr */
+        drm_syncobj_get(syncobj);
+
+        idr_preload(GFP_KERNEL);
+        spin_lock(&file_private->syncobj_table_lock);
+        ret = idr_alloc(&file_private->syncobj_idr, syncobj, 1, 0, GFP_NOWAIT);
+        spin_unlock(&file_private->syncobj_table_lock);
+
+        idr_preload_end();
+
+        if (ret < 0) {
+                drm_syncobj_put(syncobj);
+                return ret;
+        }
+
+        *handle = ret;
+        return 0;
+}
+EXPORT_SYMBOL(drm_syncobj_get_handle);
+
+static int drm_syncobj_create_as_handle(struct drm_file *file_private,
+                                        u32 *handle, uint32_t flags)
+{
+        int ret;
+        struct drm_syncobj *syncobj;
+
+        ret = drm_syncobj_create(&syncobj, flags, NULL);
+        if (ret)
+                return ret;
+
+        ret = drm_syncobj_get_handle(file_private, syncobj, handle);
+        drm_syncobj_put(syncobj);
+        return ret;
 }
 
 static int drm_syncobj_destroy(struct drm_file *file_private,
@@ -328,6 +369,28 @@ static const struct file_operations drm_syncobj_file_fops = {
 	.release = drm_syncobj_file_release,
 };
 
+int drm_syncobj_get_fd(struct drm_syncobj *syncobj, int *p_fd)
+{
+        int ret;
+        int fd;
+
+        fd = get_unused_fd_flags(O_CLOEXEC);
+        if (fd < 0)
+                return fd;
+
+        if (!syncobj->file) {
+                ret = drm_syncobj_alloc_file(syncobj);
+                if (ret) {
+                        put_unused_fd(fd);
+                        return ret;
+                }
+        }
+        fd_install(fd, syncobj->file);
+        *p_fd = fd;
+        return 0;
+}
+EXPORT_SYMBOL(drm_syncobj_get_fd);
+
 static int drm_syncobj_handle_to_fd(struct drm_file *file_private,
 				    u32 handle, int *p_fd)
 {
@@ -501,8 +564,8 @@ drm_syncobj_create_ioctl(struct drm_device *dev, void *data,
 	if (args->flags & ~DRM_SYNCOBJ_CREATE_SIGNALED)
 		return -EINVAL;
 
-	return drm_syncobj_create(file_private,
-				  &args->handle, args->flags);
+	return drm_syncobj_create_as_handle(file_private,
+						&args->handle, args->flags);
 }
 
 int
diff --git a/include/drm/drm_syncobj.h b/include/drm/drm_syncobj.h
index 6d45aae..30c452f 100644
--- a/include/drm/drm_syncobj.h
+++ b/include/drm/drm_syncobj.h
@@ -131,5 +131,9 @@ int drm_syncobj_find_fence(struct drm_file *file_private,
 			   u32 handle,
 			   struct dma_fence **fence);
 void drm_syncobj_free(struct kref *kref);
-
+int drm_syncobj_create(struct drm_syncobj **out_syncobj, uint32_t flags,
+                       struct dma_fence *fence);
+int drm_syncobj_get_handle(struct drm_file *file_private,
+                           struct drm_syncobj *syncobj, u32 *handle);
+int drm_syncobj_get_fd(struct drm_syncobj *syncobj, int *p_fd);
 #endif
diff --git a/include/uapi/drm/amdgpu_drm.h b/include/uapi/drm/amdgpu_drm.h
index 69f72d1..a03a782 100644
--- a/include/uapi/drm/amdgpu_drm.h
+++ b/include/uapi/drm/amdgpu_drm.h
@@ -52,6 +52,7 @@ extern "C" {
 #define DRM_AMDGPU_GEM_USERPTR		0x11
 #define DRM_AMDGPU_WAIT_FENCES		0x12
 #define DRM_AMDGPU_VM			0x13
+#define DRM_AMDGPU_FENCE_TO_HANDLE      0x14
 
 /* hybrid specific ioctls */
 #define DRM_AMDGPU_FREESYNC             0x5d
@@ -73,6 +74,7 @@ extern "C" {
 #define DRM_IOCTL_AMDGPU_GEM_USERPTR	DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_USERPTR, struct drm_amdgpu_gem_userptr)
 #define DRM_IOCTL_AMDGPU_WAIT_FENCES	DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_WAIT_FENCES, union drm_amdgpu_wait_fences)
 #define DRM_IOCTL_AMDGPU_VM		DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_VM, union drm_amdgpu_vm)
+#define DRM_IOCTL_AMDGPU_FENCE_TO_HANDLE DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_FENCE_TO_HANDLE, union drm_amdgpu_fence_to_handle)
 
 /* hybrid specific ioctls */
 #define DRM_IOCTL_AMDGPU_FREESYNC       DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_FREESYNC, struct drm_amdgpu_freesync)
@@ -184,13 +186,21 @@ union drm_amdgpu_bo_list {
 /* unknown cause */
 #define AMDGPU_CTX_UNKNOWN_RESET	3
 
+/* Context priority level */
+#define AMDGPU_CTX_PRIORITY_LOW_HW      -1023
+#define AMDGPU_CTX_PRIORITY_LOW_SW      -512
+#define AMDGPU_CTX_PRIORITY_NORMAL      0
+/* Selecting a priority above NORMAL requires CAP_SYS_NICE or DRM_MASTER */
+#define AMDGPU_CTX_PRIORITY_HIGH_SW     512
+#define AMDGPU_CTX_PRIORITY_HIGH_HW     1023
+
 struct drm_amdgpu_ctx_in {
 	/** AMDGPU_CTX_OP_* */
 	__u32	op;
 	/** For future use, no flags defined so far */
 	__u32	flags;
 	__u32	ctx_id;
-	__u32	_pad;
+	__s32   priority;
 };
 
 union drm_amdgpu_ctx_out {
@@ -582,6 +592,20 @@ struct drm_amdgpu_cs_chunk_sem {
 	__u32 handle;
 };
 
+#define AMDGPU_FENCE_TO_HANDLE_GET_SYNCOBJ      0
+#define AMDGPU_FENCE_TO_HANDLE_GET_SYNCOBJ_FD   1
+#define AMDGPU_FENCE_TO_HANDLE_GET_SYNC_FILE_FD 2
+
+union drm_amdgpu_fence_to_handle {
+        struct {
+                struct drm_amdgpu_fence fence;
+                __u32 what;
+        } in;
+        struct {
+                __u32 handle;
+        } out;
+};
+
 struct drm_amdgpu_cs_chunk_data {
 	union {
 		struct drm_amdgpu_cs_chunk_ib		ib_data;
-- 
2.7.4