From 51e80cb7bcc98f32833867e2d4089ad8081cf892 Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Fri, 4 Jun 2021 15:20:10 +0200 Subject: [PATCH] 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. --- ...e-hack-avoiding-the-invalid-temperat.patch | 61 +++++++++++++++++++ .../configs/odroid_xu4_defconfig | 2 +- 2 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 buildroot-external/board/hardkernel/odroid-xu4/patches/linux/0001-ODROID-XU4-Update-hack-avoiding-the-invalid-temperat.patch diff --git a/buildroot-external/board/hardkernel/odroid-xu4/patches/linux/0001-ODROID-XU4-Update-hack-avoiding-the-invalid-temperat.patch b/buildroot-external/board/hardkernel/odroid-xu4/patches/linux/0001-ODROID-XU4-Update-hack-avoiding-the-invalid-temperat.patch new file mode 100644 index 000000000..cbdca0ea2 --- /dev/null +++ b/buildroot-external/board/hardkernel/odroid-xu4/patches/linux/0001-ODROID-XU4-Update-hack-avoiding-the-invalid-temperat.patch @@ -0,0 +1,61 @@ +From d6b82edb420c7df4fa8bb0924dae2476beb649a2 Mon Sep 17 00:00:00 2001 +Message-Id: +From: "charles.park" +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 + diff --git a/buildroot-external/configs/odroid_xu4_defconfig b/buildroot-external/configs/odroid_xu4_defconfig index c5dc3af30..93e991ab9 100644 --- a/buildroot-external/configs/odroid_xu4_defconfig +++ b/buildroot-external/configs/odroid_xu4_defconfig @@ -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