summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Frid <afrid@nvidia.com>2010-05-05 14:46:04 -0700
committerGary King <gking@nvidia.com>2010-05-11 13:54:02 -0700
commit4e8f661e2231c7cb5ee642d0511e59b6ea343e4d (patch)
tree24a6f2e43c3b92a4778c81a985511f6be6b31dbe
parentaf2ef726e747887ed41c3ea6cbcbd9e27dd3517a (diff)
tegra RM: Updated tegra idle loop timing (part 2).
Estimated LP2 sleep time based on the duration of current idle sleep length as specified by the scheduler, instead of using time to the next interrupt (the latter does not take into account user mode sleep delays). Change-Id: I66bde7035fb71dbcb93c50d92e28a276a1cd9466 Reviewed-on: http://git-master/r/1313 Tested-by: Aleksandr Frid <afrid@nvidia.com> Reviewed-by: Gary King <gking@nvidia.com>
-rw-r--r--arch/arm/mach-tegra/idle-t2.c37
1 files changed, 14 insertions, 23 deletions
diff --git a/arch/arm/mach-tegra/idle-t2.c b/arch/arm/mach-tegra/idle-t2.c
index 0c37b0686f4e..53095c3e5683 100644
--- a/arch/arm/mach-tegra/idle-t2.c
+++ b/arch/arm/mach-tegra/idle-t2.c
@@ -53,7 +53,7 @@ extern struct wake_lock main_wake_lock;
#define TEMP_SAVE_AREA_SIZE 16
#define ENABLE_LP2 1
#define LP2_PADDING_FACTOR 2
-#define LP2_ROUNDTRIP_TIME_US 2500ul
+#define LP2_ROUNDTRIP_TIME_US 2500l
//Let Max LP2 time wait be 71 min (Almost a wrap around)
#define LP2_MAX_WAIT_TIME_US (71*60*1000000ul)
@@ -308,7 +308,7 @@ void cpu_ap20_do_idle(void)
void mach_tegra_idle(void)
{
bool lp2_ok = true;
- unsigned long sleep_time;
+ s64 sleep_time;
#ifdef CONFIG_WAKELOCK
if (!main_wake_lock.flags || has_wake_lock(WAKE_LOCK_IDLE))
@@ -330,40 +330,31 @@ void mach_tegra_idle(void)
lp2_ok = false;
}
- if (lp2_ok) {
- unsigned long now, sleep_jiffies;
-
- now = (unsigned long)get_jiffies_64();
- sleep_jiffies = get_next_timer_interrupt(now) - now;
-
- if (sleep_jiffies > 1) {
- sleep_time = jiffies_to_usecs(sleep_jiffies - 1);
-
- sleep_time = min_t(unsigned long, sleep_time,
- LP2_MAX_WAIT_TIME_US);
+ if (lp2_ok) {
+ sleep_time = ktime_to_us(tick_nohz_get_sleep_length());
- if (sleep_time <=
- (LP2_ROUNDTRIP_TIME_US*LP2_PADDING_FACTOR))
- lp2_ok = false;
- } else
+ if (sleep_time <= (LP2_ROUNDTRIP_TIME_US*LP2_PADDING_FACTOR))
lp2_ok = false;
}
if (lp2_ok) {
+ unsigned long lp2_time;
+
sleep_time -= LP2_ROUNDTRIP_TIME_US;
- tegra_lp2_set_trigger(sleep_time);
+ tegra_lp2_set_trigger((unsigned long)sleep_time);
cpu_ap20_do_lp2();
tegra_lp2_set_trigger(0);
/* add the actual amount of time spent in lp2 to the timers */
- sleep_time = NV_REGR(s_hRmGlobal, NvRmModuleID_Pmif,
+ lp2_time = NV_REGR(s_hRmGlobal, NvRmModuleID_Pmif,
0, APBDEV_PMC_SCRATCH39_0);
- sleep_time -= NV_REGR(s_hRmGlobal, NvRmModuleID_Pmif,
+ lp2_time -= NV_REGR(s_hRmGlobal, NvRmModuleID_Pmif,
0, APBDEV_PMC_SCRATCH38_0);
- // jiffies += usecs_to_jiffies(sleep_time);
- // jiffies updated by tick_nohz_restart_sched_tick() after exit
- NvRmPrivSetLp2TimeUS(s_hRmGlobal, sleep_time);
+ NvRmPrivSetLp2TimeUS(s_hRmGlobal, lp2_time);
+
+ /* adjust kernel timers */
+ hrtimer_peek_ahead_timers();
} else
cpu_ap20_do_idle();