hc
2024-05-16 8d2a02b24d66aa359e83eebc1ed3c0f85367a1cb
kernel/drivers/gpu/arm/bifrost/mali_kbase_pm.c
....@@ -1,7 +1,7 @@
11 // SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note
22 /*
33 *
4
- * (C) COPYRIGHT 2010-2021 ARM Limited. All rights reserved.
4
+ * (C) COPYRIGHT 2010-2022 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
....@@ -26,7 +26,8 @@
2626 #include <mali_kbase.h>
2727 #include <gpu/mali_kbase_gpu_regmap.h>
2828 #include <mali_kbase_vinstr.h>
29
-#include <mali_kbase_hwcnt_context.h>
29
+#include <mali_kbase_kinstr_prfcnt.h>
30
+#include <hwcnt/mali_kbase_hwcnt_context.h>
3031
3132 #include <mali_kbase_pm.h>
3233 #include <backend/gpu/mali_kbase_pm_internal.h>
....@@ -76,13 +77,13 @@
7677 case KBASE_PM_SUSPEND_HANDLER_DONT_REACTIVATE:
7778 if (kbdev->pm.active_count != 0)
7879 break;
79
- /* FALLTHROUGH */
80
+ fallthrough;
8081 case KBASE_PM_SUSPEND_HANDLER_DONT_INCREASE:
8182 kbase_pm_unlock(kbdev);
8283 return 1;
8384
8485 case KBASE_PM_SUSPEND_HANDLER_NOT_POSSIBLE:
85
- /* FALLTHROUGH */
86
+ fallthrough;
8687 default:
8788 KBASE_DEBUG_ASSERT_MSG(false, "unreachable");
8889 break;
....@@ -143,14 +144,15 @@
143144
144145 KBASE_EXPORT_TEST_API(kbase_pm_context_idle);
145146
146
-void kbase_pm_driver_suspend(struct kbase_device *kbdev)
147
+int kbase_pm_driver_suspend(struct kbase_device *kbdev)
147148 {
148149 KBASE_DEBUG_ASSERT(kbdev);
149150
150
- /* Suspend vinstr. This blocks until the vinstr worker and timer are
151
- * no longer running.
151
+ /* Suspend HW counter intermediaries. This blocks until workers and timers
152
+ * are no longer running.
152153 */
153154 kbase_vinstr_suspend(kbdev->vinstr_ctx);
155
+ kbase_kinstr_prfcnt_suspend(kbdev->kinstr_prfcnt_ctx);
154156
155157 /* Disable GPU hardware counters.
156158 * This call will block until counters are disabled.
....@@ -160,7 +162,7 @@
160162 mutex_lock(&kbdev->pm.lock);
161163 if (WARN_ON(kbase_pm_is_suspending(kbdev))) {
162164 mutex_unlock(&kbdev->pm.lock);
163
- return;
165
+ return 0;
164166 }
165167 kbdev->pm.suspending = true;
166168 mutex_unlock(&kbdev->pm.lock);
....@@ -191,7 +193,12 @@
191193 */
192194 kbasep_js_suspend(kbdev);
193195 #else
194
- kbase_csf_scheduler_pm_suspend(kbdev);
196
+ if (kbase_csf_scheduler_pm_suspend(kbdev)) {
197
+ mutex_lock(&kbdev->pm.lock);
198
+ kbdev->pm.suspending = false;
199
+ mutex_unlock(&kbdev->pm.lock);
200
+ return -1;
201
+ }
195202 #endif
196203
197204 /* Wait for the active count to reach zero. This is not the same as
....@@ -207,7 +214,12 @@
207214 /* NOTE: We synchronize with anything that was just finishing a
208215 * kbase_pm_context_idle() call by locking the pm.lock below
209216 */
210
- kbase_hwaccess_pm_suspend(kbdev);
217
+ if (kbase_hwaccess_pm_suspend(kbdev)) {
218
+ mutex_lock(&kbdev->pm.lock);
219
+ kbdev->pm.suspending = false;
220
+ mutex_unlock(&kbdev->pm.lock);
221
+ return -1;
222
+ }
211223
212224 #ifdef CONFIG_MALI_ARBITER_SUPPORT
213225 if (kbdev->arb.arb_if) {
....@@ -216,6 +228,8 @@
216228 mutex_unlock(&kbdev->pm.arb_vm_state->vm_state_lock);
217229 }
218230 #endif /* CONFIG_MALI_ARBITER_SUPPORT */
231
+
232
+ return 0;
219233 }
220234
221235 void kbase_pm_driver_resume(struct kbase_device *kbdev, bool arb_gpu_start)
....@@ -246,8 +260,6 @@
246260 * atoms
247261 */
248262 kbasep_js_resume(kbdev);
249
-#else
250
- kbase_csf_scheduler_pm_resume(kbdev);
251263 #endif
252264
253265 /* Matching idle call, to power off the GPU/cores if we didn't actually
....@@ -266,20 +278,24 @@
266278 spin_unlock_irqrestore(&kbdev->hwaccess_lock, flags);
267279 #endif
268280
269
- /* Resume vinstr */
281
+ /* Resume HW counters intermediaries. */
270282 kbase_vinstr_resume(kbdev->vinstr_ctx);
283
+ kbase_kinstr_prfcnt_resume(kbdev->kinstr_prfcnt_ctx);
271284 }
272285
273
-void kbase_pm_suspend(struct kbase_device *kbdev)
286
+int kbase_pm_suspend(struct kbase_device *kbdev)
274287 {
288
+ int result = 0;
275289 #ifdef CONFIG_MALI_ARBITER_SUPPORT
276290 if (kbdev->arb.arb_if)
277291 kbase_arbiter_pm_vm_event(kbdev, KBASE_VM_OS_SUSPEND_EVENT);
278292 else
279
- kbase_pm_driver_suspend(kbdev);
293
+ result = kbase_pm_driver_suspend(kbdev);
280294 #else
281
- kbase_pm_driver_suspend(kbdev);
295
+ result = kbase_pm_driver_suspend(kbdev);
282296 #endif /* CONFIG_MALI_ARBITER_SUPPORT */
297
+
298
+ return result;
283299 }
284300
285301 void kbase_pm_resume(struct kbase_device *kbdev)