OSDN Git Service

thermal/drivers/hisi: Fix multiple alarm interrupts firing
authorDaniel Lezcano <daniel.lezcano@linaro.org>
Thu, 19 Oct 2017 17:05:47 +0000 (19:05 +0200)
committerEduardo Valentin <edubezval@gmail.com>
Wed, 1 Nov 2017 02:32:15 +0000 (19:32 -0700)
commitdb2b0332608c8e648ea1e44727d36ad37cdb56cb
tree283f64751488274720106352ac1c46a1d0c92fc4
parent48880b979cdc9ef5a70af020f42b8ba1e51dbd34
thermal/drivers/hisi: Fix multiple alarm interrupts firing

The DT specifies a threshold of 65000, we setup the register with a value in
the temperature resolution for the controller, 64656.

When we reach 64656, the interrupt fires, the interrupt is disabled. Then the
irq thread runs and calls thermal_zone_device_update() which will call in turn
hisi_thermal_get_temp().

The function will look if the temperature decreased, assuming it was more than
65000, but that is not the case because the current temperature is 64656
(because of the rounding when setting the threshold). This condition being
true, we re-enable the interrupt which fires immediately after exiting the irq
thread. That happens again and again until the temperature goes to more than
65000.

Potentially, there is here an interrupt storm if the temperature stabilizes at
this temperature. A very unlikely case but possible.

In any case, it does not make sense to handle dozens of alarm interrupt for
nothing.

Fix this by rounding the threshold value to the controller resolution so the
check against the threshold is consistent with the one set in the controller.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Reviewed-by: Leo Yan <leo.yan@linaro.org>
Tested-by: Leo Yan <leo.yan@linaro.org>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
drivers/thermal/hisi_thermal.c