rk3288 gpu : update GPU driver r4p0_eac version
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / arm / midgard / platform / vexpress / mali_kbase_config_vexpress.c
1 /*
2  *
3  * (C) COPYRIGHT ARM Limited. All rights reserved.
4  *
5  * This program is free software and is provided to you under the terms of the
6  * GNU General Public License version 2 as published by the Free Software
7  * Foundation, and any use by you of this program is subject to the terms
8  * of such GNU licence.
9  *
10  * A copy of the licence is included with the program, and can also be obtained
11  * from Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
12  * Boston, MA  02110-1301, USA.
13  *
14  */
15
16
17
18
19
20 #include <linux/ioport.h>
21 #include <mali_kbase.h>
22 #include <mali_kbase_defs.h>
23 #include <mali_kbase_config.h>
24 #include "mali_kbase_cpu_vexpress.h"
25
26 /* Versatile Express (VE) configuration defaults shared between config_attributes[]
27  * and config_attributes_hw_issue_8408[]. Settings are not shared for
28  * JS_HARD_STOP_TICKS_SS and JS_RESET_TICKS_SS.
29  */
30 #define KBASE_VE_GPU_FREQ_KHZ_MAX               5000
31 #define KBASE_VE_GPU_FREQ_KHZ_MIN               5000
32
33 #define KBASE_VE_JS_SCHEDULING_TICK_NS_DEBUG    15000000u      /* 15ms, an agressive tick for testing purposes. This will reduce performance significantly */
34 #define KBASE_VE_JS_SOFT_STOP_TICKS_DEBUG       1       /* between 15ms and 30ms before soft-stop a job */
35 #define KBASE_VE_JS_SOFT_STOP_TICKS_CL_DEBUG    1       /* between 15ms and 30ms before soft-stop a CL job */
36 #define KBASE_VE_JS_HARD_STOP_TICKS_SS_DEBUG    333     /* 5s before hard-stop */
37 #define KBASE_VE_JS_HARD_STOP_TICKS_SS_8401_DEBUG 2000  /* 30s before hard-stop, for a certain GLES2 test at 128x128 (bound by combined vertex+tiler job) - for issue 8401 */
38 #define KBASE_VE_JS_HARD_STOP_TICKS_CL_DEBUG    166     /* 2.5s before hard-stop */
39 #define KBASE_VE_JS_HARD_STOP_TICKS_NSS_DEBUG   100000  /* 1500s (25mins) before NSS hard-stop */
40 #define KBASE_VE_JS_RESET_TICKS_SS_DEBUG        500     /* 45s before resetting GPU, for a certain GLES2 test at 128x128 (bound by combined vertex+tiler job) */
41 #define KBASE_VE_JS_RESET_TICKS_SS_8401_DEBUG   3000    /* 7.5s before resetting GPU - for issue 8401 */
42 #define KBASE_VE_JS_RESET_TICKS_CL_DEBUG        500     /* 45s before resetting GPU */
43 #define KBASE_VE_JS_RESET_TICKS_NSS_DEBUG       100166  /* 1502s before resetting GPU */
44
45 #define KBASE_VE_JS_SCHEDULING_TICK_NS          1250000000u     /* 1.25s */
46 #define KBASE_VE_JS_SOFT_STOP_TICKS             2       /* 2.5s before soft-stop a job */
47 #define KBASE_VE_JS_SOFT_STOP_TICKS_CL          1       /* 1.25s before soft-stop a CL job */
48 #define KBASE_VE_JS_HARD_STOP_TICKS_SS          4       /* 5s before hard-stop */
49 #define KBASE_VE_JS_HARD_STOP_TICKS_SS_8401     24      /* 30s before hard-stop, for a certain GLES2 test at 128x128 (bound by combined vertex+tiler job) - for issue 8401 */
50 #define KBASE_VE_JS_HARD_STOP_TICKS_CL          2       /* 2.5s before hard-stop */
51 #define KBASE_VE_JS_HARD_STOP_TICKS_NSS         1200    /* 1500s before NSS hard-stop */
52 #define KBASE_VE_JS_RESET_TICKS_SS              6       /* 7.5s before resetting GPU */
53 #define KBASE_VE_JS_RESET_TICKS_SS_8401         36      /* 45s before resetting GPU, for a certain GLES2 test at 128x128 (bound by combined vertex+tiler job) - for issue 8401 */
54 #define KBASE_VE_JS_RESET_TICKS_CL              3       /* 7.5s before resetting GPU */
55 #define KBASE_VE_JS_RESET_TICKS_NSS             1201    /* 1502s before resetting GPU */
56
57 #define KBASE_VE_JS_RESET_TIMEOUT_MS            3000    /* 3s before cancelling stuck jobs */
58 #define KBASE_VE_JS_CTX_TIMESLICE_NS            1000000 /* 1ms - an agressive timeslice for testing purposes (causes lots of scheduling out for >4 ctxs) */
59 #define KBASE_VE_SECURE_BUT_LOSS_OF_PERFORMANCE ((uintptr_t)MALI_FALSE) /* By default we prefer performance over security on r0p0-15dev0 and KBASE_CONFIG_ATTR_ earlier */
60 #define KBASE_VE_POWER_MANAGEMENT_CALLBACKS     ((uintptr_t)&pm_callbacks)
61 #define KBASE_VE_CPU_SPEED_FUNC                 ((uintptr_t)&kbase_get_vexpress_cpu_clock_speed)
62
63 #define HARD_RESET_AT_POWER_OFF 0
64
65 #ifndef CONFIG_OF
66 static kbase_io_resources io_resources = {
67         .job_irq_number = 68,
68         .mmu_irq_number = 69,
69         .gpu_irq_number = 70,
70         .io_memory_region = {
71                              .start = 0xFC010000,
72                              .end = 0xFC010000 + (4096 * 4) - 1}
73 };
74 #endif
75
76 static int pm_callback_power_on(kbase_device *kbdev)
77 {
78         /* Nothing is needed on VExpress, but we may have destroyed GPU state (if the below HARD_RESET code is active) */
79         return 1;
80 }
81
82 static void pm_callback_power_off(kbase_device *kbdev)
83 {
84 #if HARD_RESET_AT_POWER_OFF
85         /* Cause a GPU hard reset to test whether we have actually idled the GPU
86          * and that we properly reconfigure the GPU on power up.
87          * Usually this would be dangerous, but if the GPU is working correctly it should
88          * be completely safe as the GPU should not be active at this point.
89          * However this is disabled normally because it will most likely interfere with
90          * bus logging etc.
91          */
92         KBASE_TRACE_ADD(kbdev, CORE_GPU_HARD_RESET, NULL, NULL, 0u, 0);
93         kbase_os_reg_write(kbdev, GPU_CONTROL_REG(GPU_COMMAND), GPU_COMMAND_HARD_RESET);
94 #endif
95 }
96
97 static kbase_pm_callback_conf pm_callbacks = {
98         .power_on_callback = pm_callback_power_on,
99         .power_off_callback = pm_callback_power_off,
100         .power_suspend_callback  = NULL,
101         .power_resume_callback = NULL
102 };
103
104 /* Please keep table config_attributes in sync with config_attributes_hw_issue_8408 */
105 static kbase_attribute config_attributes[] = {
106         {
107          KBASE_CONFIG_ATTR_GPU_FREQ_KHZ_MAX,
108          KBASE_VE_GPU_FREQ_KHZ_MAX},
109
110         {
111          KBASE_CONFIG_ATTR_GPU_FREQ_KHZ_MIN,
112          KBASE_VE_GPU_FREQ_KHZ_MIN},
113
114 #ifdef CONFIG_MALI_DEBUG
115 /* Use more aggressive scheduling timeouts in debug builds for testing purposes */
116         {
117          KBASE_CONFIG_ATTR_JS_SCHEDULING_TICK_NS,
118          KBASE_VE_JS_SCHEDULING_TICK_NS_DEBUG},
119
120         {
121          KBASE_CONFIG_ATTR_JS_SOFT_STOP_TICKS,
122          KBASE_VE_JS_SOFT_STOP_TICKS_DEBUG},
123
124         {
125          KBASE_CONFIG_ATTR_JS_SOFT_STOP_TICKS_CL,
126          KBASE_VE_JS_SOFT_STOP_TICKS_CL_DEBUG},
127
128         {
129          KBASE_CONFIG_ATTR_JS_HARD_STOP_TICKS_SS,
130          KBASE_VE_JS_HARD_STOP_TICKS_SS_DEBUG},
131
132         {
133          KBASE_CONFIG_ATTR_JS_HARD_STOP_TICKS_CL,
134          KBASE_VE_JS_HARD_STOP_TICKS_CL_DEBUG},
135
136         {
137          KBASE_CONFIG_ATTR_JS_HARD_STOP_TICKS_NSS,
138          KBASE_VE_JS_HARD_STOP_TICKS_NSS_DEBUG},
139
140         {
141          KBASE_CONFIG_ATTR_JS_RESET_TICKS_SS,
142          KBASE_VE_JS_RESET_TICKS_SS_DEBUG},
143
144         {
145          KBASE_CONFIG_ATTR_JS_RESET_TICKS_CL,
146          KBASE_VE_JS_RESET_TICKS_CL_DEBUG},
147
148         {
149          KBASE_CONFIG_ATTR_JS_RESET_TICKS_NSS,
150          KBASE_VE_JS_RESET_TICKS_NSS_DEBUG},
151 #else                           /* CONFIG_MALI_DEBUG */
152 /* In release builds same as the defaults but scaled for 5MHz FPGA */
153         {
154          KBASE_CONFIG_ATTR_JS_SCHEDULING_TICK_NS,
155          KBASE_VE_JS_SCHEDULING_TICK_NS},
156
157         {
158          KBASE_CONFIG_ATTR_JS_SOFT_STOP_TICKS,
159          KBASE_VE_JS_SOFT_STOP_TICKS},
160
161         {
162          KBASE_CONFIG_ATTR_JS_SOFT_STOP_TICKS_CL,
163          KBASE_VE_JS_SOFT_STOP_TICKS_CL},
164
165         {
166          KBASE_CONFIG_ATTR_JS_HARD_STOP_TICKS_SS,
167          KBASE_VE_JS_HARD_STOP_TICKS_SS},
168
169         {
170          KBASE_CONFIG_ATTR_JS_HARD_STOP_TICKS_CL,
171          KBASE_VE_JS_HARD_STOP_TICKS_CL},
172
173         {
174          KBASE_CONFIG_ATTR_JS_HARD_STOP_TICKS_NSS,
175          KBASE_VE_JS_HARD_STOP_TICKS_NSS},
176
177         {
178          KBASE_CONFIG_ATTR_JS_RESET_TICKS_SS,
179          KBASE_VE_JS_RESET_TICKS_SS},
180
181         {
182          KBASE_CONFIG_ATTR_JS_RESET_TICKS_CL,
183          KBASE_VE_JS_RESET_TICKS_CL},
184
185         {
186          KBASE_CONFIG_ATTR_JS_RESET_TICKS_NSS,
187          KBASE_VE_JS_RESET_TICKS_NSS},
188 #endif                          /* CONFIG_MALI_DEBUG */
189         {
190          KBASE_CONFIG_ATTR_JS_RESET_TIMEOUT_MS,
191          KBASE_VE_JS_RESET_TIMEOUT_MS},
192
193         {
194          KBASE_CONFIG_ATTR_JS_CTX_TIMESLICE_NS,
195          KBASE_VE_JS_CTX_TIMESLICE_NS},
196
197         {
198          KBASE_CONFIG_ATTR_POWER_MANAGEMENT_CALLBACKS,
199          KBASE_VE_POWER_MANAGEMENT_CALLBACKS},
200
201         {
202          KBASE_CONFIG_ATTR_CPU_SPEED_FUNC,
203          KBASE_VE_CPU_SPEED_FUNC},
204
205         {
206          KBASE_CONFIG_ATTR_SECURE_BUT_LOSS_OF_PERFORMANCE,
207          KBASE_VE_SECURE_BUT_LOSS_OF_PERFORMANCE},
208
209         {
210          KBASE_CONFIG_ATTR_GPU_IRQ_THROTTLE_TIME_US,
211          20},
212
213         {
214          KBASE_CONFIG_ATTR_END,
215          0}
216 };
217
218 /* as config_attributes array above except with different settings for
219  * JS_HARD_STOP_TICKS_SS, JS_RESET_TICKS_SS that
220  * are needed for BASE_HW_ISSUE_8408.
221  */
222 kbase_attribute config_attributes_hw_issue_8408[] = {
223         {
224          KBASE_CONFIG_ATTR_GPU_FREQ_KHZ_MAX,
225          KBASE_VE_GPU_FREQ_KHZ_MAX},
226
227         {
228          KBASE_CONFIG_ATTR_GPU_FREQ_KHZ_MIN,
229          KBASE_VE_GPU_FREQ_KHZ_MIN},
230
231 #ifdef CONFIG_MALI_DEBUG
232 /* Use more aggressive scheduling timeouts in debug builds for testing purposes */
233         {
234          KBASE_CONFIG_ATTR_JS_SCHEDULING_TICK_NS,
235          KBASE_VE_JS_SCHEDULING_TICK_NS_DEBUG},
236
237         {
238          KBASE_CONFIG_ATTR_JS_SOFT_STOP_TICKS,
239          KBASE_VE_JS_SOFT_STOP_TICKS_DEBUG},
240
241         {
242          KBASE_CONFIG_ATTR_JS_HARD_STOP_TICKS_SS,
243          KBASE_VE_JS_HARD_STOP_TICKS_SS_8401_DEBUG},
244
245         {
246          KBASE_CONFIG_ATTR_JS_HARD_STOP_TICKS_NSS,
247          KBASE_VE_JS_HARD_STOP_TICKS_NSS_DEBUG},
248
249         {
250          KBASE_CONFIG_ATTR_JS_RESET_TICKS_SS,
251          KBASE_VE_JS_RESET_TICKS_SS_8401_DEBUG},
252
253         {
254          KBASE_CONFIG_ATTR_JS_RESET_TICKS_NSS,
255          KBASE_VE_JS_RESET_TICKS_NSS_DEBUG},
256 #else                           /* CONFIG_MALI_DEBUG */
257 /* In release builds same as the defaults but scaled for 5MHz FPGA */
258         {
259          KBASE_CONFIG_ATTR_JS_SCHEDULING_TICK_NS,
260          KBASE_VE_JS_SCHEDULING_TICK_NS},
261
262         {
263          KBASE_CONFIG_ATTR_JS_SOFT_STOP_TICKS,
264          KBASE_VE_JS_SOFT_STOP_TICKS},
265
266         {
267          KBASE_CONFIG_ATTR_JS_HARD_STOP_TICKS_SS,
268          KBASE_VE_JS_HARD_STOP_TICKS_SS_8401},
269
270         {
271          KBASE_CONFIG_ATTR_JS_HARD_STOP_TICKS_NSS,
272          KBASE_VE_JS_HARD_STOP_TICKS_NSS},
273
274         {
275          KBASE_CONFIG_ATTR_JS_RESET_TICKS_SS,
276          KBASE_VE_JS_RESET_TICKS_SS_8401},
277
278         {
279          KBASE_CONFIG_ATTR_JS_RESET_TICKS_NSS,
280          KBASE_VE_JS_RESET_TICKS_NSS},
281 #endif                          /* CONFIG_MALI_DEBUG */
282         {
283          KBASE_CONFIG_ATTR_JS_RESET_TIMEOUT_MS,
284          KBASE_VE_JS_RESET_TIMEOUT_MS},
285
286         {
287          KBASE_CONFIG_ATTR_JS_CTX_TIMESLICE_NS,
288          KBASE_VE_JS_CTX_TIMESLICE_NS},
289
290         {
291          KBASE_CONFIG_ATTR_POWER_MANAGEMENT_CALLBACKS,
292          KBASE_VE_POWER_MANAGEMENT_CALLBACKS},
293
294         {
295          KBASE_CONFIG_ATTR_CPU_SPEED_FUNC,
296          KBASE_VE_CPU_SPEED_FUNC},
297
298         {
299          KBASE_CONFIG_ATTR_SECURE_BUT_LOSS_OF_PERFORMANCE,
300          KBASE_VE_SECURE_BUT_LOSS_OF_PERFORMANCE},
301
302         {
303          KBASE_CONFIG_ATTR_END,
304          0}
305 };
306
307 static kbase_platform_config versatile_platform_config = {
308         .attributes = config_attributes,
309 #ifndef CONFIG_OF
310         .io_resources = &io_resources
311 #endif
312 };
313
314 kbase_platform_config *kbase_get_platform_config(void)
315 {
316         return &versatile_platform_config;
317 }
318
319 int kbase_platform_early_init(void)
320 {
321         /* Nothing needed at this stage */
322         return 0;
323 }