Commit 6e8fe3aa authored by Martin Kepplinger's avatar Martin Kepplinger Committed by Angus Ainslie (Purism)

thermal/drivers/cpu_cooling: workaround cpuidle time calculation error

For cpuidle_cooling_runtime() returning 0, no idle-injection is
applied. For an idle injection percentage of 0, this makes sense. But
this happends for the idle injection percentage of 100 too, which is
wrong.

The documented calculation: ((idle_cycle * 100) / state) - idle_cycle
results 0 for state being 100. For "state" from 0 to 99, the thermal
driver throttles accordingly and keeps the CPUs cool. When switching
to 100, it stops cooling, we see a jump up in temperature and the CPU
heats up until it shuts down.

Work around this problem by keeping the "state" at 99 for calculations,
never reaching 100. The user interface still reaches 100, but there
is no formal connection to actual data and the UI. It's just a unified
range that can be implemented in various ways.
parent 5ce08112
......@@ -926,6 +926,9 @@ static s64 cpuidle_cooling_runtime(struct cpuidle_cooling_device *idle_cdev)
if (!state)
return 0;
if (state == 100)
state = 99;
next_wakeup = (s64)((idle_cdev->idle_cycle * 100) / state) -
idle_cdev->idle_cycle;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment