blob: 260a73a44e6999d51523814487a2ceec40c6160d [file] [log] [blame]
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001/*
2 * Copyright (C) 2015 Etnaviv Project
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 as published by
6 * the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License along with
14 * this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include <linux/component.h>
Chris Wilsonf54d1862016-10-25 13:00:45 +010018#include <linux/dma-fence.h>
The etnaviv authorsa8c21a52015-12-03 18:21:29 +010019#include <linux/moduleparam.h>
20#include <linux/of_device.h>
Russell Kingbcdfb5e2017-03-12 19:00:59 +000021#include <linux/thermal.h>
Lucas Stachea1f5722017-01-16 16:09:51 +010022
23#include "etnaviv_cmdbuf.h"
The etnaviv authorsa8c21a52015-12-03 18:21:29 +010024#include "etnaviv_dump.h"
25#include "etnaviv_gpu.h"
26#include "etnaviv_gem.h"
27#include "etnaviv_mmu.h"
Christian Gmeiner357713c2017-09-24 15:15:28 +020028#include "etnaviv_perfmon.h"
Lucas Stache93b6de2017-12-04 18:41:58 +010029#include "etnaviv_sched.h"
The etnaviv authorsa8c21a52015-12-03 18:21:29 +010030#include "common.xml.h"
31#include "state.xml.h"
32#include "state_hi.xml.h"
33#include "cmdstream.xml.h"
34
Lucas Stachc09d7f72018-01-04 13:40:03 +010035#ifndef PHYS_OFFSET
36#define PHYS_OFFSET 0
37#endif
38
The etnaviv authorsa8c21a52015-12-03 18:21:29 +010039static const struct platform_device_id gpu_ids[] = {
40 { .name = "etnaviv-gpu,2d" },
41 { },
42};
43
The etnaviv authorsa8c21a52015-12-03 18:21:29 +010044/*
45 * Driver functions:
46 */
47
48int etnaviv_gpu_get_param(struct etnaviv_gpu *gpu, u32 param, u64 *value)
49{
50 switch (param) {
51 case ETNAVIV_PARAM_GPU_MODEL:
52 *value = gpu->identity.model;
53 break;
54
55 case ETNAVIV_PARAM_GPU_REVISION:
56 *value = gpu->identity.revision;
57 break;
58
59 case ETNAVIV_PARAM_GPU_FEATURES_0:
60 *value = gpu->identity.features;
61 break;
62
63 case ETNAVIV_PARAM_GPU_FEATURES_1:
64 *value = gpu->identity.minor_features0;
65 break;
66
67 case ETNAVIV_PARAM_GPU_FEATURES_2:
68 *value = gpu->identity.minor_features1;
69 break;
70
71 case ETNAVIV_PARAM_GPU_FEATURES_3:
72 *value = gpu->identity.minor_features2;
73 break;
74
75 case ETNAVIV_PARAM_GPU_FEATURES_4:
76 *value = gpu->identity.minor_features3;
77 break;
78
Russell King602eb482016-01-24 17:36:04 +000079 case ETNAVIV_PARAM_GPU_FEATURES_5:
80 *value = gpu->identity.minor_features4;
81 break;
82
83 case ETNAVIV_PARAM_GPU_FEATURES_6:
84 *value = gpu->identity.minor_features5;
85 break;
86
The etnaviv authorsa8c21a52015-12-03 18:21:29 +010087 case ETNAVIV_PARAM_GPU_STREAM_COUNT:
88 *value = gpu->identity.stream_count;
89 break;
90
91 case ETNAVIV_PARAM_GPU_REGISTER_MAX:
92 *value = gpu->identity.register_max;
93 break;
94
95 case ETNAVIV_PARAM_GPU_THREAD_COUNT:
96 *value = gpu->identity.thread_count;
97 break;
98
99 case ETNAVIV_PARAM_GPU_VERTEX_CACHE_SIZE:
100 *value = gpu->identity.vertex_cache_size;
101 break;
102
103 case ETNAVIV_PARAM_GPU_SHADER_CORE_COUNT:
104 *value = gpu->identity.shader_core_count;
105 break;
106
107 case ETNAVIV_PARAM_GPU_PIXEL_PIPES:
108 *value = gpu->identity.pixel_pipes;
109 break;
110
111 case ETNAVIV_PARAM_GPU_VERTEX_OUTPUT_BUFFER_SIZE:
112 *value = gpu->identity.vertex_output_buffer_size;
113 break;
114
115 case ETNAVIV_PARAM_GPU_BUFFER_SIZE:
116 *value = gpu->identity.buffer_size;
117 break;
118
119 case ETNAVIV_PARAM_GPU_INSTRUCTION_COUNT:
120 *value = gpu->identity.instruction_count;
121 break;
122
123 case ETNAVIV_PARAM_GPU_NUM_CONSTANTS:
124 *value = gpu->identity.num_constants;
125 break;
126
Russell King602eb482016-01-24 17:36:04 +0000127 case ETNAVIV_PARAM_GPU_NUM_VARYINGS:
128 *value = gpu->identity.varyings_count;
129 break;
130
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100131 default:
132 DBG("%s: invalid param: %u", dev_name(gpu->dev), param);
133 return -EINVAL;
134 }
135
136 return 0;
137}
138
Russell King472f79d2016-01-24 17:35:59 +0000139
140#define etnaviv_is_model_rev(gpu, mod, rev) \
141 ((gpu)->identity.model == chipModel_##mod && \
142 (gpu)->identity.revision == rev)
Russell King52f36ba2016-01-24 17:35:54 +0000143#define etnaviv_field(val, field) \
144 (((val) & field##__MASK) >> field##__SHIFT)
145
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100146static void etnaviv_hw_specs(struct etnaviv_gpu *gpu)
147{
148 if (gpu->identity.minor_features0 &
149 chipMinorFeatures0_MORE_MINOR_FEATURES) {
Russell King602eb482016-01-24 17:36:04 +0000150 u32 specs[4];
151 unsigned int streams;
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100152
153 specs[0] = gpu_read(gpu, VIVS_HI_CHIP_SPECS);
154 specs[1] = gpu_read(gpu, VIVS_HI_CHIP_SPECS_2);
Russell King602eb482016-01-24 17:36:04 +0000155 specs[2] = gpu_read(gpu, VIVS_HI_CHIP_SPECS_3);
156 specs[3] = gpu_read(gpu, VIVS_HI_CHIP_SPECS_4);
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100157
Russell King52f36ba2016-01-24 17:35:54 +0000158 gpu->identity.stream_count = etnaviv_field(specs[0],
159 VIVS_HI_CHIP_SPECS_STREAM_COUNT);
160 gpu->identity.register_max = etnaviv_field(specs[0],
161 VIVS_HI_CHIP_SPECS_REGISTER_MAX);
162 gpu->identity.thread_count = etnaviv_field(specs[0],
163 VIVS_HI_CHIP_SPECS_THREAD_COUNT);
164 gpu->identity.vertex_cache_size = etnaviv_field(specs[0],
165 VIVS_HI_CHIP_SPECS_VERTEX_CACHE_SIZE);
166 gpu->identity.shader_core_count = etnaviv_field(specs[0],
167 VIVS_HI_CHIP_SPECS_SHADER_CORE_COUNT);
168 gpu->identity.pixel_pipes = etnaviv_field(specs[0],
169 VIVS_HI_CHIP_SPECS_PIXEL_PIPES);
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100170 gpu->identity.vertex_output_buffer_size =
Russell King52f36ba2016-01-24 17:35:54 +0000171 etnaviv_field(specs[0],
172 VIVS_HI_CHIP_SPECS_VERTEX_OUTPUT_BUFFER_SIZE);
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100173
Russell King52f36ba2016-01-24 17:35:54 +0000174 gpu->identity.buffer_size = etnaviv_field(specs[1],
175 VIVS_HI_CHIP_SPECS_2_BUFFER_SIZE);
176 gpu->identity.instruction_count = etnaviv_field(specs[1],
177 VIVS_HI_CHIP_SPECS_2_INSTRUCTION_COUNT);
178 gpu->identity.num_constants = etnaviv_field(specs[1],
179 VIVS_HI_CHIP_SPECS_2_NUM_CONSTANTS);
Russell King602eb482016-01-24 17:36:04 +0000180
181 gpu->identity.varyings_count = etnaviv_field(specs[2],
182 VIVS_HI_CHIP_SPECS_3_VARYINGS_COUNT);
183
184 /* This overrides the value from older register if non-zero */
185 streams = etnaviv_field(specs[3],
186 VIVS_HI_CHIP_SPECS_4_STREAM_COUNT);
187 if (streams)
188 gpu->identity.stream_count = streams;
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100189 }
190
191 /* Fill in the stream count if not specified */
192 if (gpu->identity.stream_count == 0) {
193 if (gpu->identity.model >= 0x1000)
194 gpu->identity.stream_count = 4;
195 else
196 gpu->identity.stream_count = 1;
197 }
198
199 /* Convert the register max value */
200 if (gpu->identity.register_max)
201 gpu->identity.register_max = 1 << gpu->identity.register_max;
Russell King507f8992016-01-24 17:35:48 +0000202 else if (gpu->identity.model == chipModel_GC400)
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100203 gpu->identity.register_max = 32;
204 else
205 gpu->identity.register_max = 64;
206
207 /* Convert thread count */
208 if (gpu->identity.thread_count)
209 gpu->identity.thread_count = 1 << gpu->identity.thread_count;
Russell King507f8992016-01-24 17:35:48 +0000210 else if (gpu->identity.model == chipModel_GC400)
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100211 gpu->identity.thread_count = 64;
Russell King507f8992016-01-24 17:35:48 +0000212 else if (gpu->identity.model == chipModel_GC500 ||
213 gpu->identity.model == chipModel_GC530)
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100214 gpu->identity.thread_count = 128;
215 else
216 gpu->identity.thread_count = 256;
217
218 if (gpu->identity.vertex_cache_size == 0)
219 gpu->identity.vertex_cache_size = 8;
220
221 if (gpu->identity.shader_core_count == 0) {
222 if (gpu->identity.model >= 0x1000)
223 gpu->identity.shader_core_count = 2;
224 else
225 gpu->identity.shader_core_count = 1;
226 }
227
228 if (gpu->identity.pixel_pipes == 0)
229 gpu->identity.pixel_pipes = 1;
230
231 /* Convert virtex buffer size */
232 if (gpu->identity.vertex_output_buffer_size) {
233 gpu->identity.vertex_output_buffer_size =
234 1 << gpu->identity.vertex_output_buffer_size;
Russell King507f8992016-01-24 17:35:48 +0000235 } else if (gpu->identity.model == chipModel_GC400) {
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100236 if (gpu->identity.revision < 0x4000)
237 gpu->identity.vertex_output_buffer_size = 512;
238 else if (gpu->identity.revision < 0x4200)
239 gpu->identity.vertex_output_buffer_size = 256;
240 else
241 gpu->identity.vertex_output_buffer_size = 128;
242 } else {
243 gpu->identity.vertex_output_buffer_size = 512;
244 }
245
246 switch (gpu->identity.instruction_count) {
247 case 0:
Russell King472f79d2016-01-24 17:35:59 +0000248 if (etnaviv_is_model_rev(gpu, GC2000, 0x5108) ||
Russell King507f8992016-01-24 17:35:48 +0000249 gpu->identity.model == chipModel_GC880)
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100250 gpu->identity.instruction_count = 512;
251 else
252 gpu->identity.instruction_count = 256;
253 break;
254
255 case 1:
256 gpu->identity.instruction_count = 1024;
257 break;
258
259 case 2:
260 gpu->identity.instruction_count = 2048;
261 break;
262
263 default:
264 gpu->identity.instruction_count = 256;
265 break;
266 }
267
268 if (gpu->identity.num_constants == 0)
269 gpu->identity.num_constants = 168;
Russell King602eb482016-01-24 17:36:04 +0000270
271 if (gpu->identity.varyings_count == 0) {
272 if (gpu->identity.minor_features1 & chipMinorFeatures1_HALTI0)
273 gpu->identity.varyings_count = 12;
274 else
275 gpu->identity.varyings_count = 8;
276 }
277
278 /*
279 * For some cores, two varyings are consumed for position, so the
280 * maximum varying count needs to be reduced by one.
281 */
282 if (etnaviv_is_model_rev(gpu, GC5000, 0x5434) ||
283 etnaviv_is_model_rev(gpu, GC4000, 0x5222) ||
284 etnaviv_is_model_rev(gpu, GC4000, 0x5245) ||
285 etnaviv_is_model_rev(gpu, GC4000, 0x5208) ||
286 etnaviv_is_model_rev(gpu, GC3000, 0x5435) ||
287 etnaviv_is_model_rev(gpu, GC2200, 0x5244) ||
288 etnaviv_is_model_rev(gpu, GC2100, 0x5108) ||
289 etnaviv_is_model_rev(gpu, GC2000, 0x5108) ||
290 etnaviv_is_model_rev(gpu, GC1500, 0x5246) ||
291 etnaviv_is_model_rev(gpu, GC880, 0x5107) ||
292 etnaviv_is_model_rev(gpu, GC880, 0x5106))
293 gpu->identity.varyings_count -= 1;
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100294}
295
296static void etnaviv_hw_identify(struct etnaviv_gpu *gpu)
297{
298 u32 chipIdentity;
299
300 chipIdentity = gpu_read(gpu, VIVS_HI_CHIP_IDENTITY);
301
302 /* Special case for older graphic cores. */
Russell King52f36ba2016-01-24 17:35:54 +0000303 if (etnaviv_field(chipIdentity, VIVS_HI_CHIP_IDENTITY_FAMILY) == 0x01) {
Russell King507f8992016-01-24 17:35:48 +0000304 gpu->identity.model = chipModel_GC500;
Russell King52f36ba2016-01-24 17:35:54 +0000305 gpu->identity.revision = etnaviv_field(chipIdentity,
306 VIVS_HI_CHIP_IDENTITY_REVISION);
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100307 } else {
308
309 gpu->identity.model = gpu_read(gpu, VIVS_HI_CHIP_MODEL);
310 gpu->identity.revision = gpu_read(gpu, VIVS_HI_CHIP_REV);
311
312 /*
313 * !!!! HACK ALERT !!!!
314 * Because people change device IDs without letting software
315 * know about it - here is the hack to make it all look the
316 * same. Only for GC400 family.
317 */
318 if ((gpu->identity.model & 0xff00) == 0x0400 &&
Russell King507f8992016-01-24 17:35:48 +0000319 gpu->identity.model != chipModel_GC420) {
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100320 gpu->identity.model = gpu->identity.model & 0x0400;
321 }
322
323 /* Another special case */
Russell King472f79d2016-01-24 17:35:59 +0000324 if (etnaviv_is_model_rev(gpu, GC300, 0x2201)) {
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100325 u32 chipDate = gpu_read(gpu, VIVS_HI_CHIP_DATE);
326 u32 chipTime = gpu_read(gpu, VIVS_HI_CHIP_TIME);
327
328 if (chipDate == 0x20080814 && chipTime == 0x12051100) {
329 /*
330 * This IP has an ECO; put the correct
331 * revision in it.
332 */
333 gpu->identity.revision = 0x1051;
334 }
335 }
Lucas Stach12ff4bd2016-08-15 18:16:59 +0200336
337 /*
338 * NXP likes to call the GPU on the i.MX6QP GC2000+, but in
339 * reality it's just a re-branded GC3000. We can identify this
340 * core by the upper half of the revision register being all 1.
341 * Fix model/rev here, so all other places can refer to this
342 * core by its real identity.
343 */
344 if (etnaviv_is_model_rev(gpu, GC2000, 0xffff5450)) {
345 gpu->identity.model = chipModel_GC3000;
346 gpu->identity.revision &= 0xffff;
347 }
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100348 }
349
350 dev_info(gpu->dev, "model: GC%x, revision: %x\n",
351 gpu->identity.model, gpu->identity.revision);
352
353 gpu->identity.features = gpu_read(gpu, VIVS_HI_CHIP_FEATURE);
354
355 /* Disable fast clear on GC700. */
Russell King507f8992016-01-24 17:35:48 +0000356 if (gpu->identity.model == chipModel_GC700)
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100357 gpu->identity.features &= ~chipFeatures_FAST_CLEAR;
358
Russell King507f8992016-01-24 17:35:48 +0000359 if ((gpu->identity.model == chipModel_GC500 &&
360 gpu->identity.revision < 2) ||
361 (gpu->identity.model == chipModel_GC300 &&
362 gpu->identity.revision < 0x2000)) {
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100363
364 /*
365 * GC500 rev 1.x and GC300 rev < 2.0 doesn't have these
366 * registers.
367 */
368 gpu->identity.minor_features0 = 0;
369 gpu->identity.minor_features1 = 0;
370 gpu->identity.minor_features2 = 0;
371 gpu->identity.minor_features3 = 0;
Russell King602eb482016-01-24 17:36:04 +0000372 gpu->identity.minor_features4 = 0;
373 gpu->identity.minor_features5 = 0;
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100374 } else
375 gpu->identity.minor_features0 =
376 gpu_read(gpu, VIVS_HI_CHIP_MINOR_FEATURE_0);
377
378 if (gpu->identity.minor_features0 &
379 chipMinorFeatures0_MORE_MINOR_FEATURES) {
380 gpu->identity.minor_features1 =
381 gpu_read(gpu, VIVS_HI_CHIP_MINOR_FEATURE_1);
382 gpu->identity.minor_features2 =
383 gpu_read(gpu, VIVS_HI_CHIP_MINOR_FEATURE_2);
384 gpu->identity.minor_features3 =
385 gpu_read(gpu, VIVS_HI_CHIP_MINOR_FEATURE_3);
Russell King602eb482016-01-24 17:36:04 +0000386 gpu->identity.minor_features4 =
387 gpu_read(gpu, VIVS_HI_CHIP_MINOR_FEATURE_4);
388 gpu->identity.minor_features5 =
389 gpu_read(gpu, VIVS_HI_CHIP_MINOR_FEATURE_5);
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100390 }
391
392 /* GC600 idle register reports zero bits where modules aren't present */
393 if (gpu->identity.model == chipModel_GC600) {
394 gpu->idle_mask = VIVS_HI_IDLE_STATE_TX |
395 VIVS_HI_IDLE_STATE_RA |
396 VIVS_HI_IDLE_STATE_SE |
397 VIVS_HI_IDLE_STATE_PA |
398 VIVS_HI_IDLE_STATE_SH |
399 VIVS_HI_IDLE_STATE_PE |
400 VIVS_HI_IDLE_STATE_DE |
401 VIVS_HI_IDLE_STATE_FE;
402 } else {
403 gpu->idle_mask = ~VIVS_HI_IDLE_STATE_AXI_LP;
404 }
405
406 etnaviv_hw_specs(gpu);
407}
408
409static void etnaviv_gpu_load_clock(struct etnaviv_gpu *gpu, u32 clock)
410{
411 gpu_write(gpu, VIVS_HI_CLOCK_CONTROL, clock |
412 VIVS_HI_CLOCK_CONTROL_FSCALE_CMD_LOAD);
413 gpu_write(gpu, VIVS_HI_CLOCK_CONTROL, clock);
414}
415
Russell Kingbcdfb5e2017-03-12 19:00:59 +0000416static void etnaviv_gpu_update_clock(struct etnaviv_gpu *gpu)
417{
Lucas Stachd79fd1ccf22017-04-11 15:54:50 +0200418 if (gpu->identity.minor_features2 &
419 chipMinorFeatures2_DYNAMIC_FREQUENCY_SCALING) {
420 clk_set_rate(gpu->clk_core,
421 gpu->base_rate_core >> gpu->freq_scale);
422 clk_set_rate(gpu->clk_shader,
423 gpu->base_rate_shader >> gpu->freq_scale);
424 } else {
425 unsigned int fscale = 1 << (6 - gpu->freq_scale);
Lucas Stach6eb3ecc2017-09-28 15:41:21 +0200426 u32 clock = gpu_read(gpu, VIVS_HI_CLOCK_CONTROL);
Russell Kingbcdfb5e2017-03-12 19:00:59 +0000427
Lucas Stach6eb3ecc2017-09-28 15:41:21 +0200428 clock &= ~VIVS_HI_CLOCK_CONTROL_FSCALE_VAL__MASK;
429 clock |= VIVS_HI_CLOCK_CONTROL_FSCALE_VAL(fscale);
Lucas Stachd79fd1ccf22017-04-11 15:54:50 +0200430 etnaviv_gpu_load_clock(gpu, clock);
431 }
Russell Kingbcdfb5e2017-03-12 19:00:59 +0000432}
433
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100434static int etnaviv_hw_reset(struct etnaviv_gpu *gpu)
435{
436 u32 control, idle;
437 unsigned long timeout;
438 bool failed = true;
439
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100440 /* We hope that the GPU resets in under one second */
441 timeout = jiffies + msecs_to_jiffies(1000);
442
443 while (time_is_after_jiffies(timeout)) {
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100444 /* enable clock */
Lucas Stach6eb3ecc2017-09-28 15:41:21 +0200445 unsigned int fscale = 1 << (6 - gpu->freq_scale);
446 control = VIVS_HI_CLOCK_CONTROL_FSCALE_VAL(fscale);
447 etnaviv_gpu_load_clock(gpu, control);
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100448
449 /* isolate the GPU. */
450 control |= VIVS_HI_CLOCK_CONTROL_ISOLATE_GPU;
451 gpu_write(gpu, VIVS_HI_CLOCK_CONTROL, control);
452
453 /* set soft reset. */
454 control |= VIVS_HI_CLOCK_CONTROL_SOFT_RESET;
455 gpu_write(gpu, VIVS_HI_CLOCK_CONTROL, control);
456
457 /* wait for reset. */
Philipp Zabel40462172017-10-09 12:03:30 +0200458 usleep_range(10, 20);
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100459
460 /* reset soft reset bit. */
461 control &= ~VIVS_HI_CLOCK_CONTROL_SOFT_RESET;
462 gpu_write(gpu, VIVS_HI_CLOCK_CONTROL, control);
463
464 /* reset GPU isolation. */
465 control &= ~VIVS_HI_CLOCK_CONTROL_ISOLATE_GPU;
466 gpu_write(gpu, VIVS_HI_CLOCK_CONTROL, control);
467
468 /* read idle register. */
469 idle = gpu_read(gpu, VIVS_HI_IDLE_STATE);
470
471 /* try reseting again if FE it not idle */
472 if ((idle & VIVS_HI_IDLE_STATE_FE) == 0) {
473 dev_dbg(gpu->dev, "FE is not idle\n");
474 continue;
475 }
476
477 /* read reset register. */
478 control = gpu_read(gpu, VIVS_HI_CLOCK_CONTROL);
479
480 /* is the GPU idle? */
481 if (((control & VIVS_HI_CLOCK_CONTROL_IDLE_3D) == 0) ||
482 ((control & VIVS_HI_CLOCK_CONTROL_IDLE_2D) == 0)) {
483 dev_dbg(gpu->dev, "GPU is not idle\n");
484 continue;
485 }
486
Lucas Stach6eb3ecc2017-09-28 15:41:21 +0200487 /* disable debug registers, as they are not normally needed */
488 control |= VIVS_HI_CLOCK_CONTROL_DISABLE_DEBUG_REGISTERS;
489 gpu_write(gpu, VIVS_HI_CLOCK_CONTROL, control);
490
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100491 failed = false;
492 break;
493 }
494
495 if (failed) {
496 idle = gpu_read(gpu, VIVS_HI_IDLE_STATE);
497 control = gpu_read(gpu, VIVS_HI_CLOCK_CONTROL);
498
499 dev_err(gpu->dev, "GPU failed to reset: FE %sidle, 3D %sidle, 2D %sidle\n",
500 idle & VIVS_HI_IDLE_STATE_FE ? "" : "not ",
501 control & VIVS_HI_CLOCK_CONTROL_IDLE_3D ? "" : "not ",
502 control & VIVS_HI_CLOCK_CONTROL_IDLE_2D ? "" : "not ");
503
504 return -EBUSY;
505 }
506
507 /* We rely on the GPU running, so program the clock */
Russell Kingbcdfb5e2017-03-12 19:00:59 +0000508 etnaviv_gpu_update_clock(gpu);
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100509
510 return 0;
511}
512
Russell King7d0c6e72016-01-21 15:20:45 +0000513static void etnaviv_gpu_enable_mlcg(struct etnaviv_gpu *gpu)
514{
515 u32 pmc, ppc;
516
517 /* enable clock gating */
518 ppc = gpu_read(gpu, VIVS_PM_POWER_CONTROLS);
519 ppc |= VIVS_PM_POWER_CONTROLS_ENABLE_MODULE_CLOCK_GATING;
520
521 /* Disable stall module clock gating for 4.3.0.1 and 4.3.0.2 revs */
522 if (gpu->identity.revision == 0x4301 ||
523 gpu->identity.revision == 0x4302)
524 ppc |= VIVS_PM_POWER_CONTROLS_DISABLE_STALL_MODULE_CLOCK_GATING;
525
526 gpu_write(gpu, VIVS_PM_POWER_CONTROLS, ppc);
527
528 pmc = gpu_read(gpu, VIVS_PM_MODULE_CONTROLS);
529
Lucas Stach7cef6002017-03-17 12:42:30 +0100530 /* Disable PA clock gating for GC400+ without bugfix except for GC420 */
Russell King7d0c6e72016-01-21 15:20:45 +0000531 if (gpu->identity.model >= chipModel_GC400 &&
Lucas Stach7cef6002017-03-17 12:42:30 +0100532 gpu->identity.model != chipModel_GC420 &&
533 !(gpu->identity.minor_features3 & chipMinorFeatures3_BUG_FIXES12))
Russell King7d0c6e72016-01-21 15:20:45 +0000534 pmc |= VIVS_PM_MODULE_CONTROLS_DISABLE_MODULE_CLOCK_GATING_PA;
535
536 /*
537 * Disable PE clock gating on revs < 5.0.0.0 when HZ is
538 * present without a bug fix.
539 */
540 if (gpu->identity.revision < 0x5000 &&
541 gpu->identity.minor_features0 & chipMinorFeatures0_HZ &&
542 !(gpu->identity.minor_features1 &
543 chipMinorFeatures1_DISABLE_PE_GATING))
544 pmc |= VIVS_PM_MODULE_CONTROLS_DISABLE_MODULE_CLOCK_GATING_PE;
545
546 if (gpu->identity.revision < 0x5422)
547 pmc |= BIT(15); /* Unknown bit */
548
Lucas Stach7cef6002017-03-17 12:42:30 +0100549 /* Disable TX clock gating on affected core revisions. */
550 if (etnaviv_is_model_rev(gpu, GC4000, 0x5222) ||
551 etnaviv_is_model_rev(gpu, GC2000, 0x5108))
552 pmc |= VIVS_PM_MODULE_CONTROLS_DISABLE_MODULE_CLOCK_GATING_TX;
553
Russell King7d0c6e72016-01-21 15:20:45 +0000554 pmc |= VIVS_PM_MODULE_CONTROLS_DISABLE_MODULE_CLOCK_GATING_RA_HZ;
555 pmc |= VIVS_PM_MODULE_CONTROLS_DISABLE_MODULE_CLOCK_GATING_RA_EZ;
556
557 gpu_write(gpu, VIVS_PM_MODULE_CONTROLS, pmc);
558}
559
Lucas Stach229855b2016-08-17 15:27:52 +0200560void etnaviv_gpu_start_fe(struct etnaviv_gpu *gpu, u32 address, u16 prefetch)
561{
562 gpu_write(gpu, VIVS_FE_COMMAND_ADDRESS, address);
563 gpu_write(gpu, VIVS_FE_COMMAND_CONTROL,
564 VIVS_FE_COMMAND_CONTROL_ENABLE |
565 VIVS_FE_COMMAND_CONTROL_PREFETCH(prefetch));
566}
567
Wladimir J. van der Laane17a0de2016-12-15 13:11:30 +0100568static void etnaviv_gpu_setup_pulse_eater(struct etnaviv_gpu *gpu)
569{
570 /*
571 * Base value for VIVS_PM_PULSE_EATER register on models where it
572 * cannot be read, extracted from vivante kernel driver.
573 */
574 u32 pulse_eater = 0x01590880;
575
576 if (etnaviv_is_model_rev(gpu, GC4000, 0x5208) ||
577 etnaviv_is_model_rev(gpu, GC4000, 0x5222)) {
578 pulse_eater |= BIT(23);
579
580 }
581
582 if (etnaviv_is_model_rev(gpu, GC1000, 0x5039) ||
583 etnaviv_is_model_rev(gpu, GC1000, 0x5040)) {
584 pulse_eater &= ~BIT(16);
585 pulse_eater |= BIT(17);
586 }
587
588 if ((gpu->identity.revision > 0x5420) &&
589 (gpu->identity.features & chipFeatures_PIPE_3D))
590 {
591 /* Performance fix: disable internal DFS */
592 pulse_eater = gpu_read(gpu, VIVS_PM_PULSE_EATER);
593 pulse_eater |= BIT(18);
594 }
595
596 gpu_write(gpu, VIVS_PM_PULSE_EATER, pulse_eater);
597}
598
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100599static void etnaviv_gpu_hw_init(struct etnaviv_gpu *gpu)
600{
601 u16 prefetch;
602
Russell King472f79d2016-01-24 17:35:59 +0000603 if ((etnaviv_is_model_rev(gpu, GC320, 0x5007) ||
604 etnaviv_is_model_rev(gpu, GC320, 0x5220)) &&
605 gpu_read(gpu, VIVS_HI_CHIP_TIME) != 0x2062400) {
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100606 u32 mc_memory_debug;
607
608 mc_memory_debug = gpu_read(gpu, VIVS_MC_DEBUG_MEMORY) & ~0xff;
609
610 if (gpu->identity.revision == 0x5007)
611 mc_memory_debug |= 0x0c;
612 else
613 mc_memory_debug |= 0x08;
614
615 gpu_write(gpu, VIVS_MC_DEBUG_MEMORY, mc_memory_debug);
616 }
617
Russell King7d0c6e72016-01-21 15:20:45 +0000618 /* enable module-level clock gating */
619 etnaviv_gpu_enable_mlcg(gpu);
620
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100621 /*
622 * Update GPU AXI cache atttribute to "cacheable, no allocate".
623 * This is necessary to prevent the iMX6 SoC locking up.
624 */
625 gpu_write(gpu, VIVS_HI_AXI_CONFIG,
626 VIVS_HI_AXI_CONFIG_AWCACHE(2) |
627 VIVS_HI_AXI_CONFIG_ARCACHE(2));
628
629 /* GC2000 rev 5108 needs a special bus config */
Russell King472f79d2016-01-24 17:35:59 +0000630 if (etnaviv_is_model_rev(gpu, GC2000, 0x5108)) {
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100631 u32 bus_config = gpu_read(gpu, VIVS_MC_BUS_CONFIG);
632 bus_config &= ~(VIVS_MC_BUS_CONFIG_FE_BUS_CONFIG__MASK |
633 VIVS_MC_BUS_CONFIG_TX_BUS_CONFIG__MASK);
634 bus_config |= VIVS_MC_BUS_CONFIG_FE_BUS_CONFIG(1) |
635 VIVS_MC_BUS_CONFIG_TX_BUS_CONFIG(0);
636 gpu_write(gpu, VIVS_MC_BUS_CONFIG, bus_config);
637 }
638
Wladimir J. van der Laane17a0de2016-12-15 13:11:30 +0100639 /* setup the pulse eater */
640 etnaviv_gpu_setup_pulse_eater(gpu);
641
Lucas Stach99f861b2016-08-16 11:48:49 +0200642 /* setup the MMU */
Lucas Stache095c8f2016-08-16 11:54:51 +0200643 etnaviv_iommu_restore(gpu);
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100644
645 /* Start command processor */
646 prefetch = etnaviv_buffer_init(gpu);
647
648 gpu_write(gpu, VIVS_HI_INTR_ENBL, ~0U);
Lucas Stach2f9225d2017-11-24 16:56:37 +0100649 etnaviv_gpu_start_fe(gpu, etnaviv_cmdbuf_get_va(&gpu->buffer),
Lucas Stach229855b2016-08-17 15:27:52 +0200650 prefetch);
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100651}
652
653int etnaviv_gpu_init(struct etnaviv_gpu *gpu)
654{
655 int ret, i;
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100656
657 ret = pm_runtime_get_sync(gpu->dev);
Lucas Stach1409df02016-06-17 12:29:02 +0200658 if (ret < 0) {
659 dev_err(gpu->dev, "Failed to enable GPU power domain\n");
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100660 return ret;
Lucas Stach1409df02016-06-17 12:29:02 +0200661 }
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100662
663 etnaviv_hw_identify(gpu);
664
665 if (gpu->identity.model == 0) {
666 dev_err(gpu->dev, "Unknown GPU model\n");
Russell Kingf6427762016-01-24 17:32:13 +0000667 ret = -ENXIO;
668 goto fail;
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100669 }
670
Russell Kingb98c6682016-01-21 15:19:59 +0000671 /* Exclude VG cores with FE2.0 */
672 if (gpu->identity.features & chipFeatures_PIPE_VG &&
673 gpu->identity.features & chipFeatures_FE20) {
674 dev_info(gpu->dev, "Ignoring GPU with VG and FE2.0\n");
675 ret = -ENXIO;
676 goto fail;
677 }
678
Lucas Stach2144fff2016-04-21 13:52:38 +0200679 /*
680 * Set the GPU linear window to be at the end of the DMA window, where
681 * the CMA area is likely to reside. This ensures that we are able to
682 * map the command buffers while having the linear window overlap as
683 * much RAM as possible, so we can optimize mappings for other buffers.
684 *
685 * For 3D cores only do this if MC2.0 is present, as with MC1.0 it leads
686 * to different views of the memory on the individual engines.
687 */
688 if (!(gpu->identity.features & chipFeatures_PIPE_3D) ||
689 (gpu->identity.minor_features0 & chipMinorFeatures0_MC20)) {
690 u32 dma_mask = (u32)dma_get_required_mask(gpu->dev);
691 if (dma_mask < PHYS_OFFSET + SZ_2G)
692 gpu->memory_base = PHYS_OFFSET;
693 else
694 gpu->memory_base = dma_mask - SZ_2G + 1;
Lucas Stach1db01272016-12-02 12:19:16 +0100695 } else if (PHYS_OFFSET >= SZ_2G) {
696 dev_info(gpu->dev, "Need to move linear window on MC1.0, disabling TS\n");
697 gpu->memory_base = PHYS_OFFSET;
698 gpu->identity.features &= ~chipFeatures_FAST_CLEAR;
Lucas Stach2144fff2016-04-21 13:52:38 +0200699 }
700
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100701 ret = etnaviv_hw_reset(gpu);
Lucas Stach1409df02016-06-17 12:29:02 +0200702 if (ret) {
703 dev_err(gpu->dev, "GPU reset failed\n");
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100704 goto fail;
Lucas Stach1409df02016-06-17 12:29:02 +0200705 }
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100706
Lucas Stachdd34bb92016-08-16 12:09:08 +0200707 gpu->mmu = etnaviv_iommu_new(gpu);
708 if (IS_ERR(gpu->mmu)) {
Lucas Stach1409df02016-06-17 12:29:02 +0200709 dev_err(gpu->dev, "Failed to instantiate GPU IOMMU\n");
Lucas Stachdd34bb92016-08-16 12:09:08 +0200710 ret = PTR_ERR(gpu->mmu);
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100711 goto fail;
712 }
713
Lucas Stache66774d2017-01-16 17:29:57 +0100714 gpu->cmdbuf_suballoc = etnaviv_cmdbuf_suballoc_new(gpu);
715 if (IS_ERR(gpu->cmdbuf_suballoc)) {
716 dev_err(gpu->dev, "Failed to create cmdbuf suballocator\n");
717 ret = PTR_ERR(gpu->cmdbuf_suballoc);
718 goto fail;
719 }
720
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100721 /* Create buffer: */
Lucas Stach2f9225d2017-11-24 16:56:37 +0100722 ret = etnaviv_cmdbuf_init(gpu->cmdbuf_suballoc, &gpu->buffer,
723 PAGE_SIZE);
724 if (ret) {
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100725 dev_err(gpu->dev, "could not create command buffer\n");
Lucas Stach45d16a62016-01-25 12:41:05 +0100726 goto destroy_iommu;
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100727 }
Lucas Stachacfee0e2016-08-17 16:19:53 +0200728
729 if (gpu->mmu->version == ETNAVIV_IOMMU_V1 &&
Lucas Stach2f9225d2017-11-24 16:56:37 +0100730 etnaviv_cmdbuf_get_va(&gpu->buffer) > 0x80000000) {
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100731 ret = -EINVAL;
732 dev_err(gpu->dev,
733 "command buffer outside valid memory window\n");
734 goto free_buffer;
735 }
736
737 /* Setup event management */
738 spin_lock_init(&gpu->event_spinlock);
739 init_completion(&gpu->event_free);
Christian Gmeiner355502e2017-09-24 15:15:19 +0200740 bitmap_zero(gpu->event_bitmap, ETNA_NR_EVENTS);
741 for (i = 0; i < ARRAY_SIZE(gpu->event); i++)
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100742 complete(&gpu->event_free);
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100743
744 /* Now program the hardware */
745 mutex_lock(&gpu->lock);
746 etnaviv_gpu_hw_init(gpu);
Russell Kingf6086312016-01-21 15:20:19 +0000747 gpu->exec_state = -1;
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100748 mutex_unlock(&gpu->lock);
749
750 pm_runtime_mark_last_busy(gpu->dev);
751 pm_runtime_put_autosuspend(gpu->dev);
752
753 return 0;
754
755free_buffer:
Lucas Stach2f9225d2017-11-24 16:56:37 +0100756 etnaviv_cmdbuf_free(&gpu->buffer);
Lucas Stach45d16a62016-01-25 12:41:05 +0100757destroy_iommu:
758 etnaviv_iommu_destroy(gpu->mmu);
759 gpu->mmu = NULL;
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100760fail:
761 pm_runtime_mark_last_busy(gpu->dev);
762 pm_runtime_put_autosuspend(gpu->dev);
763
764 return ret;
765}
766
767#ifdef CONFIG_DEBUG_FS
768struct dma_debug {
769 u32 address[2];
770 u32 state[2];
771};
772
773static void verify_dma(struct etnaviv_gpu *gpu, struct dma_debug *debug)
774{
775 u32 i;
776
777 debug->address[0] = gpu_read(gpu, VIVS_FE_DMA_ADDRESS);
778 debug->state[0] = gpu_read(gpu, VIVS_FE_DMA_DEBUG_STATE);
779
780 for (i = 0; i < 500; i++) {
781 debug->address[1] = gpu_read(gpu, VIVS_FE_DMA_ADDRESS);
782 debug->state[1] = gpu_read(gpu, VIVS_FE_DMA_DEBUG_STATE);
783
784 if (debug->address[0] != debug->address[1])
785 break;
786
787 if (debug->state[0] != debug->state[1])
788 break;
789 }
790}
791
792int etnaviv_gpu_debugfs(struct etnaviv_gpu *gpu, struct seq_file *m)
793{
794 struct dma_debug debug;
795 u32 dma_lo, dma_hi, axi, idle;
796 int ret;
797
798 seq_printf(m, "%s Status:\n", dev_name(gpu->dev));
799
800 ret = pm_runtime_get_sync(gpu->dev);
801 if (ret < 0)
802 return ret;
803
804 dma_lo = gpu_read(gpu, VIVS_FE_DMA_LOW);
805 dma_hi = gpu_read(gpu, VIVS_FE_DMA_HIGH);
806 axi = gpu_read(gpu, VIVS_HI_AXI_STATUS);
807 idle = gpu_read(gpu, VIVS_HI_IDLE_STATE);
808
809 verify_dma(gpu, &debug);
810
811 seq_puts(m, "\tfeatures\n");
Lucas Stach3d9fc642018-01-04 13:50:14 +0100812 seq_printf(m, "\t major_features: 0x%08x\n",
813 gpu->identity.features);
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100814 seq_printf(m, "\t minor_features0: 0x%08x\n",
815 gpu->identity.minor_features0);
816 seq_printf(m, "\t minor_features1: 0x%08x\n",
817 gpu->identity.minor_features1);
818 seq_printf(m, "\t minor_features2: 0x%08x\n",
819 gpu->identity.minor_features2);
820 seq_printf(m, "\t minor_features3: 0x%08x\n",
821 gpu->identity.minor_features3);
Russell King602eb482016-01-24 17:36:04 +0000822 seq_printf(m, "\t minor_features4: 0x%08x\n",
823 gpu->identity.minor_features4);
824 seq_printf(m, "\t minor_features5: 0x%08x\n",
825 gpu->identity.minor_features5);
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100826
827 seq_puts(m, "\tspecs\n");
828 seq_printf(m, "\t stream_count: %d\n",
829 gpu->identity.stream_count);
830 seq_printf(m, "\t register_max: %d\n",
831 gpu->identity.register_max);
832 seq_printf(m, "\t thread_count: %d\n",
833 gpu->identity.thread_count);
834 seq_printf(m, "\t vertex_cache_size: %d\n",
835 gpu->identity.vertex_cache_size);
836 seq_printf(m, "\t shader_core_count: %d\n",
837 gpu->identity.shader_core_count);
838 seq_printf(m, "\t pixel_pipes: %d\n",
839 gpu->identity.pixel_pipes);
840 seq_printf(m, "\t vertex_output_buffer_size: %d\n",
841 gpu->identity.vertex_output_buffer_size);
842 seq_printf(m, "\t buffer_size: %d\n",
843 gpu->identity.buffer_size);
844 seq_printf(m, "\t instruction_count: %d\n",
845 gpu->identity.instruction_count);
846 seq_printf(m, "\t num_constants: %d\n",
847 gpu->identity.num_constants);
Russell King602eb482016-01-24 17:36:04 +0000848 seq_printf(m, "\t varyings_count: %d\n",
849 gpu->identity.varyings_count);
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100850
851 seq_printf(m, "\taxi: 0x%08x\n", axi);
852 seq_printf(m, "\tidle: 0x%08x\n", idle);
853 idle |= ~gpu->idle_mask & ~VIVS_HI_IDLE_STATE_AXI_LP;
854 if ((idle & VIVS_HI_IDLE_STATE_FE) == 0)
855 seq_puts(m, "\t FE is not idle\n");
856 if ((idle & VIVS_HI_IDLE_STATE_DE) == 0)
857 seq_puts(m, "\t DE is not idle\n");
858 if ((idle & VIVS_HI_IDLE_STATE_PE) == 0)
859 seq_puts(m, "\t PE is not idle\n");
860 if ((idle & VIVS_HI_IDLE_STATE_SH) == 0)
861 seq_puts(m, "\t SH is not idle\n");
862 if ((idle & VIVS_HI_IDLE_STATE_PA) == 0)
863 seq_puts(m, "\t PA is not idle\n");
864 if ((idle & VIVS_HI_IDLE_STATE_SE) == 0)
865 seq_puts(m, "\t SE is not idle\n");
866 if ((idle & VIVS_HI_IDLE_STATE_RA) == 0)
867 seq_puts(m, "\t RA is not idle\n");
868 if ((idle & VIVS_HI_IDLE_STATE_TX) == 0)
869 seq_puts(m, "\t TX is not idle\n");
870 if ((idle & VIVS_HI_IDLE_STATE_VG) == 0)
871 seq_puts(m, "\t VG is not idle\n");
872 if ((idle & VIVS_HI_IDLE_STATE_IM) == 0)
873 seq_puts(m, "\t IM is not idle\n");
874 if ((idle & VIVS_HI_IDLE_STATE_FP) == 0)
875 seq_puts(m, "\t FP is not idle\n");
876 if ((idle & VIVS_HI_IDLE_STATE_TS) == 0)
877 seq_puts(m, "\t TS is not idle\n");
878 if (idle & VIVS_HI_IDLE_STATE_AXI_LP)
879 seq_puts(m, "\t AXI low power mode\n");
880
881 if (gpu->identity.features & chipFeatures_DEBUG_MODE) {
882 u32 read0 = gpu_read(gpu, VIVS_MC_DEBUG_READ0);
883 u32 read1 = gpu_read(gpu, VIVS_MC_DEBUG_READ1);
884 u32 write = gpu_read(gpu, VIVS_MC_DEBUG_WRITE);
885
886 seq_puts(m, "\tMC\n");
887 seq_printf(m, "\t read0: 0x%08x\n", read0);
888 seq_printf(m, "\t read1: 0x%08x\n", read1);
889 seq_printf(m, "\t write: 0x%08x\n", write);
890 }
891
892 seq_puts(m, "\tDMA ");
893
894 if (debug.address[0] == debug.address[1] &&
895 debug.state[0] == debug.state[1]) {
896 seq_puts(m, "seems to be stuck\n");
897 } else if (debug.address[0] == debug.address[1]) {
Masanari Iidac01e0152016-04-20 00:27:33 +0900898 seq_puts(m, "address is constant\n");
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100899 } else {
Masanari Iidac01e0152016-04-20 00:27:33 +0900900 seq_puts(m, "is running\n");
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100901 }
902
903 seq_printf(m, "\t address 0: 0x%08x\n", debug.address[0]);
904 seq_printf(m, "\t address 1: 0x%08x\n", debug.address[1]);
905 seq_printf(m, "\t state 0: 0x%08x\n", debug.state[0]);
906 seq_printf(m, "\t state 1: 0x%08x\n", debug.state[1]);
907 seq_printf(m, "\t last fetch 64 bit word: 0x%08x 0x%08x\n",
908 dma_lo, dma_hi);
909
910 ret = 0;
911
912 pm_runtime_mark_last_busy(gpu->dev);
913 pm_runtime_put_autosuspend(gpu->dev);
914
915 return ret;
916}
917#endif
918
Lucas Stach6d7a20c2017-12-06 10:53:27 +0100919void etnaviv_gpu_recover_hang(struct etnaviv_gpu *gpu)
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100920{
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100921 unsigned long flags;
Christian Gmeiner355502e2017-09-24 15:15:19 +0200922 unsigned int i = 0;
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100923
Lucas Stach6d7a20c2017-12-06 10:53:27 +0100924 dev_err(gpu->dev, "recover hung GPU!\n");
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100925
926 if (pm_runtime_get_sync(gpu->dev) < 0)
927 return;
928
929 mutex_lock(&gpu->lock);
930
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100931 etnaviv_hw_reset(gpu);
932
933 /* complete all events, the GPU won't do it after the reset */
934 spin_lock_irqsave(&gpu->event_spinlock, flags);
Lucas Stach6d7a20c2017-12-06 10:53:27 +0100935 for_each_set_bit_from(i, gpu->event_bitmap, ETNA_NR_EVENTS)
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100936 complete(&gpu->event_free);
Christian Gmeiner355502e2017-09-24 15:15:19 +0200937 bitmap_zero(gpu->event_bitmap, ETNA_NR_EVENTS);
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100938 spin_unlock_irqrestore(&gpu->event_spinlock, flags);
939 gpu->completed_fence = gpu->active_fence;
940
941 etnaviv_gpu_hw_init(gpu);
Lucas Stach1b94a9b2016-09-15 12:57:32 +0200942 gpu->lastctx = NULL;
Russell Kingf6086312016-01-21 15:20:19 +0000943 gpu->exec_state = -1;
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100944
945 mutex_unlock(&gpu->lock);
946 pm_runtime_mark_last_busy(gpu->dev);
947 pm_runtime_put_autosuspend(gpu->dev);
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100948}
949
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100950/* fence object management */
951struct etnaviv_fence {
952 struct etnaviv_gpu *gpu;
Chris Wilsonf54d1862016-10-25 13:00:45 +0100953 struct dma_fence base;
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100954};
955
Chris Wilsonf54d1862016-10-25 13:00:45 +0100956static inline struct etnaviv_fence *to_etnaviv_fence(struct dma_fence *fence)
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100957{
958 return container_of(fence, struct etnaviv_fence, base);
959}
960
Chris Wilsonf54d1862016-10-25 13:00:45 +0100961static const char *etnaviv_fence_get_driver_name(struct dma_fence *fence)
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100962{
963 return "etnaviv";
964}
965
Chris Wilsonf54d1862016-10-25 13:00:45 +0100966static const char *etnaviv_fence_get_timeline_name(struct dma_fence *fence)
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100967{
968 struct etnaviv_fence *f = to_etnaviv_fence(fence);
969
970 return dev_name(f->gpu->dev);
971}
972
Chris Wilsonf54d1862016-10-25 13:00:45 +0100973static bool etnaviv_fence_enable_signaling(struct dma_fence *fence)
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100974{
975 return true;
976}
977
Chris Wilsonf54d1862016-10-25 13:00:45 +0100978static bool etnaviv_fence_signaled(struct dma_fence *fence)
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100979{
980 struct etnaviv_fence *f = to_etnaviv_fence(fence);
981
982 return fence_completed(f->gpu, f->base.seqno);
983}
984
Chris Wilsonf54d1862016-10-25 13:00:45 +0100985static void etnaviv_fence_release(struct dma_fence *fence)
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100986{
987 struct etnaviv_fence *f = to_etnaviv_fence(fence);
988
989 kfree_rcu(f, base.rcu);
990}
991
Chris Wilsonf54d1862016-10-25 13:00:45 +0100992static const struct dma_fence_ops etnaviv_fence_ops = {
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100993 .get_driver_name = etnaviv_fence_get_driver_name,
994 .get_timeline_name = etnaviv_fence_get_timeline_name,
995 .enable_signaling = etnaviv_fence_enable_signaling,
996 .signaled = etnaviv_fence_signaled,
Chris Wilsonf54d1862016-10-25 13:00:45 +0100997 .wait = dma_fence_default_wait,
The etnaviv authorsa8c21a52015-12-03 18:21:29 +0100998 .release = etnaviv_fence_release,
999};
1000
Chris Wilsonf54d1862016-10-25 13:00:45 +01001001static struct dma_fence *etnaviv_gpu_fence_alloc(struct etnaviv_gpu *gpu)
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001002{
1003 struct etnaviv_fence *f;
1004
Lucas Stachb27734c22017-03-22 12:23:43 +01001005 /*
1006 * GPU lock must already be held, otherwise fence completion order might
1007 * not match the seqno order assigned here.
1008 */
1009 lockdep_assert_held(&gpu->lock);
1010
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001011 f = kzalloc(sizeof(*f), GFP_KERNEL);
1012 if (!f)
1013 return NULL;
1014
1015 f->gpu = gpu;
1016
Chris Wilsonf54d1862016-10-25 13:00:45 +01001017 dma_fence_init(&f->base, &etnaviv_fence_ops, &gpu->fence_spinlock,
1018 gpu->fence_context, ++gpu->next_fence);
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001019
1020 return &f->base;
1021}
1022
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001023/*
1024 * event management:
1025 */
1026
Christian Gmeiner95a428c2017-09-24 15:15:20 +02001027static int event_alloc(struct etnaviv_gpu *gpu, unsigned nr_events,
1028 unsigned int *events)
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001029{
Christian Gmeiner95a428c2017-09-24 15:15:20 +02001030 unsigned long flags, timeout = msecs_to_jiffies(10 * 10000);
1031 unsigned i, acquired = 0;
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001032
Christian Gmeiner95a428c2017-09-24 15:15:20 +02001033 for (i = 0; i < nr_events; i++) {
1034 unsigned long ret;
1035
1036 ret = wait_for_completion_timeout(&gpu->event_free, timeout);
1037
1038 if (!ret) {
1039 dev_err(gpu->dev, "wait_for_completion_timeout failed");
1040 goto out;
1041 }
1042
1043 acquired++;
1044 timeout = ret;
1045 }
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001046
1047 spin_lock_irqsave(&gpu->event_spinlock, flags);
1048
Christian Gmeiner95a428c2017-09-24 15:15:20 +02001049 for (i = 0; i < nr_events; i++) {
1050 int event = find_first_zero_bit(gpu->event_bitmap, ETNA_NR_EVENTS);
1051
1052 events[i] = event;
Christian Gmeiner547d3402017-09-24 15:15:29 +02001053 memset(&gpu->event[event], 0, sizeof(struct etnaviv_event));
Christian Gmeiner355502e2017-09-24 15:15:19 +02001054 set_bit(event, gpu->event_bitmap);
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001055 }
1056
1057 spin_unlock_irqrestore(&gpu->event_spinlock, flags);
1058
Christian Gmeiner95a428c2017-09-24 15:15:20 +02001059 return 0;
1060
1061out:
1062 for (i = 0; i < acquired; i++)
1063 complete(&gpu->event_free);
1064
1065 return -EBUSY;
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001066}
1067
1068static void event_free(struct etnaviv_gpu *gpu, unsigned int event)
1069{
1070 unsigned long flags;
1071
1072 spin_lock_irqsave(&gpu->event_spinlock, flags);
1073
Christian Gmeiner355502e2017-09-24 15:15:19 +02001074 if (!test_bit(event, gpu->event_bitmap)) {
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001075 dev_warn(gpu->dev, "event %u is already marked as free",
1076 event);
1077 spin_unlock_irqrestore(&gpu->event_spinlock, flags);
1078 } else {
Christian Gmeiner355502e2017-09-24 15:15:19 +02001079 clear_bit(event, gpu->event_bitmap);
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001080 spin_unlock_irqrestore(&gpu->event_spinlock, flags);
1081
1082 complete(&gpu->event_free);
1083 }
1084}
1085
1086/*
1087 * Cmdstream submission/retirement:
1088 */
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001089int etnaviv_gpu_wait_fence_interruptible(struct etnaviv_gpu *gpu,
Lucas Stach8bc4d882017-11-29 14:49:04 +01001090 u32 id, struct timespec *timeout)
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001091{
Lucas Stach8bc4d882017-11-29 14:49:04 +01001092 struct dma_fence *fence;
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001093 int ret;
1094
Lucas Stach8bc4d882017-11-29 14:49:04 +01001095 /*
Lucas Stache93b6de2017-12-04 18:41:58 +01001096 * Look up the fence and take a reference. We might still find a fence
Lucas Stach8bc4d882017-11-29 14:49:04 +01001097 * whose refcount has already dropped to zero. dma_fence_get_rcu
1098 * pretends we didn't find a fence in that case.
1099 */
Lucas Stache93b6de2017-12-04 18:41:58 +01001100 rcu_read_lock();
Lucas Stach8bc4d882017-11-29 14:49:04 +01001101 fence = idr_find(&gpu->fence_idr, id);
1102 if (fence)
1103 fence = dma_fence_get_rcu(fence);
Lucas Stache93b6de2017-12-04 18:41:58 +01001104 rcu_read_unlock();
Lucas Stach8bc4d882017-11-29 14:49:04 +01001105
1106 if (!fence)
1107 return 0;
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001108
1109 if (!timeout) {
1110 /* No timeout was requested: just test for completion */
Lucas Stach8bc4d882017-11-29 14:49:04 +01001111 ret = dma_fence_is_signaled(fence) ? 0 : -EBUSY;
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001112 } else {
1113 unsigned long remaining = etnaviv_timeout_to_jiffies(timeout);
1114
Lucas Stach8bc4d882017-11-29 14:49:04 +01001115 ret = dma_fence_wait_timeout(fence, true, remaining);
1116 if (ret == 0)
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001117 ret = -ETIMEDOUT;
Lucas Stach8bc4d882017-11-29 14:49:04 +01001118 else if (ret != -ERESTARTSYS)
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001119 ret = 0;
Lucas Stach8bc4d882017-11-29 14:49:04 +01001120
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001121 }
1122
Lucas Stach8bc4d882017-11-29 14:49:04 +01001123 dma_fence_put(fence);
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001124 return ret;
1125}
1126
1127/*
1128 * Wait for an object to become inactive. This, on it's own, is not race
Lucas Stache93b6de2017-12-04 18:41:58 +01001129 * free: the object is moved by the scheduler off the active list, and
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001130 * then the iova is put. Moreover, the object could be re-submitted just
1131 * after we notice that it's become inactive.
1132 *
1133 * Although the retirement happens under the gpu lock, we don't want to hold
1134 * that lock in this function while waiting.
1135 */
1136int etnaviv_gpu_wait_obj_inactive(struct etnaviv_gpu *gpu,
1137 struct etnaviv_gem_object *etnaviv_obj, struct timespec *timeout)
1138{
1139 unsigned long remaining;
1140 long ret;
1141
1142 if (!timeout)
1143 return !is_active(etnaviv_obj) ? 0 : -EBUSY;
1144
1145 remaining = etnaviv_timeout_to_jiffies(timeout);
1146
1147 ret = wait_event_interruptible_timeout(gpu->fence_event,
1148 !is_active(etnaviv_obj),
1149 remaining);
Lucas Stachfa67ac82017-11-17 16:35:32 +01001150 if (ret > 0)
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001151 return 0;
Lucas Stachfa67ac82017-11-17 16:35:32 +01001152 else if (ret == -ERESTARTSYS)
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001153 return -ERESTARTSYS;
Lucas Stachfa67ac82017-11-17 16:35:32 +01001154 else
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001155 return -ETIMEDOUT;
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001156}
1157
Christian Gmeiner68dc0b22017-09-24 15:15:30 +02001158static void sync_point_perfmon_sample(struct etnaviv_gpu *gpu,
1159 struct etnaviv_event *event, unsigned int flags)
1160{
Lucas Stachef146c002017-11-24 12:02:38 +01001161 const struct etnaviv_gem_submit *submit = event->submit;
Christian Gmeiner68dc0b22017-09-24 15:15:30 +02001162 unsigned int i;
1163
Lucas Stachef146c002017-11-24 12:02:38 +01001164 for (i = 0; i < submit->nr_pmrs; i++) {
1165 const struct etnaviv_perfmon_request *pmr = submit->pmrs + i;
Christian Gmeiner68dc0b22017-09-24 15:15:30 +02001166
1167 if (pmr->flags == flags)
Lucas Stach7a9c0fe2017-11-24 15:19:16 +01001168 etnaviv_perfmon_process(gpu, pmr, submit->exec_state);
Christian Gmeiner68dc0b22017-09-24 15:15:30 +02001169 }
1170}
1171
1172static void sync_point_perfmon_sample_pre(struct etnaviv_gpu *gpu,
1173 struct etnaviv_event *event)
1174{
Christian Gmeiner2c8b0c52017-09-24 15:15:39 +02001175 u32 val;
1176
1177 /* disable clock gating */
1178 val = gpu_read(gpu, VIVS_PM_POWER_CONTROLS);
1179 val &= ~VIVS_PM_POWER_CONTROLS_ENABLE_MODULE_CLOCK_GATING;
1180 gpu_write(gpu, VIVS_PM_POWER_CONTROLS, val);
1181
Christian Gmeiner04a7d182017-09-24 15:15:42 +02001182 /* enable debug register */
1183 val = gpu_read(gpu, VIVS_HI_CLOCK_CONTROL);
1184 val &= ~VIVS_HI_CLOCK_CONTROL_DISABLE_DEBUG_REGISTERS;
1185 gpu_write(gpu, VIVS_HI_CLOCK_CONTROL, val);
1186
Christian Gmeiner68dc0b22017-09-24 15:15:30 +02001187 sync_point_perfmon_sample(gpu, event, ETNA_PM_PROCESS_PRE);
1188}
1189
1190static void sync_point_perfmon_sample_post(struct etnaviv_gpu *gpu,
1191 struct etnaviv_event *event)
1192{
Lucas Stachef146c002017-11-24 12:02:38 +01001193 const struct etnaviv_gem_submit *submit = event->submit;
Christian Gmeiner68dc0b22017-09-24 15:15:30 +02001194 unsigned int i;
Christian Gmeiner2c8b0c52017-09-24 15:15:39 +02001195 u32 val;
Christian Gmeiner68dc0b22017-09-24 15:15:30 +02001196
1197 sync_point_perfmon_sample(gpu, event, ETNA_PM_PROCESS_POST);
1198
Lucas Stachef146c002017-11-24 12:02:38 +01001199 for (i = 0; i < submit->nr_pmrs; i++) {
1200 const struct etnaviv_perfmon_request *pmr = submit->pmrs + i;
Christian Gmeiner68dc0b22017-09-24 15:15:30 +02001201
1202 *pmr->bo_vma = pmr->sequence;
1203 }
Christian Gmeiner2c8b0c52017-09-24 15:15:39 +02001204
Christian Gmeiner04a7d182017-09-24 15:15:42 +02001205 /* disable debug register */
1206 val = gpu_read(gpu, VIVS_HI_CLOCK_CONTROL);
1207 val |= VIVS_HI_CLOCK_CONTROL_DISABLE_DEBUG_REGISTERS;
1208 gpu_write(gpu, VIVS_HI_CLOCK_CONTROL, val);
1209
Christian Gmeiner2c8b0c52017-09-24 15:15:39 +02001210 /* enable clock gating */
1211 val = gpu_read(gpu, VIVS_PM_POWER_CONTROLS);
1212 val |= VIVS_PM_POWER_CONTROLS_ENABLE_MODULE_CLOCK_GATING;
1213 gpu_write(gpu, VIVS_PM_POWER_CONTROLS, val);
Christian Gmeiner68dc0b22017-09-24 15:15:30 +02001214}
1215
1216
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001217/* add bo's to gpu's ring, and kick gpu: */
Lucas Stache93b6de2017-12-04 18:41:58 +01001218struct dma_fence *etnaviv_gpu_submit(struct etnaviv_gem_submit *submit)
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001219{
Lucas Stache93b6de2017-12-04 18:41:58 +01001220 struct etnaviv_gpu *gpu = submit->gpu;
1221 struct dma_fence *gpu_fence;
Christian Gmeiner68dc0b22017-09-24 15:15:30 +02001222 unsigned int i, nr_events = 1, event[3];
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001223 int ret;
1224
Lucas Stach6d7a20c2017-12-06 10:53:27 +01001225 if (!submit->runtime_resumed) {
1226 ret = pm_runtime_get_sync(gpu->dev);
1227 if (ret < 0)
1228 return NULL;
1229 submit->runtime_resumed = true;
1230 }
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001231
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001232 /*
Christian Gmeiner68dc0b22017-09-24 15:15:30 +02001233 * if there are performance monitor requests we need to have
1234 * - a sync point to re-configure gpu and process ETNA_PM_PROCESS_PRE
1235 * requests.
1236 * - a sync point to re-configure gpu, process ETNA_PM_PROCESS_POST requests
1237 * and update the sequence number for userspace.
1238 */
Lucas Stachef146c002017-11-24 12:02:38 +01001239 if (submit->nr_pmrs)
Christian Gmeiner68dc0b22017-09-24 15:15:30 +02001240 nr_events = 3;
1241
1242 ret = event_alloc(gpu, nr_events, event);
Christian Gmeiner95a428c2017-09-24 15:15:20 +02001243 if (ret) {
Christian Gmeiner68dc0b22017-09-24 15:15:30 +02001244 DRM_ERROR("no free events\n");
Lucas Stache93b6de2017-12-04 18:41:58 +01001245 return NULL;
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001246 }
1247
Lucas Stachf3cd1b02017-03-22 12:07:23 +01001248 mutex_lock(&gpu->lock);
1249
Lucas Stache93b6de2017-12-04 18:41:58 +01001250 gpu_fence = etnaviv_gpu_fence_alloc(gpu);
1251 if (!gpu_fence) {
Christian Gmeiner68dc0b22017-09-24 15:15:30 +02001252 for (i = 0; i < nr_events; i++)
1253 event_free(gpu, event[i]);
1254
Wei Yongjun45abdf32017-04-12 00:31:16 +00001255 goto out_unlock;
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001256 }
1257
Lucas Stache93b6de2017-12-04 18:41:58 +01001258 gpu->active_fence = gpu_fence->seqno;
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001259
Lucas Stachef146c002017-11-24 12:02:38 +01001260 if (submit->nr_pmrs) {
Christian Gmeiner68dc0b22017-09-24 15:15:30 +02001261 gpu->event[event[1]].sync_point = &sync_point_perfmon_sample_pre;
Lucas Stachef146c002017-11-24 12:02:38 +01001262 kref_get(&submit->refcount);
1263 gpu->event[event[1]].submit = submit;
Christian Gmeiner68dc0b22017-09-24 15:15:30 +02001264 etnaviv_sync_point_queue(gpu, event[1]);
1265 }
1266
Lucas Stache93b6de2017-12-04 18:41:58 +01001267 gpu->event[event[0]].fence = gpu_fence;
Lucas Stach6d7a20c2017-12-06 10:53:27 +01001268 submit->cmdbuf.user_size = submit->cmdbuf.size - 8;
Lucas Stach2f9225d2017-11-24 16:56:37 +01001269 etnaviv_buffer_queue(gpu, submit->exec_state, event[0],
1270 &submit->cmdbuf);
Christian Gmeiner68dc0b22017-09-24 15:15:30 +02001271
Lucas Stachef146c002017-11-24 12:02:38 +01001272 if (submit->nr_pmrs) {
Christian Gmeiner68dc0b22017-09-24 15:15:30 +02001273 gpu->event[event[2]].sync_point = &sync_point_perfmon_sample_post;
Lucas Stachef146c002017-11-24 12:02:38 +01001274 kref_get(&submit->refcount);
1275 gpu->event[event[2]].submit = submit;
Christian Gmeiner68dc0b22017-09-24 15:15:30 +02001276 etnaviv_sync_point_queue(gpu, event[2]);
1277 }
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001278
Wei Yongjun45abdf32017-04-12 00:31:16 +00001279out_unlock:
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001280 mutex_unlock(&gpu->lock);
1281
Lucas Stache93b6de2017-12-04 18:41:58 +01001282 return gpu_fence;
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001283}
1284
Christian Gmeiner357713c2017-09-24 15:15:28 +02001285static void sync_point_worker(struct work_struct *work)
1286{
1287 struct etnaviv_gpu *gpu = container_of(work, struct etnaviv_gpu,
1288 sync_point_work);
Lucas Stachb9a48aa2017-10-19 13:48:40 +02001289 struct etnaviv_event *event = &gpu->event[gpu->sync_point_event];
1290 u32 addr = gpu_read(gpu, VIVS_FE_DMA_ADDRESS);
Christian Gmeiner357713c2017-09-24 15:15:28 +02001291
Lucas Stachb9a48aa2017-10-19 13:48:40 +02001292 event->sync_point(gpu, event);
Lucas Stachef146c002017-11-24 12:02:38 +01001293 etnaviv_submit_put(event->submit);
Christian Gmeiner357713c2017-09-24 15:15:28 +02001294 event_free(gpu, gpu->sync_point_event);
Lucas Stachb9a48aa2017-10-19 13:48:40 +02001295
1296 /* restart FE last to avoid GPU and IRQ racing against this worker */
1297 etnaviv_gpu_start_fe(gpu, addr + 2, 2);
Christian Gmeiner357713c2017-09-24 15:15:28 +02001298}
1299
Lucas Stach4df30002018-01-19 12:22:30 +01001300static void dump_mmu_fault(struct etnaviv_gpu *gpu)
1301{
1302 u32 status = gpu_read(gpu, VIVS_MMUv2_STATUS);
1303 int i;
1304
1305 dev_err_ratelimited(gpu->dev, "MMU fault status 0x%08x\n", status);
1306
1307 for (i = 0; i < 4; i++) {
1308 if (!(status & (VIVS_MMUv2_STATUS_EXCEPTION0__MASK << (i * 4))))
1309 continue;
1310
1311 dev_err_ratelimited(gpu->dev, "MMU %d fault addr 0x%08x\n", i,
1312 gpu_read(gpu, VIVS_MMUv2_EXCEPTION_ADDR(i)));
1313 }
1314}
1315
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001316static irqreturn_t irq_handler(int irq, void *data)
1317{
1318 struct etnaviv_gpu *gpu = data;
1319 irqreturn_t ret = IRQ_NONE;
1320
1321 u32 intr = gpu_read(gpu, VIVS_HI_INTR_ACKNOWLEDGE);
1322
1323 if (intr != 0) {
1324 int event;
1325
1326 pm_runtime_mark_last_busy(gpu->dev);
1327
1328 dev_dbg(gpu->dev, "intr 0x%08x\n", intr);
1329
1330 if (intr & VIVS_HI_INTR_ACKNOWLEDGE_AXI_BUS_ERROR) {
1331 dev_err(gpu->dev, "AXI bus error\n");
1332 intr &= ~VIVS_HI_INTR_ACKNOWLEDGE_AXI_BUS_ERROR;
1333 }
1334
Lucas Stach128a9b12016-08-20 00:14:43 +02001335 if (intr & VIVS_HI_INTR_ACKNOWLEDGE_MMU_EXCEPTION) {
Lucas Stach4df30002018-01-19 12:22:30 +01001336 dump_mmu_fault(gpu);
Lucas Stach128a9b12016-08-20 00:14:43 +02001337 intr &= ~VIVS_HI_INTR_ACKNOWLEDGE_MMU_EXCEPTION;
1338 }
1339
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001340 while ((event = ffs(intr)) != 0) {
Chris Wilsonf54d1862016-10-25 13:00:45 +01001341 struct dma_fence *fence;
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001342
1343 event -= 1;
1344
1345 intr &= ~(1 << event);
1346
1347 dev_dbg(gpu->dev, "event %u\n", event);
1348
Christian Gmeiner357713c2017-09-24 15:15:28 +02001349 if (gpu->event[event].sync_point) {
1350 gpu->sync_point_event = event;
Lucas Stacha7790d72017-11-17 17:43:37 +01001351 queue_work(gpu->wq, &gpu->sync_point_work);
Christian Gmeiner357713c2017-09-24 15:15:28 +02001352 }
1353
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001354 fence = gpu->event[event].fence;
Christian Gmeiner68dc0b22017-09-24 15:15:30 +02001355 if (!fence)
1356 continue;
1357
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001358 gpu->event[event].fence = NULL;
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001359
1360 /*
1361 * Events can be processed out of order. Eg,
1362 * - allocate and queue event 0
1363 * - allocate event 1
1364 * - event 0 completes, we process it
1365 * - allocate and queue event 0
1366 * - event 1 and event 0 complete
1367 * we can end up processing event 0 first, then 1.
1368 */
1369 if (fence_after(fence->seqno, gpu->completed_fence))
1370 gpu->completed_fence = fence->seqno;
Lucas Stach8bc4d882017-11-29 14:49:04 +01001371 dma_fence_signal(fence);
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001372
1373 event_free(gpu, event);
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001374 }
1375
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001376 ret = IRQ_HANDLED;
1377 }
1378
1379 return ret;
1380}
1381
1382static int etnaviv_gpu_clk_enable(struct etnaviv_gpu *gpu)
1383{
1384 int ret;
1385
Lucas Stach65f037e2018-01-19 15:05:40 +01001386 if (gpu->clk_reg) {
1387 ret = clk_prepare_enable(gpu->clk_reg);
1388 if (ret)
1389 return ret;
1390 }
1391
Lucas Stach9c7310c2016-08-22 15:26:19 +02001392 if (gpu->clk_bus) {
1393 ret = clk_prepare_enable(gpu->clk_bus);
1394 if (ret)
1395 return ret;
1396 }
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001397
Lucas Stach9c7310c2016-08-22 15:26:19 +02001398 if (gpu->clk_core) {
1399 ret = clk_prepare_enable(gpu->clk_core);
1400 if (ret)
1401 goto disable_clk_bus;
1402 }
1403
1404 if (gpu->clk_shader) {
1405 ret = clk_prepare_enable(gpu->clk_shader);
1406 if (ret)
1407 goto disable_clk_core;
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001408 }
1409
1410 return 0;
Lucas Stach9c7310c2016-08-22 15:26:19 +02001411
1412disable_clk_core:
1413 if (gpu->clk_core)
1414 clk_disable_unprepare(gpu->clk_core);
1415disable_clk_bus:
1416 if (gpu->clk_bus)
1417 clk_disable_unprepare(gpu->clk_bus);
1418
1419 return ret;
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001420}
1421
1422static int etnaviv_gpu_clk_disable(struct etnaviv_gpu *gpu)
1423{
Lucas Stach9c7310c2016-08-22 15:26:19 +02001424 if (gpu->clk_shader)
1425 clk_disable_unprepare(gpu->clk_shader);
1426 if (gpu->clk_core)
1427 clk_disable_unprepare(gpu->clk_core);
1428 if (gpu->clk_bus)
1429 clk_disable_unprepare(gpu->clk_bus);
Lucas Stach65f037e2018-01-19 15:05:40 +01001430 if (gpu->clk_reg)
1431 clk_disable_unprepare(gpu->clk_reg);
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001432
1433 return 0;
1434}
1435
Lucas Stachb88163e2016-08-17 15:16:57 +02001436int etnaviv_gpu_wait_idle(struct etnaviv_gpu *gpu, unsigned int timeout_ms)
1437{
1438 unsigned long timeout = jiffies + msecs_to_jiffies(timeout_ms);
1439
1440 do {
1441 u32 idle = gpu_read(gpu, VIVS_HI_IDLE_STATE);
1442
1443 if ((idle & gpu->idle_mask) == gpu->idle_mask)
1444 return 0;
1445
1446 if (time_is_before_jiffies(timeout)) {
1447 dev_warn(gpu->dev,
1448 "timed out waiting for idle: idle=0x%x\n",
1449 idle);
1450 return -ETIMEDOUT;
1451 }
1452
1453 udelay(5);
1454 } while (1);
1455}
1456
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001457static int etnaviv_gpu_hw_suspend(struct etnaviv_gpu *gpu)
1458{
Lucas Stach2f9225d2017-11-24 16:56:37 +01001459 if (gpu->buffer.suballoc) {
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001460 /* Replace the last WAIT with END */
Lucas Stach40c27bd2017-11-17 17:59:26 +01001461 mutex_lock(&gpu->lock);
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001462 etnaviv_buffer_end(gpu);
Lucas Stach40c27bd2017-11-17 17:59:26 +01001463 mutex_unlock(&gpu->lock);
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001464
1465 /*
1466 * We know that only the FE is busy here, this should
1467 * happen quickly (as the WAIT is only 200 cycles). If
1468 * we fail, just warn and continue.
1469 */
Lucas Stachb88163e2016-08-17 15:16:57 +02001470 etnaviv_gpu_wait_idle(gpu, 100);
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001471 }
1472
1473 return etnaviv_gpu_clk_disable(gpu);
1474}
1475
1476#ifdef CONFIG_PM
1477static int etnaviv_gpu_hw_resume(struct etnaviv_gpu *gpu)
1478{
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001479 int ret;
1480
1481 ret = mutex_lock_killable(&gpu->lock);
1482 if (ret)
1483 return ret;
1484
Russell Kingbcdfb5e2017-03-12 19:00:59 +00001485 etnaviv_gpu_update_clock(gpu);
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001486 etnaviv_gpu_hw_init(gpu);
1487
Lucas Stach4375fff2017-11-17 17:19:50 +01001488 gpu->lastctx = NULL;
Russell Kingf6086312016-01-21 15:20:19 +00001489 gpu->exec_state = -1;
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001490
1491 mutex_unlock(&gpu->lock);
1492
1493 return 0;
1494}
1495#endif
1496
Russell Kingbcdfb5e2017-03-12 19:00:59 +00001497static int
1498etnaviv_gpu_cooling_get_max_state(struct thermal_cooling_device *cdev,
1499 unsigned long *state)
1500{
1501 *state = 6;
1502
1503 return 0;
1504}
1505
1506static int
1507etnaviv_gpu_cooling_get_cur_state(struct thermal_cooling_device *cdev,
1508 unsigned long *state)
1509{
1510 struct etnaviv_gpu *gpu = cdev->devdata;
1511
1512 *state = gpu->freq_scale;
1513
1514 return 0;
1515}
1516
1517static int
1518etnaviv_gpu_cooling_set_cur_state(struct thermal_cooling_device *cdev,
1519 unsigned long state)
1520{
1521 struct etnaviv_gpu *gpu = cdev->devdata;
1522
1523 mutex_lock(&gpu->lock);
1524 gpu->freq_scale = state;
1525 if (!pm_runtime_suspended(gpu->dev))
1526 etnaviv_gpu_update_clock(gpu);
1527 mutex_unlock(&gpu->lock);
1528
1529 return 0;
1530}
1531
1532static struct thermal_cooling_device_ops cooling_ops = {
1533 .get_max_state = etnaviv_gpu_cooling_get_max_state,
1534 .get_cur_state = etnaviv_gpu_cooling_get_cur_state,
1535 .set_cur_state = etnaviv_gpu_cooling_set_cur_state,
1536};
1537
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001538static int etnaviv_gpu_bind(struct device *dev, struct device *master,
1539 void *data)
1540{
1541 struct drm_device *drm = data;
1542 struct etnaviv_drm_private *priv = drm->dev_private;
1543 struct etnaviv_gpu *gpu = dev_get_drvdata(dev);
1544 int ret;
1545
Philipp Zabel49b82c32017-12-01 16:00:41 +01001546 if (IS_ENABLED(CONFIG_DRM_ETNAVIV_THERMAL)) {
Lucas Stach5247e2a2017-08-08 15:28:25 +02001547 gpu->cooling = thermal_of_cooling_device_register(dev->of_node,
Russell Kingbcdfb5e2017-03-12 19:00:59 +00001548 (char *)dev_name(dev), gpu, &cooling_ops);
Lucas Stach5247e2a2017-08-08 15:28:25 +02001549 if (IS_ERR(gpu->cooling))
1550 return PTR_ERR(gpu->cooling);
1551 }
Russell Kingbcdfb5e2017-03-12 19:00:59 +00001552
Lucas Stacha7790d72017-11-17 17:43:37 +01001553 gpu->wq = alloc_ordered_workqueue(dev_name(dev), 0);
1554 if (!gpu->wq) {
Lucas Stache93b6de2017-12-04 18:41:58 +01001555 ret = -ENOMEM;
1556 goto out_thermal;
Lucas Stacha7790d72017-11-17 17:43:37 +01001557 }
1558
Lucas Stache93b6de2017-12-04 18:41:58 +01001559 ret = etnaviv_sched_init(gpu);
1560 if (ret)
1561 goto out_workqueue;
1562
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001563#ifdef CONFIG_PM
1564 ret = pm_runtime_get_sync(gpu->dev);
1565#else
1566 ret = etnaviv_gpu_clk_enable(gpu);
1567#endif
Lucas Stache93b6de2017-12-04 18:41:58 +01001568 if (ret < 0)
1569 goto out_sched;
1570
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001571
1572 gpu->drm = drm;
Chris Wilsonf54d1862016-10-25 13:00:45 +01001573 gpu->fence_context = dma_fence_context_alloc(1);
Lucas Stach8bc4d882017-11-29 14:49:04 +01001574 idr_init(&gpu->fence_idr);
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001575 spin_lock_init(&gpu->fence_spinlock);
1576
Christian Gmeiner357713c2017-09-24 15:15:28 +02001577 INIT_WORK(&gpu->sync_point_work, sync_point_worker);
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001578 init_waitqueue_head(&gpu->fence_event);
1579
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001580 priv->gpu[priv->num_gpus++] = gpu;
1581
1582 pm_runtime_mark_last_busy(gpu->dev);
1583 pm_runtime_put_autosuspend(gpu->dev);
1584
1585 return 0;
Lucas Stache93b6de2017-12-04 18:41:58 +01001586
1587out_sched:
1588 etnaviv_sched_fini(gpu);
1589
1590out_workqueue:
1591 destroy_workqueue(gpu->wq);
1592
1593out_thermal:
1594 if (IS_ENABLED(CONFIG_DRM_ETNAVIV_THERMAL))
1595 thermal_cooling_device_unregister(gpu->cooling);
1596
1597 return ret;
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001598}
1599
1600static void etnaviv_gpu_unbind(struct device *dev, struct device *master,
1601 void *data)
1602{
1603 struct etnaviv_gpu *gpu = dev_get_drvdata(dev);
1604
1605 DBG("%s", dev_name(gpu->dev));
1606
Lucas Stacha7790d72017-11-17 17:43:37 +01001607 flush_workqueue(gpu->wq);
1608 destroy_workqueue(gpu->wq);
1609
Lucas Stache93b6de2017-12-04 18:41:58 +01001610 etnaviv_sched_fini(gpu);
1611
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001612#ifdef CONFIG_PM
1613 pm_runtime_get_sync(gpu->dev);
1614 pm_runtime_put_sync_suspend(gpu->dev);
1615#else
1616 etnaviv_gpu_hw_suspend(gpu);
1617#endif
1618
Lucas Stach2f9225d2017-11-24 16:56:37 +01001619 if (gpu->buffer.suballoc)
1620 etnaviv_cmdbuf_free(&gpu->buffer);
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001621
Lucas Stache66774d2017-01-16 17:29:57 +01001622 if (gpu->cmdbuf_suballoc) {
1623 etnaviv_cmdbuf_suballoc_destroy(gpu->cmdbuf_suballoc);
1624 gpu->cmdbuf_suballoc = NULL;
1625 }
1626
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001627 if (gpu->mmu) {
1628 etnaviv_iommu_destroy(gpu->mmu);
1629 gpu->mmu = NULL;
1630 }
1631
1632 gpu->drm = NULL;
Lucas Stach8bc4d882017-11-29 14:49:04 +01001633 idr_destroy(&gpu->fence_idr);
Russell Kingbcdfb5e2017-03-12 19:00:59 +00001634
Philipp Zabel49b82c32017-12-01 16:00:41 +01001635 if (IS_ENABLED(CONFIG_DRM_ETNAVIV_THERMAL))
1636 thermal_cooling_device_unregister(gpu->cooling);
Russell Kingbcdfb5e2017-03-12 19:00:59 +00001637 gpu->cooling = NULL;
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001638}
1639
1640static const struct component_ops gpu_ops = {
1641 .bind = etnaviv_gpu_bind,
1642 .unbind = etnaviv_gpu_unbind,
1643};
1644
1645static const struct of_device_id etnaviv_gpu_match[] = {
1646 {
1647 .compatible = "vivante,gc"
1648 },
1649 { /* sentinel */ }
1650};
Lucas Stach246774d2018-01-24 15:30:29 +01001651MODULE_DEVICE_TABLE(of, etnaviv_gpu_match);
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001652
1653static int etnaviv_gpu_platform_probe(struct platform_device *pdev)
1654{
1655 struct device *dev = &pdev->dev;
1656 struct etnaviv_gpu *gpu;
Fabio Estevamdc227892016-08-21 19:32:15 -03001657 int err;
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001658
1659 gpu = devm_kzalloc(dev, sizeof(*gpu), GFP_KERNEL);
1660 if (!gpu)
1661 return -ENOMEM;
1662
1663 gpu->dev = &pdev->dev;
1664 mutex_init(&gpu->lock);
Lucas Stache93b6de2017-12-04 18:41:58 +01001665 mutex_init(&gpu->fence_idr_lock);
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001666
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001667 /* Map registers: */
1668 gpu->mmio = etnaviv_ioremap(pdev, NULL, dev_name(gpu->dev));
1669 if (IS_ERR(gpu->mmio))
1670 return PTR_ERR(gpu->mmio);
1671
1672 /* Get Interrupt: */
1673 gpu->irq = platform_get_irq(pdev, 0);
1674 if (gpu->irq < 0) {
Fabio Estevamdb60eda2016-08-21 19:32:14 -03001675 dev_err(dev, "failed to get irq: %d\n", gpu->irq);
1676 return gpu->irq;
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001677 }
1678
1679 err = devm_request_irq(&pdev->dev, gpu->irq, irq_handler, 0,
1680 dev_name(gpu->dev), gpu);
1681 if (err) {
1682 dev_err(dev, "failed to request IRQ%u: %d\n", gpu->irq, err);
Fabio Estevamdb60eda2016-08-21 19:32:14 -03001683 return err;
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001684 }
1685
1686 /* Get Clocks: */
Lucas Stach65f037e2018-01-19 15:05:40 +01001687 gpu->clk_reg = devm_clk_get(&pdev->dev, "reg");
1688 DBG("clk_reg: %p", gpu->clk_reg);
1689 if (IS_ERR(gpu->clk_reg))
1690 gpu->clk_reg = NULL;
1691
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001692 gpu->clk_bus = devm_clk_get(&pdev->dev, "bus");
1693 DBG("clk_bus: %p", gpu->clk_bus);
1694 if (IS_ERR(gpu->clk_bus))
1695 gpu->clk_bus = NULL;
1696
1697 gpu->clk_core = devm_clk_get(&pdev->dev, "core");
1698 DBG("clk_core: %p", gpu->clk_core);
1699 if (IS_ERR(gpu->clk_core))
1700 gpu->clk_core = NULL;
Lucas Stachd79fd1ccf22017-04-11 15:54:50 +02001701 gpu->base_rate_core = clk_get_rate(gpu->clk_core);
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001702
1703 gpu->clk_shader = devm_clk_get(&pdev->dev, "shader");
1704 DBG("clk_shader: %p", gpu->clk_shader);
1705 if (IS_ERR(gpu->clk_shader))
1706 gpu->clk_shader = NULL;
Lucas Stachd79fd1ccf22017-04-11 15:54:50 +02001707 gpu->base_rate_shader = clk_get_rate(gpu->clk_shader);
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001708
1709 /* TODO: figure out max mapped size */
1710 dev_set_drvdata(dev, gpu);
1711
1712 /*
1713 * We treat the device as initially suspended. The runtime PM
1714 * autosuspend delay is rather arbitary: no measurements have
1715 * yet been performed to determine an appropriate value.
1716 */
1717 pm_runtime_use_autosuspend(gpu->dev);
1718 pm_runtime_set_autosuspend_delay(gpu->dev, 200);
1719 pm_runtime_enable(gpu->dev);
1720
1721 err = component_add(&pdev->dev, &gpu_ops);
1722 if (err < 0) {
1723 dev_err(&pdev->dev, "failed to register component: %d\n", err);
Fabio Estevamdb60eda2016-08-21 19:32:14 -03001724 return err;
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001725 }
1726
1727 return 0;
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001728}
1729
1730static int etnaviv_gpu_platform_remove(struct platform_device *pdev)
1731{
1732 component_del(&pdev->dev, &gpu_ops);
1733 pm_runtime_disable(&pdev->dev);
1734 return 0;
1735}
1736
1737#ifdef CONFIG_PM
1738static int etnaviv_gpu_rpm_suspend(struct device *dev)
1739{
1740 struct etnaviv_gpu *gpu = dev_get_drvdata(dev);
1741 u32 idle, mask;
1742
1743 /* If we have outstanding fences, we're not idle */
1744 if (gpu->completed_fence != gpu->active_fence)
1745 return -EBUSY;
1746
1747 /* Check whether the hardware (except FE) is idle */
1748 mask = gpu->idle_mask & ~VIVS_HI_IDLE_STATE_FE;
1749 idle = gpu_read(gpu, VIVS_HI_IDLE_STATE) & mask;
1750 if (idle != mask)
1751 return -EBUSY;
1752
1753 return etnaviv_gpu_hw_suspend(gpu);
1754}
1755
1756static int etnaviv_gpu_rpm_resume(struct device *dev)
1757{
1758 struct etnaviv_gpu *gpu = dev_get_drvdata(dev);
1759 int ret;
1760
1761 ret = etnaviv_gpu_clk_enable(gpu);
1762 if (ret)
1763 return ret;
1764
1765 /* Re-initialise the basic hardware state */
Lucas Stach2f9225d2017-11-24 16:56:37 +01001766 if (gpu->drm && gpu->buffer.suballoc) {
The etnaviv authorsa8c21a52015-12-03 18:21:29 +01001767 ret = etnaviv_gpu_hw_resume(gpu);
1768 if (ret) {
1769 etnaviv_gpu_clk_disable(gpu);
1770 return ret;
1771 }
1772 }
1773
1774 return 0;
1775}
1776#endif
1777
1778static const struct dev_pm_ops etnaviv_gpu_pm_ops = {
1779 SET_RUNTIME_PM_OPS(etnaviv_gpu_rpm_suspend, etnaviv_gpu_rpm_resume,
1780 NULL)
1781};
1782
1783struct platform_driver etnaviv_gpu_driver = {
1784 .driver = {
1785 .name = "etnaviv-gpu",
1786 .owner = THIS_MODULE,
1787 .pm = &etnaviv_gpu_pm_ops,
1788 .of_match_table = etnaviv_gpu_match,
1789 },
1790 .probe = etnaviv_gpu_platform_probe,
1791 .remove = etnaviv_gpu_platform_remove,
1792 .id_table = gpu_ids,
1793};