Merge "msm: pm-8x60: Fix suspend time tracking"
diff --git a/arch/arm/mach-msm/pm-8x60.c b/arch/arm/mach-msm/pm-8x60.c
index 00b0b3b..af21584 100644
--- a/arch/arm/mach-msm/pm-8x60.c
+++ b/arch/arm/mach-msm/pm-8x60.c
@@ -651,8 +651,11 @@
{
int64_t time = 0;
- if (msm_pm_use_sync_timer)
- return sched_clock();
+ if (msm_pm_use_sync_timer) {
+ struct timespec ts;
+ getnstimeofday(&ts);
+ return timespec_to_ns(&ts);
+ }
time = msm_timer_get_sclk_time(period);
if (!time)
@@ -663,8 +666,12 @@
static int64_t msm_pm_timer_exit_suspend(int64_t time, int64_t period)
{
- if (msm_pm_use_sync_timer)
- return sched_clock() - time;
+ if (msm_pm_use_sync_timer) {
+ struct timespec ts;
+ getnstimeofday(&ts);
+
+ return timespec_to_ns(&ts) - time;
+ }
if (time != 0) {
int64_t end_time = msm_timer_get_sclk_time(NULL);
@@ -1048,12 +1055,14 @@
}
EXPORT_SYMBOL(msm_pm_enable_retention);
+static int64_t suspend_time, suspend_period;
+static int collapsed;
+static int suspend_power_collapsed;
+
static int msm_pm_enter(suspend_state_t state)
{
bool allow[MSM_PM_SLEEP_MODE_NR];
int i;
- int64_t period = 0;
- int64_t time = msm_pm_timer_enter_suspend(&period);
struct msm_pm_time_params time_param;
time_param.latency_us = -1;
@@ -1081,7 +1090,6 @@
int ret = -ENODEV;
uint32_t power;
uint32_t msm_pm_max_sleep_time = 0;
- int collapsed = 0;
if (MSM_PM_DEBUG_SUSPEND & msm_pm_debug_mask)
pr_info("%s: power collapse\n", __func__);
@@ -1115,11 +1123,7 @@
pr_err("%s: cannot find the lowest power limit\n",
__func__);
}
- time = msm_pm_timer_exit_suspend(time, period);
- if (collapsed)
- msm_pm_add_stat(MSM_PM_STAT_SUSPEND, time);
- else
- msm_pm_add_stat(MSM_PM_STAT_FAILED_SUSPEND, time);
+ suspend_power_collapsed = true;
} else if (allow[MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE]) {
if (MSM_PM_DEBUG_SUSPEND & msm_pm_debug_mask)
pr_info("%s: standalone power collapse\n", __func__);
@@ -1149,6 +1153,7 @@
static int msm_suspend_prepare(void)
{
+ suspend_time = msm_pm_timer_enter_suspend(&suspend_period);
msm_mpm_suspend_prepare();
return 0;
}
@@ -1156,6 +1161,16 @@
static void msm_suspend_wake(void)
{
msm_mpm_suspend_wake();
+ if (suspend_power_collapsed) {
+ suspend_time = msm_pm_timer_exit_suspend(suspend_time,
+ suspend_period);
+ if (collapsed)
+ msm_pm_add_stat(MSM_PM_STAT_SUSPEND, suspend_time);
+ else
+ msm_pm_add_stat(MSM_PM_STAT_FAILED_SUSPEND,
+ suspend_time);
+ suspend_power_collapsed = false;
+ }
}
static const struct platform_suspend_ops msm_pm_ops = {