From 2f23e319b133c7392493e77f515a237c8e1e6dd6 Mon Sep 17 00:00:00 2001
From: Pascal Paillet
Date: Fri, 10 Jan 2020 11:16:05 +0100
Subject: [PATCH] thermal: stm32: Fix low threshold interrupt flood
With the STM32 thermal peripheral, it is not possible to dump the
temperature that has caused the interrupt.
When the temperature reaches the low threshold, we generally read
a temperature that is a little bit higher than the low threshold.
This maybe due to sampling precision, and also because the CPU becomes
hotter when it quits WFI mode.
In that case, the framework does not change the trip points. This leads
to a lot of low threshold interrupts.
The fix is to set the low threshold value 0.5 degrees Celsius
below the actual request.
The problem is not so frequent with the high threshold and it would
no be a good idea to set the threshold value higher than the request.
Signed-off-by: Pascal Paillet
Signed-off-by: Daniel Lezcano
Link: https://lore.kernel.org/r/20200110101605.24984-7-p.paillet@st.com
---
drivers/thermal/st/stm_thermal.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/thermal/st/stm_thermal.c b/drivers/thermal/st/stm_thermal.c
index aaf25ca2f118..1cc5e6c5709e 100644
--- a/drivers/thermal/st/stm_thermal.c
+++ b/drivers/thermal/st/stm_thermal.c
@@ -321,7 +321,8 @@ static int stm_thermal_set_trips(void *data, int low, int high)
if (low > -INT_MAX) {
sensor->low_temp_enabled = 1;
- ret = stm_thermal_calculate_threshold(sensor, low, &th);
+ /* add 0.5 of hysteresis due to measurement error */
+ ret = stm_thermal_calculate_threshold(sensor, low - 500, &th);
if (ret)
return ret;
--
2.30.2