From 08f87f769b595151be1afeff53e144f543faa614 Mon Sep 17 00:00:00 2001
From: hc <hc@nodka.com>
Date: Wed, 06 Dec 2023 09:51:13 +0000
Subject: [PATCH] add dts config

---
 kernel/drivers/gpu/arm/bifrost/mali_kbase_pm.c |   48 ++++++++++++++++++++++++++++++++----------------
 1 files changed, 32 insertions(+), 16 deletions(-)

diff --git a/kernel/drivers/gpu/arm/bifrost/mali_kbase_pm.c b/kernel/drivers/gpu/arm/bifrost/mali_kbase_pm.c
index de100dd..62a1328 100644
--- a/kernel/drivers/gpu/arm/bifrost/mali_kbase_pm.c
+++ b/kernel/drivers/gpu/arm/bifrost/mali_kbase_pm.c
@@ -1,7 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note
 /*
  *
- * (C) COPYRIGHT 2010-2021 ARM Limited. All rights reserved.
+ * (C) COPYRIGHT 2010-2022 ARM Limited. All rights reserved.
  *
  * This program is free software and is provided to you under the terms of the
  * GNU General Public License version 2 as published by the Free Software
@@ -26,7 +26,8 @@
 #include <mali_kbase.h>
 #include <gpu/mali_kbase_gpu_regmap.h>
 #include <mali_kbase_vinstr.h>
-#include <mali_kbase_hwcnt_context.h>
+#include <mali_kbase_kinstr_prfcnt.h>
+#include <hwcnt/mali_kbase_hwcnt_context.h>
 
 #include <mali_kbase_pm.h>
 #include <backend/gpu/mali_kbase_pm_internal.h>
@@ -76,13 +77,13 @@
 		case KBASE_PM_SUSPEND_HANDLER_DONT_REACTIVATE:
 			if (kbdev->pm.active_count != 0)
 				break;
-			/* FALLTHROUGH */
+			fallthrough;
 		case KBASE_PM_SUSPEND_HANDLER_DONT_INCREASE:
 			kbase_pm_unlock(kbdev);
 			return 1;
 
 		case KBASE_PM_SUSPEND_HANDLER_NOT_POSSIBLE:
-			/* FALLTHROUGH */
+			fallthrough;
 		default:
 			KBASE_DEBUG_ASSERT_MSG(false, "unreachable");
 			break;
@@ -143,14 +144,15 @@
 
 KBASE_EXPORT_TEST_API(kbase_pm_context_idle);
 
-void kbase_pm_driver_suspend(struct kbase_device *kbdev)
+int kbase_pm_driver_suspend(struct kbase_device *kbdev)
 {
 	KBASE_DEBUG_ASSERT(kbdev);
 
-	/* Suspend vinstr. This blocks until the vinstr worker and timer are
-	 * no longer running.
+	/* Suspend HW counter intermediaries. This blocks until workers and timers
+	 * are no longer running.
 	 */
 	kbase_vinstr_suspend(kbdev->vinstr_ctx);
+	kbase_kinstr_prfcnt_suspend(kbdev->kinstr_prfcnt_ctx);
 
 	/* Disable GPU hardware counters.
 	 * This call will block until counters are disabled.
@@ -160,7 +162,7 @@
 	mutex_lock(&kbdev->pm.lock);
 	if (WARN_ON(kbase_pm_is_suspending(kbdev))) {
 		mutex_unlock(&kbdev->pm.lock);
-		return;
+		return 0;
 	}
 	kbdev->pm.suspending = true;
 	mutex_unlock(&kbdev->pm.lock);
@@ -191,7 +193,12 @@
 	 */
 	kbasep_js_suspend(kbdev);
 #else
-	kbase_csf_scheduler_pm_suspend(kbdev);
+	if (kbase_csf_scheduler_pm_suspend(kbdev)) {
+		mutex_lock(&kbdev->pm.lock);
+		kbdev->pm.suspending = false;
+		mutex_unlock(&kbdev->pm.lock);
+		return -1;
+	}
 #endif
 
 	/* Wait for the active count to reach zero. This is not the same as
@@ -207,7 +214,12 @@
 	/* NOTE: We synchronize with anything that was just finishing a
 	 * kbase_pm_context_idle() call by locking the pm.lock below
 	 */
-	kbase_hwaccess_pm_suspend(kbdev);
+	if (kbase_hwaccess_pm_suspend(kbdev)) {
+		mutex_lock(&kbdev->pm.lock);
+		kbdev->pm.suspending = false;
+		mutex_unlock(&kbdev->pm.lock);
+		return -1;
+	}
 
 #ifdef CONFIG_MALI_ARBITER_SUPPORT
 	if (kbdev->arb.arb_if) {
@@ -216,6 +228,8 @@
 		mutex_unlock(&kbdev->pm.arb_vm_state->vm_state_lock);
 	}
 #endif /* CONFIG_MALI_ARBITER_SUPPORT */
+
+	return 0;
 }
 
 void kbase_pm_driver_resume(struct kbase_device *kbdev, bool arb_gpu_start)
@@ -246,8 +260,6 @@
 	 * atoms
 	 */
 	kbasep_js_resume(kbdev);
-#else
-	kbase_csf_scheduler_pm_resume(kbdev);
 #endif
 
 	/* Matching idle call, to power off the GPU/cores if we didn't actually
@@ -266,20 +278,24 @@
 	spin_unlock_irqrestore(&kbdev->hwaccess_lock, flags);
 #endif
 
-	/* Resume vinstr */
+	/* Resume HW counters intermediaries. */
 	kbase_vinstr_resume(kbdev->vinstr_ctx);
+	kbase_kinstr_prfcnt_resume(kbdev->kinstr_prfcnt_ctx);
 }
 
-void kbase_pm_suspend(struct kbase_device *kbdev)
+int kbase_pm_suspend(struct kbase_device *kbdev)
 {
+	int result = 0;
 #ifdef CONFIG_MALI_ARBITER_SUPPORT
 	if (kbdev->arb.arb_if)
 		kbase_arbiter_pm_vm_event(kbdev, KBASE_VM_OS_SUSPEND_EVENT);
 	else
-		kbase_pm_driver_suspend(kbdev);
+		result = kbase_pm_driver_suspend(kbdev);
 #else
-	kbase_pm_driver_suspend(kbdev);
+	result = kbase_pm_driver_suspend(kbdev);
 #endif /* CONFIG_MALI_ARBITER_SUPPORT */
+
+	return result;
 }
 
 void kbase_pm_resume(struct kbase_device *kbdev)

--
Gitblit v1.6.2