.. | .. |
---|
1 | 1 | // SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note |
---|
2 | 2 | /* |
---|
3 | 3 | * |
---|
4 | | - * (C) COPYRIGHT 2019-2021 ARM Limited. All rights reserved. |
---|
| 4 | + * (C) COPYRIGHT 2019-2023 ARM Limited. All rights reserved. |
---|
5 | 5 | * |
---|
6 | 6 | * This program is free software and is provided to you under the terms of the |
---|
7 | 7 | * GNU General Public License version 2 as published by the Free Software |
---|
.. | .. |
---|
27 | 27 | #include <mali_kbase_hwaccess_backend.h> |
---|
28 | 28 | #include <mali_kbase_ctx_sched.h> |
---|
29 | 29 | #include <mali_kbase_reset_gpu.h> |
---|
30 | | - |
---|
| 30 | +#include <hwcnt/mali_kbase_hwcnt_watchdog_if_timer.h> |
---|
| 31 | +#include <hwcnt/backend/mali_kbase_hwcnt_backend_jm.h> |
---|
| 32 | +#include <hwcnt/backend/mali_kbase_hwcnt_backend_jm_watchdog.h> |
---|
| 33 | +#include <backend/gpu/mali_kbase_model_linux.h> |
---|
31 | 34 | |
---|
32 | 35 | #ifdef CONFIG_MALI_ARBITER_SUPPORT |
---|
33 | 36 | #include <arbiter/mali_kbase_arbiter_pm.h> |
---|
.. | .. |
---|
68 | 71 | goto fail_timer; |
---|
69 | 72 | |
---|
70 | 73 | #ifdef CONFIG_MALI_BIFROST_DEBUG |
---|
71 | | -#ifndef CONFIG_MALI_BIFROST_NO_MALI |
---|
| 74 | +#if IS_ENABLED(CONFIG_MALI_REAL_HW) |
---|
72 | 75 | if (kbasep_common_test_interrupt_handlers(kbdev) != 0) { |
---|
73 | 76 | dev_err(kbdev->dev, "Interrupt assignment check failed.\n"); |
---|
74 | 77 | err = -EINVAL; |
---|
75 | 78 | goto fail_interrupt_test; |
---|
76 | 79 | } |
---|
77 | | -#endif /* !CONFIG_MALI_BIFROST_NO_MALI */ |
---|
| 80 | +#endif /* IS_ENABLED(CONFIG_MALI_REAL_HW) */ |
---|
78 | 81 | #endif /* CONFIG_MALI_BIFROST_DEBUG */ |
---|
79 | 82 | |
---|
80 | 83 | err = kbase_job_slot_init(kbdev); |
---|
.. | .. |
---|
97 | 100 | if (err) |
---|
98 | 101 | goto fail_update_l2_features; |
---|
99 | 102 | |
---|
| 103 | + err = kbase_backend_time_init(kbdev); |
---|
| 104 | + if (err) |
---|
| 105 | + goto fail_update_l2_features; |
---|
| 106 | + |
---|
100 | 107 | init_waitqueue_head(&kbdev->hwaccess.backend.reset_wait); |
---|
101 | 108 | |
---|
102 | 109 | /* Idle the GPU and/or cores, if the policy wants it to */ |
---|
.. | .. |
---|
113 | 120 | fail_job_slot: |
---|
114 | 121 | |
---|
115 | 122 | #ifdef CONFIG_MALI_BIFROST_DEBUG |
---|
116 | | -#ifndef CONFIG_MALI_BIFROST_NO_MALI |
---|
| 123 | +#if IS_ENABLED(CONFIG_MALI_REAL_HW) |
---|
117 | 124 | fail_interrupt_test: |
---|
118 | | -#endif /* !CONFIG_MALI_BIFROST_NO_MALI */ |
---|
| 125 | +#endif /* IS_ENABLED(CONFIG_MALI_REAL_HW) */ |
---|
119 | 126 | #endif /* CONFIG_MALI_BIFROST_DEBUG */ |
---|
120 | 127 | |
---|
121 | 128 | kbase_backend_timer_term(kbdev); |
---|
.. | .. |
---|
145 | 152 | kbase_hwaccess_pm_term(kbdev); |
---|
146 | 153 | } |
---|
147 | 154 | |
---|
148 | | -static int kbase_device_hwcnt_backend_jm_init(struct kbase_device *kbdev) |
---|
| 155 | +/** |
---|
| 156 | + * kbase_device_hwcnt_watchdog_if_init - Create hardware counter watchdog |
---|
| 157 | + * interface. |
---|
| 158 | + * @kbdev: Device pointer |
---|
| 159 | + * Return: 0 on success, or an error code on failure. |
---|
| 160 | + */ |
---|
| 161 | +static int kbase_device_hwcnt_watchdog_if_init(struct kbase_device *kbdev) |
---|
149 | 162 | { |
---|
150 | | - return kbase_hwcnt_backend_jm_create(kbdev, &kbdev->hwcnt_gpu_iface); |
---|
| 163 | + return kbase_hwcnt_watchdog_if_timer_create(&kbdev->hwcnt_watchdog_timer); |
---|
151 | 164 | } |
---|
152 | 165 | |
---|
| 166 | +/** |
---|
| 167 | + * kbase_device_hwcnt_watchdog_if_term - Terminate hardware counter watchdog |
---|
| 168 | + * interface. |
---|
| 169 | + * @kbdev: Device pointer |
---|
| 170 | + */ |
---|
| 171 | +static void kbase_device_hwcnt_watchdog_if_term(struct kbase_device *kbdev) |
---|
| 172 | +{ |
---|
| 173 | + kbase_hwcnt_watchdog_if_timer_destroy(&kbdev->hwcnt_watchdog_timer); |
---|
| 174 | +} |
---|
| 175 | + |
---|
| 176 | +/** |
---|
| 177 | + * kbase_device_hwcnt_backend_jm_init - Create hardware counter backend. |
---|
| 178 | + * @kbdev: Device pointer |
---|
| 179 | + * Return: 0 on success, or an error code on failure. |
---|
| 180 | + */ |
---|
| 181 | +static int kbase_device_hwcnt_backend_jm_init(struct kbase_device *kbdev) |
---|
| 182 | +{ |
---|
| 183 | + return kbase_hwcnt_backend_jm_create(kbdev, &kbdev->hwcnt_gpu_jm_backend); |
---|
| 184 | +} |
---|
| 185 | + |
---|
| 186 | +/** |
---|
| 187 | + * kbase_device_hwcnt_backend_jm_term - Terminate hardware counter backend. |
---|
| 188 | + * @kbdev: Device pointer |
---|
| 189 | + */ |
---|
153 | 190 | static void kbase_device_hwcnt_backend_jm_term(struct kbase_device *kbdev) |
---|
154 | 191 | { |
---|
155 | | - kbase_hwcnt_backend_jm_destroy(&kbdev->hwcnt_gpu_iface); |
---|
| 192 | + kbase_hwcnt_backend_jm_destroy(&kbdev->hwcnt_gpu_jm_backend); |
---|
| 193 | +} |
---|
| 194 | + |
---|
| 195 | +/** |
---|
| 196 | + * kbase_device_hwcnt_backend_jm_watchdog_init - Create hardware counter watchdog backend. |
---|
| 197 | + * @kbdev: Device pointer |
---|
| 198 | + * Return: 0 on success, or an error code on failure. |
---|
| 199 | + */ |
---|
| 200 | +static int kbase_device_hwcnt_backend_jm_watchdog_init(struct kbase_device *kbdev) |
---|
| 201 | +{ |
---|
| 202 | + return kbase_hwcnt_backend_jm_watchdog_create(&kbdev->hwcnt_gpu_jm_backend, |
---|
| 203 | + &kbdev->hwcnt_watchdog_timer, |
---|
| 204 | + &kbdev->hwcnt_gpu_iface); |
---|
| 205 | +} |
---|
| 206 | + |
---|
| 207 | +/** |
---|
| 208 | + * kbase_device_hwcnt_backend_jm_watchdog_term - Terminate hardware counter watchdog backend. |
---|
| 209 | + * @kbdev: Device pointer |
---|
| 210 | + */ |
---|
| 211 | +static void kbase_device_hwcnt_backend_jm_watchdog_term(struct kbase_device *kbdev) |
---|
| 212 | +{ |
---|
| 213 | + kbase_hwcnt_backend_jm_watchdog_destroy(&kbdev->hwcnt_gpu_iface); |
---|
156 | 214 | } |
---|
157 | 215 | |
---|
158 | 216 | static const struct kbase_device_init dev_init[] = { |
---|
| 217 | +#if !IS_ENABLED(CONFIG_MALI_REAL_HW) |
---|
| 218 | + { kbase_gpu_device_create, kbase_gpu_device_destroy, "Dummy model initialization failed" }, |
---|
| 219 | +#else /* !IS_ENABLED(CONFIG_MALI_REAL_HW) */ |
---|
159 | 220 | { assign_irqs, NULL, "IRQ search failed" }, |
---|
| 221 | +#endif /* !IS_ENABLED(CONFIG_MALI_REAL_HW) */ |
---|
| 222 | +#if !IS_ENABLED(CONFIG_MALI_BIFROST_NO_MALI) |
---|
160 | 223 | { registers_map, registers_unmap, "Register map failed" }, |
---|
| 224 | +#endif /* !IS_ENABLED(CONFIG_MALI_BIFROST_NO_MALI) */ |
---|
161 | 225 | { kbase_device_io_history_init, kbase_device_io_history_term, |
---|
162 | 226 | "Register access history initialization failed" }, |
---|
163 | | - { kbase_device_pm_init, kbase_device_pm_term, |
---|
164 | | - "Power management initialization failed" }, |
---|
165 | | - { kbase_device_early_init, kbase_device_early_term, |
---|
166 | | - "Early device initialization failed" }, |
---|
167 | | - { kbase_device_populate_max_freq, NULL, |
---|
168 | | - "Populating max frequency failed" }, |
---|
| 227 | + { kbase_device_pm_init, kbase_device_pm_term, "Power management initialization failed" }, |
---|
| 228 | + { kbase_device_early_init, kbase_device_early_term, "Early device initialization failed" }, |
---|
| 229 | + { kbase_device_populate_max_freq, NULL, "Populating max frequency failed" }, |
---|
| 230 | + { kbase_pm_lowest_gpu_freq_init, NULL, "Lowest freq initialization failed" }, |
---|
169 | 231 | { kbase_device_misc_init, kbase_device_misc_term, |
---|
170 | 232 | "Miscellaneous device initialization failed" }, |
---|
171 | 233 | { kbase_device_pcm_dev_init, kbase_device_pcm_dev_term, |
---|
172 | 234 | "Priority control manager initialization failed" }, |
---|
173 | | - { kbase_ctx_sched_init, kbase_ctx_sched_term, |
---|
174 | | - "Context scheduler initialization failed" }, |
---|
175 | | - { kbase_mem_init, kbase_mem_term, |
---|
176 | | - "Memory subsystem initialization failed" }, |
---|
| 235 | + { kbase_ctx_sched_init, kbase_ctx_sched_term, "Context scheduler initialization failed" }, |
---|
| 236 | + { kbase_mem_init, kbase_mem_term, "Memory subsystem initialization failed" }, |
---|
177 | 237 | { kbase_device_coherency_init, NULL, "Device coherency init failed" }, |
---|
178 | 238 | { kbase_protected_mode_init, kbase_protected_mode_term, |
---|
179 | 239 | "Protected mode subsystem initialization failed" }, |
---|
180 | | - { kbase_device_list_init, kbase_device_list_term, |
---|
181 | | - "Device list setup failed" }, |
---|
182 | | - { kbasep_js_devdata_init, kbasep_js_devdata_term, |
---|
183 | | - "Job JS devdata initialization failed" }, |
---|
| 240 | + { kbase_device_list_init, kbase_device_list_term, "Device list setup failed" }, |
---|
| 241 | + { kbasep_js_devdata_init, kbasep_js_devdata_term, "Job JS devdata initialization failed" }, |
---|
184 | 242 | { kbase_device_timeline_init, kbase_device_timeline_term, |
---|
185 | 243 | "Timeline stream initialization failed" }, |
---|
186 | 244 | { kbase_clk_rate_trace_manager_init, kbase_clk_rate_trace_manager_term, |
---|
187 | 245 | "Clock rate trace manager initialization failed" }, |
---|
188 | 246 | { kbase_instr_backend_init, kbase_instr_backend_term, |
---|
189 | 247 | "Instrumentation backend initialization failed" }, |
---|
190 | | - { kbase_device_hwcnt_backend_jm_init, |
---|
191 | | - kbase_device_hwcnt_backend_jm_term, |
---|
| 248 | + { kbase_device_hwcnt_watchdog_if_init, kbase_device_hwcnt_watchdog_if_term, |
---|
| 249 | + "GPU hwcnt backend watchdog interface creation failed" }, |
---|
| 250 | + { kbase_device_hwcnt_backend_jm_init, kbase_device_hwcnt_backend_jm_term, |
---|
192 | 251 | "GPU hwcnt backend creation failed" }, |
---|
| 252 | + { kbase_device_hwcnt_backend_jm_watchdog_init, kbase_device_hwcnt_backend_jm_watchdog_term, |
---|
| 253 | + "GPU hwcnt watchdog backend creation failed" }, |
---|
193 | 254 | { kbase_device_hwcnt_context_init, kbase_device_hwcnt_context_term, |
---|
194 | 255 | "GPU hwcnt context initialization failed" }, |
---|
195 | | - { kbase_device_hwcnt_virtualizer_init, |
---|
196 | | - kbase_device_hwcnt_virtualizer_term, |
---|
| 256 | + { kbase_device_hwcnt_virtualizer_init, kbase_device_hwcnt_virtualizer_term, |
---|
197 | 257 | "GPU hwcnt virtualizer initialization failed" }, |
---|
198 | 258 | { kbase_device_vinstr_init, kbase_device_vinstr_term, |
---|
199 | 259 | "Virtual instrumentation initialization failed" }, |
---|
200 | | - { kbase_backend_late_init, kbase_backend_late_term, |
---|
201 | | - "Late backend initialization failed" }, |
---|
202 | | -#ifdef MALI_KBASE_BUILD |
---|
| 260 | + { kbase_device_kinstr_prfcnt_init, kbase_device_kinstr_prfcnt_term, |
---|
| 261 | + "Performance counter instrumentation initialization failed" }, |
---|
| 262 | + { kbase_backend_late_init, kbase_backend_late_term, "Late backend initialization failed" }, |
---|
203 | 263 | { kbase_debug_job_fault_dev_init, kbase_debug_job_fault_dev_term, |
---|
204 | 264 | "Job fault debug initialization failed" }, |
---|
205 | | - { kbase_device_debugfs_init, kbase_device_debugfs_term, |
---|
206 | | - "DebugFS initialization failed" }, |
---|
| 265 | + { kbase_device_debugfs_init, kbase_device_debugfs_term, "DebugFS initialization failed" }, |
---|
207 | 266 | /* Sysfs init needs to happen before registering the device with |
---|
208 | 267 | * misc_register(), otherwise it causes a race condition between |
---|
209 | 268 | * registering the device and a uevent event being generated for |
---|
.. | .. |
---|
221 | 280 | "Misc device registration failed" }, |
---|
222 | 281 | { kbase_gpuprops_populate_user_buffer, kbase_gpuprops_free_user_buffer, |
---|
223 | 282 | "GPU property population failed" }, |
---|
224 | | -#endif |
---|
225 | 283 | { NULL, kbase_dummy_job_wa_cleanup, NULL }, |
---|
226 | | - { kbase_device_late_init, kbase_device_late_term, |
---|
227 | | - "Late device initialization failed" }, |
---|
| 284 | + { kbase_device_late_init, kbase_device_late_term, "Late device initialization failed" }, |
---|
228 | 285 | }; |
---|
229 | 286 | |
---|
230 | 287 | static void kbase_device_term_partial(struct kbase_device *kbdev, |
---|