3 * (C) COPYRIGHT ARM Limited. All rights reserved.
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
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.
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"
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.
30 #define KBASE_VE_GPU_FREQ_KHZ_MAX 5000
31 #define KBASE_VE_GPU_FREQ_KHZ_MIN 5000
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 */
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 */
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)
63 #define HARD_RESET_AT_POWER_OFF 0
66 static kbase_io_resources io_resources = {
72 .end = 0xFC010000 + (4096 * 4) - 1}
76 static int pm_callback_power_on(kbase_device *kbdev)
78 /* Nothing is needed on VExpress, but we may have destroyed GPU state (if the below HARD_RESET code is active) */
82 static void pm_callback_power_off(kbase_device *kbdev)
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
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);
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
104 /* Please keep table config_attributes in sync with config_attributes_hw_issue_8408 */
105 static kbase_attribute config_attributes[] = {
107 KBASE_CONFIG_ATTR_GPU_FREQ_KHZ_MAX,
108 KBASE_VE_GPU_FREQ_KHZ_MAX},
111 KBASE_CONFIG_ATTR_GPU_FREQ_KHZ_MIN,
112 KBASE_VE_GPU_FREQ_KHZ_MIN},
114 #ifdef CONFIG_MALI_DEBUG
115 /* Use more aggressive scheduling timeouts in debug builds for testing purposes */
117 KBASE_CONFIG_ATTR_JS_SCHEDULING_TICK_NS,
118 KBASE_VE_JS_SCHEDULING_TICK_NS_DEBUG},
121 KBASE_CONFIG_ATTR_JS_SOFT_STOP_TICKS,
122 KBASE_VE_JS_SOFT_STOP_TICKS_DEBUG},
125 KBASE_CONFIG_ATTR_JS_SOFT_STOP_TICKS_CL,
126 KBASE_VE_JS_SOFT_STOP_TICKS_CL_DEBUG},
129 KBASE_CONFIG_ATTR_JS_HARD_STOP_TICKS_SS,
130 KBASE_VE_JS_HARD_STOP_TICKS_SS_DEBUG},
133 KBASE_CONFIG_ATTR_JS_HARD_STOP_TICKS_CL,
134 KBASE_VE_JS_HARD_STOP_TICKS_CL_DEBUG},
137 KBASE_CONFIG_ATTR_JS_HARD_STOP_TICKS_NSS,
138 KBASE_VE_JS_HARD_STOP_TICKS_NSS_DEBUG},
141 KBASE_CONFIG_ATTR_JS_RESET_TICKS_SS,
142 KBASE_VE_JS_RESET_TICKS_SS_DEBUG},
145 KBASE_CONFIG_ATTR_JS_RESET_TICKS_CL,
146 KBASE_VE_JS_RESET_TICKS_CL_DEBUG},
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 */
154 KBASE_CONFIG_ATTR_JS_SCHEDULING_TICK_NS,
155 KBASE_VE_JS_SCHEDULING_TICK_NS},
158 KBASE_CONFIG_ATTR_JS_SOFT_STOP_TICKS,
159 KBASE_VE_JS_SOFT_STOP_TICKS},
162 KBASE_CONFIG_ATTR_JS_SOFT_STOP_TICKS_CL,
163 KBASE_VE_JS_SOFT_STOP_TICKS_CL},
166 KBASE_CONFIG_ATTR_JS_HARD_STOP_TICKS_SS,
167 KBASE_VE_JS_HARD_STOP_TICKS_SS},
170 KBASE_CONFIG_ATTR_JS_HARD_STOP_TICKS_CL,
171 KBASE_VE_JS_HARD_STOP_TICKS_CL},
174 KBASE_CONFIG_ATTR_JS_HARD_STOP_TICKS_NSS,
175 KBASE_VE_JS_HARD_STOP_TICKS_NSS},
178 KBASE_CONFIG_ATTR_JS_RESET_TICKS_SS,
179 KBASE_VE_JS_RESET_TICKS_SS},
182 KBASE_CONFIG_ATTR_JS_RESET_TICKS_CL,
183 KBASE_VE_JS_RESET_TICKS_CL},
186 KBASE_CONFIG_ATTR_JS_RESET_TICKS_NSS,
187 KBASE_VE_JS_RESET_TICKS_NSS},
188 #endif /* CONFIG_MALI_DEBUG */
190 KBASE_CONFIG_ATTR_JS_RESET_TIMEOUT_MS,
191 KBASE_VE_JS_RESET_TIMEOUT_MS},
194 KBASE_CONFIG_ATTR_JS_CTX_TIMESLICE_NS,
195 KBASE_VE_JS_CTX_TIMESLICE_NS},
198 KBASE_CONFIG_ATTR_POWER_MANAGEMENT_CALLBACKS,
199 KBASE_VE_POWER_MANAGEMENT_CALLBACKS},
202 KBASE_CONFIG_ATTR_CPU_SPEED_FUNC,
203 KBASE_VE_CPU_SPEED_FUNC},
206 KBASE_CONFIG_ATTR_SECURE_BUT_LOSS_OF_PERFORMANCE,
207 KBASE_VE_SECURE_BUT_LOSS_OF_PERFORMANCE},
210 KBASE_CONFIG_ATTR_GPU_IRQ_THROTTLE_TIME_US,
214 KBASE_CONFIG_ATTR_END,
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.
222 kbase_attribute config_attributes_hw_issue_8408[] = {
224 KBASE_CONFIG_ATTR_GPU_FREQ_KHZ_MAX,
225 KBASE_VE_GPU_FREQ_KHZ_MAX},
228 KBASE_CONFIG_ATTR_GPU_FREQ_KHZ_MIN,
229 KBASE_VE_GPU_FREQ_KHZ_MIN},
231 #ifdef CONFIG_MALI_DEBUG
232 /* Use more aggressive scheduling timeouts in debug builds for testing purposes */
234 KBASE_CONFIG_ATTR_JS_SCHEDULING_TICK_NS,
235 KBASE_VE_JS_SCHEDULING_TICK_NS_DEBUG},
238 KBASE_CONFIG_ATTR_JS_SOFT_STOP_TICKS,
239 KBASE_VE_JS_SOFT_STOP_TICKS_DEBUG},
242 KBASE_CONFIG_ATTR_JS_HARD_STOP_TICKS_SS,
243 KBASE_VE_JS_HARD_STOP_TICKS_SS_8401_DEBUG},
246 KBASE_CONFIG_ATTR_JS_HARD_STOP_TICKS_NSS,
247 KBASE_VE_JS_HARD_STOP_TICKS_NSS_DEBUG},
250 KBASE_CONFIG_ATTR_JS_RESET_TICKS_SS,
251 KBASE_VE_JS_RESET_TICKS_SS_8401_DEBUG},
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 */
259 KBASE_CONFIG_ATTR_JS_SCHEDULING_TICK_NS,
260 KBASE_VE_JS_SCHEDULING_TICK_NS},
263 KBASE_CONFIG_ATTR_JS_SOFT_STOP_TICKS,
264 KBASE_VE_JS_SOFT_STOP_TICKS},
267 KBASE_CONFIG_ATTR_JS_HARD_STOP_TICKS_SS,
268 KBASE_VE_JS_HARD_STOP_TICKS_SS_8401},
271 KBASE_CONFIG_ATTR_JS_HARD_STOP_TICKS_NSS,
272 KBASE_VE_JS_HARD_STOP_TICKS_NSS},
275 KBASE_CONFIG_ATTR_JS_RESET_TICKS_SS,
276 KBASE_VE_JS_RESET_TICKS_SS_8401},
279 KBASE_CONFIG_ATTR_JS_RESET_TICKS_NSS,
280 KBASE_VE_JS_RESET_TICKS_NSS},
281 #endif /* CONFIG_MALI_DEBUG */
283 KBASE_CONFIG_ATTR_JS_RESET_TIMEOUT_MS,
284 KBASE_VE_JS_RESET_TIMEOUT_MS},
287 KBASE_CONFIG_ATTR_JS_CTX_TIMESLICE_NS,
288 KBASE_VE_JS_CTX_TIMESLICE_NS},
291 KBASE_CONFIG_ATTR_POWER_MANAGEMENT_CALLBACKS,
292 KBASE_VE_POWER_MANAGEMENT_CALLBACKS},
295 KBASE_CONFIG_ATTR_CPU_SPEED_FUNC,
296 KBASE_VE_CPU_SPEED_FUNC},
299 KBASE_CONFIG_ATTR_SECURE_BUT_LOSS_OF_PERFORMANCE,
300 KBASE_VE_SECURE_BUT_LOSS_OF_PERFORMANCE},
303 KBASE_CONFIG_ATTR_END,
307 static kbase_platform_config versatile_platform_config = {
308 .attributes = config_attributes,
310 .io_resources = &io_resources
314 kbase_platform_config *kbase_get_platform_config(void)
316 return &versatile_platform_config;
319 int kbase_platform_early_init(void)
321 /* Nothing needed at this stage */