Avoid spurious shutdown on ODROID-XU4 (#1385) (#1386)

It seems that the TPU (thermal monitoring) sometimes reports
unreasonable high temperatures, leading the kernel to trigger a thermal
shutdown. Add a patch which filters out such spurious temperature
readings.
This commit is contained in:
Stefan Agner 2021-06-04 15:20:10 +02:00 committed by GitHub
parent 9e921ed9ad
commit 51e80cb7bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 62 additions and 1 deletions

View File

@ -0,0 +1,61 @@
From d6b82edb420c7df4fa8bb0924dae2476beb649a2 Mon Sep 17 00:00:00 2001
Message-Id: <d6b82edb420c7df4fa8bb0924dae2476beb649a2.1622398359.git.stefan@agner.ch>
From: "charles.park" <charles.park@hardkernel.com>
Date: Fri, 1 Jun 2018 18:12:01 +0900
Subject: [PATCH] ODROID-XU4: Update hack avoiding the invalid temperature by
TMU broken
Change-Id: I6092834427950a50746535458e99bf7089212044
---
drivers/thermal/thermal_helpers.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/drivers/thermal/thermal_helpers.c b/drivers/thermal/thermal_helpers.c
index c94bc824e5d3..2880126c5861 100644
--- a/drivers/thermal/thermal_helpers.c
+++ b/drivers/thermal/thermal_helpers.c
@@ -75,6 +75,10 @@ EXPORT_SYMBOL(get_thermal_instance);
*
* Return: On success returns 0, an error code otherwise
*/
+
+#define CRITICAL_TEMP 120000
+int thermal_zone_data[4] = { 0, };
+
int thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp)
{
int ret = -EINVAL;
@@ -108,6 +112,30 @@ int thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp)
*temp = tz->emul_temperature;
}
+ /* save thermal_zone data */
+ if (!ret)
+ thermal_zone_data[tz->id] = *temp;
+ /*
+ * This case is that the thermal sensor is broken.
+ * That's not real temperature. Set the fake temperature value in order to
+ * avoid reaching the ciritical temperature.
+ */
+ if ((thermal_zone_data[tz->id] > CRITICAL_TEMP) && (tz->id != 4)) {
+ int i, broken_sensor = 0, correct_temp = 0;
+ for (i = 0; i < 4; i++) {
+ if ((thermal_zone_data[i] <= CRITICAL_TEMP) &&
+ (correct_temp <= thermal_zone_data[i]))
+ correct_temp = thermal_zone_data[i];
+ if (thermal_zone_data[i] > CRITICAL_TEMP)
+ broken_sensor++;
+ }
+ /*
+ * if all thermal sensor broken then critical temperature data send
+ * for system poweroff.
+ */
+ *temp = (broken_sensor == 4) ? CRITICAL_TEMP : correct_temp;
+ }
+
mutex_unlock(&tz->lock);
exit:
return ret;
--
2.31.1

View File

@ -3,7 +3,7 @@ BR2_cortex_a7=y
BR2_DL_DIR="/cache/dl"
BR2_CCACHE=y
BR2_CCACHE_DIR="/cache/cc"
BR2_GLOBAL_PATCH_DIR="$(BR2_EXTERNAL_HASSOS_PATH)/patches $(BR2_EXTERNAL_HASSOS_PATH)/board/hardkernel/patches"
BR2_GLOBAL_PATCH_DIR="$(BR2_EXTERNAL_HASSOS_PATH)/patches $(BR2_EXTERNAL_HASSOS_PATH)/board/hardkernel/patches $(BR2_EXTERNAL_HASSOS_PATH)/board/hardkernel/odroid-xu4/patches"
BR2_TOOLCHAIN_BUILDROOT_GLIBC=y
BR2_GCC_VERSION_9_X=y
BR2_OPTIMIZE_2=y