msm: rpmrs: Fix overflow error during power calculations
The overflow in power calculations results in incorrect selection of low
power modes during idle. Without the change, the power calculation
favors RPM assisted PC instead of standalone power collapse for shorter
sleep durations.
Change-Id: I85cd2af4bf10dcb5de3ab6b756e694f307a67e23
Signed-off-by: Maheshkumar Sivasubramanian <msivasub@codeaurora.org>
diff --git a/arch/arm/mach-msm/rpm_resources.c b/arch/arm/mach-msm/rpm_resources.c
index 33b07bf..f2b3e88 100644
--- a/arch/arm/mach-msm/rpm_resources.c
+++ b/arch/arm/mach-msm/rpm_resources.c
@@ -914,9 +914,9 @@
} else if ((sleep_us >> 10) > level->time_overhead_us) {
power = level->steady_state_power;
} else {
- power = (sleep_us - level->time_overhead_us);
- power *= level->steady_state_power;
- power /= sleep_us;
+ power = level->steady_state_power;
+ power -= (level->time_overhead_us *
+ level->steady_state_power)/sleep_us;
power += level->energy_overhead / sleep_us;
}