Re: [PATCH 2/2] rtc: Avoid accumulating time drift insuspend/resume

From: John Stultz
Date: Wed Jun 01 2011 - 21:14:35 EST


On Wed, 2011-06-01 at 17:54 -0700, Arve HjÃnnevÃg wrote:
> On Tue, May 31, 2011 at 11:07 PM, John Stultz <john.stultz@xxxxxxxxxx> wrote:
> > + /*
> > + * Since these RTC suspend/resume handlers are not called
> > + * at the very end of suspend or the start of resume,
> > + * some run-time may pass on either sides of the sleep time
> > + * so subtract kernel run-time between rtc_suspend to rtc_resume
> > + * to keep things accurate.
> > + */
> > + sleep_time = timespec_sub(sleep_time,
> > + timespec_sub(new_system, old_system));
>
> What happens if sleep_time is negative? I think this need to be
> clamped to 0 to avoid backwards jumps when you wake up more than once
> without the rtc advancing.

Good thought! Although that will be easier to catch in
timekeeping_inject_sleeptime(), so I might add it there.

Thanks for the review!
-john



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/