aboutsummaryrefslogtreecommitdiff
path: root/drivers/thermal
diff options
context:
space:
mode:
authorJavi Merino <javi.merino@arm.com>2015-05-02 10:15:24 +0100
committerKevin Hilman <khilman@linaro.org>2015-07-07 09:20:23 -0700
commit9865d3221d3d9630116c4c9b30cf3276b2655109 (patch)
tree51e5403805e2b20a38b6b0d6b378b4a132150481 /drivers/thermal
parent923b2476a4d19f1bf603ce0d18d655033e109b5d (diff)
thermal: power_allocator: round the division when divvying up power
In situations where there is an uneven number of cooling devices, the division of power among them can lead to a milliwatt being dropped on the floor due to rounding errors. This doesn't sound like a lot, but some devices only grant the lowest cooling device state for their maximum power. So for instance, if the granted_power is the maximum power and all devices are getting their maximum power, one would get max_power - 1, making it choose cooling device state 1, instead of 0. Round the division to make the calculation more accurate. Cc: Zhang Rui <rui.zhang@intel.com> Cc: Eduardo Valentin <edubezval@gmail.com> Signed-off-by: Javi Merino <javi.merino@arm.com> Signed-off-by: Eduardo Valentin <edubezval@gmail.com> (cherry picked from commit ea54cac9065112724f3432e0574ba3e346fd695d) Signed-off-by: Kevin Hilman <khilman@linaro.org>
Diffstat (limited to 'drivers/thermal')
-rw-r--r--drivers/thermal/power_allocator.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/thermal/power_allocator.c b/drivers/thermal/power_allocator.c
index 3ca7530deac6..4672250b329f 100644
--- a/drivers/thermal/power_allocator.c
+++ b/drivers/thermal/power_allocator.c
@@ -196,7 +196,8 @@ static void divvy_up_power(u32 *req_power, u32 *max_power, int num_actors,
for (i = 0; i < num_actors; i++) {
u64 req_range = req_power[i] * power_range;
- granted_power[i] = div_u64(req_range, total_req_power);
+ granted_power[i] = DIV_ROUND_CLOSEST_ULL(req_range,
+ total_req_power);
if (granted_power[i] > max_power[i]) {
extra_power += granted_power[i] - max_power[i];