public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] update clocksource raw_time in timekeeping_suspend
@ 2009-09-09  7:35 ye janboe
  2009-09-09 14:25 ` Yong Zhang
  2009-09-09 23:07 ` john stultz
  0 siblings, 2 replies; 9+ messages in thread
From: ye janboe @ 2009-09-09  7:35 UTC (permalink / raw)
  To: johnstul, zippel, akpm, mingo; +Cc: linux-kernel

after resume from suspend, raw_time is not updated in
timekeeping_suspend. CLOCK_MONOTONIC_RAW could not get the real hw
time.
This patch fix this issue.

Signed-off-by: janboe <janboe.ye@gmail.com>
---
 kernel/time/timekeeping.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index e8c77d9..8420b85 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -331,6 +331,8 @@ static unsigned long timekeeping_suspend_time;
 static int timekeeping_resume(struct sys_device *dev)
 {
        unsigned long flags;
+       s64 nsec;
+       cycle_t last_cycle, cycle_delta;
        unsigned long now = read_persistent_clock();

        clocksource_resume();
@@ -346,8 +348,12 @@ static int timekeeping_resume(struct sys_device *dev)
        }
        update_xtime_cache(0);
        /* re-base the last cycle value */
+       last_cycle = clock->cycle_last;
        clock->cycle_last = 0;
        clock->cycle_last = clocksource_read(clock);
+       cycle_delta = clock->cycle_last - last_cycle;
+       nsec = cyc2ns(clock, cycle_delta);
+       timespec_add_ns(&clock->raw_time, nsec);
        clock->error = 0;
        timekeeping_suspended = 0;
        write_sequnlock_irqrestore(&xtime_lock, flags);

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2009-09-11 18:10 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-09  7:35 [PATCH] update clocksource raw_time in timekeeping_suspend ye janboe
2009-09-09 14:25 ` Yong Zhang
2009-09-09 22:32   ` ye janboe
2009-09-09 23:07 ` john stultz
2009-09-10  8:07   ` ye janboe
2009-09-10  9:31     ` Yong Zhang
2009-09-10 22:15       ` john stultz
2009-09-11  3:35         ` ye janboe
2009-09-11 18:09           ` john stultz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox