blob: 7b70d66c8a171364450c690f23417263eb2c058c [file] [log] [blame]
From 19b0b30b590b3f5317e90be0c1aa881746c36186 Mon Sep 17 00:00:00 2001
From: Eizan Miyamoto <eizan@chromium.org>
Date: Thu, 6 Aug 2020 15:34:04 +1000
Subject: [PATCH] CHROMIUM: firmware/psci: Delay in psci_system_suspend
Add a delay before calling PSCI SYSTEM_SUSPEND. This is a temporary hack
until we can get a fix into firmware.
On MT8173, we have found that some of the other (non cpu-0) cores may
not have been powered down by the time that the SYSTEM_SUSPEND call is
made. When this happens, the device will hang when trying to enter S3
suspend.
The kernel disables non-boot CPUs by calling PSCI CPU_OFF, and then
polls the CPU status by calling PSCI AFFINITY_INFO. However,
AFFINITY_INFO only indicates the logical state of the CPU, and not the
full power off state as required to ensure a successful SYSTEM_SUSPEND
on MT8173. The delay has been inserted to give the hardware time to
fully reach power off state.
The fix in firmware will poll the SPM_PWR_STATUS and SPM_PWR_STATUS_2ND
registers waiting for all the CPUs to go offline before going into
suspend.
BUG=b:159288905, b:237033919
TEST=stop_ui; suspend_stress_test -i spi32766 --noerrors_fatal
Signed-off-by: Eizan Miyamoto <eizan@chromium.org>
Change-Id: I8fb733165fdb1a21562295b55f75ca76efeee442
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/2340938
Reviewed-by: Daniel Kurtz <djkurtz@chromium.org>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
(cherry picked from commit 095e39dd03f7f279d51edab3b58c11deacde0c07)
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/3863207
Commit-Queue: Pin-yen Lin <treapking@chromium.org>
Tested-by: Pin-yen Lin <treapking@chromium.org>
---
drivers/firmware/psci/psci.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c
index e7bcfca4159f603317660d8525e6eafd4488ec94..29c9ca321d8bae42b2b5994d741106cf6e612364 100644
--- a/drivers/firmware/psci/psci.c
+++ b/drivers/firmware/psci/psci.c
@@ -10,6 +10,7 @@
#include <linux/arm-smccc.h>
#include <linux/cpuidle.h>
#include <linux/debugfs.h>
+#include <linux/delay.h>
#include <linux/errno.h>
#include <linux/linkage.h>
#include <linux/of.h>
@@ -476,6 +477,14 @@ int psci_cpu_suspend_enter(u32 state)
static int psci_system_suspend(unsigned long unused)
{
phys_addr_t pa_cpu_resume = __pa_symbol(cpu_resume);
+ /*
+ * TODO(b/159288905): remove this sleep. It's a hack, specifically for
+ * MT8173, giving CPUs time to be fully powered off before the PSCI call
+ * for SYSTEM_SUSPEND is made. A real fix will be coming in the ARM
+ * trusted firmware that waits for the cores to power down by reading
+ * the SPM_PWR_STATUS[_2ND] registers inside the CPU_SUSPEND handler.
+ */
+ mdelay(1);
return invoke_psci_fn(PSCI_FN_NATIVE(1_0, SYSTEM_SUSPEND),
pa_cpu_resume, 0, 0);
--
2.38.1.584.g0f3c55d4c2-goog