hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/gpu/arm/bifrost/device/backend/mali_kbase_device_jm.c
....@@ -1,7 +1,7 @@
11 // SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note
22 /*
33 *
4
- * (C) COPYRIGHT 2019-2021 ARM Limited. All rights reserved.
4
+ * (C) COPYRIGHT 2019-2023 ARM Limited. All rights reserved.
55 *
66 * This program is free software and is provided to you under the terms of the
77 * GNU General Public License version 2 as published by the Free Software
....@@ -27,7 +27,10 @@
2727 #include <mali_kbase_hwaccess_backend.h>
2828 #include <mali_kbase_ctx_sched.h>
2929 #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>
3134
3235 #ifdef CONFIG_MALI_ARBITER_SUPPORT
3336 #include <arbiter/mali_kbase_arbiter_pm.h>
....@@ -68,13 +71,13 @@
6871 goto fail_timer;
6972
7073 #ifdef CONFIG_MALI_BIFROST_DEBUG
71
-#ifndef CONFIG_MALI_BIFROST_NO_MALI
74
+#if IS_ENABLED(CONFIG_MALI_REAL_HW)
7275 if (kbasep_common_test_interrupt_handlers(kbdev) != 0) {
7376 dev_err(kbdev->dev, "Interrupt assignment check failed.\n");
7477 err = -EINVAL;
7578 goto fail_interrupt_test;
7679 }
77
-#endif /* !CONFIG_MALI_BIFROST_NO_MALI */
80
+#endif /* IS_ENABLED(CONFIG_MALI_REAL_HW) */
7881 #endif /* CONFIG_MALI_BIFROST_DEBUG */
7982
8083 err = kbase_job_slot_init(kbdev);
....@@ -97,6 +100,10 @@
97100 if (err)
98101 goto fail_update_l2_features;
99102
103
+ err = kbase_backend_time_init(kbdev);
104
+ if (err)
105
+ goto fail_update_l2_features;
106
+
100107 init_waitqueue_head(&kbdev->hwaccess.backend.reset_wait);
101108
102109 /* Idle the GPU and/or cores, if the policy wants it to */
....@@ -113,9 +120,9 @@
113120 fail_job_slot:
114121
115122 #ifdef CONFIG_MALI_BIFROST_DEBUG
116
-#ifndef CONFIG_MALI_BIFROST_NO_MALI
123
+#if IS_ENABLED(CONFIG_MALI_REAL_HW)
117124 fail_interrupt_test:
118
-#endif /* !CONFIG_MALI_BIFROST_NO_MALI */
125
+#endif /* IS_ENABLED(CONFIG_MALI_REAL_HW) */
119126 #endif /* CONFIG_MALI_BIFROST_DEBUG */
120127
121128 kbase_backend_timer_term(kbdev);
....@@ -145,65 +152,117 @@
145152 kbase_hwaccess_pm_term(kbdev);
146153 }
147154
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)
149162 {
150
- return kbase_hwcnt_backend_jm_create(kbdev, &kbdev->hwcnt_gpu_iface);
163
+ return kbase_hwcnt_watchdog_if_timer_create(&kbdev->hwcnt_watchdog_timer);
151164 }
152165
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
+ */
153190 static void kbase_device_hwcnt_backend_jm_term(struct kbase_device *kbdev)
154191 {
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);
156214 }
157215
158216 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) */
159220 { assign_irqs, NULL, "IRQ search failed" },
221
+#endif /* !IS_ENABLED(CONFIG_MALI_REAL_HW) */
222
+#if !IS_ENABLED(CONFIG_MALI_BIFROST_NO_MALI)
160223 { registers_map, registers_unmap, "Register map failed" },
224
+#endif /* !IS_ENABLED(CONFIG_MALI_BIFROST_NO_MALI) */
161225 { kbase_device_io_history_init, kbase_device_io_history_term,
162226 "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" },
169231 { kbase_device_misc_init, kbase_device_misc_term,
170232 "Miscellaneous device initialization failed" },
171233 { kbase_device_pcm_dev_init, kbase_device_pcm_dev_term,
172234 "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" },
177237 { kbase_device_coherency_init, NULL, "Device coherency init failed" },
178238 { kbase_protected_mode_init, kbase_protected_mode_term,
179239 "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" },
184242 { kbase_device_timeline_init, kbase_device_timeline_term,
185243 "Timeline stream initialization failed" },
186244 { kbase_clk_rate_trace_manager_init, kbase_clk_rate_trace_manager_term,
187245 "Clock rate trace manager initialization failed" },
188246 { kbase_instr_backend_init, kbase_instr_backend_term,
189247 "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,
192251 "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" },
193254 { kbase_device_hwcnt_context_init, kbase_device_hwcnt_context_term,
194255 "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,
197257 "GPU hwcnt virtualizer initialization failed" },
198258 { kbase_device_vinstr_init, kbase_device_vinstr_term,
199259 "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" },
203263 { kbase_debug_job_fault_dev_init, kbase_debug_job_fault_dev_term,
204264 "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" },
207266 /* Sysfs init needs to happen before registering the device with
208267 * misc_register(), otherwise it causes a race condition between
209268 * registering the device and a uevent event being generated for
....@@ -221,10 +280,8 @@
221280 "Misc device registration failed" },
222281 { kbase_gpuprops_populate_user_buffer, kbase_gpuprops_free_user_buffer,
223282 "GPU property population failed" },
224
-#endif
225283 { 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" },
228285 };
229286
230287 static void kbase_device_term_partial(struct kbase_device *kbdev,