timekeeping: utilize the suspend-nonstop clocksource to count suspended time
authorFeng Tang <feng.tang@intel.com>
Tue, 12 Mar 2013 03:56:48 +0000 (11:56 +0800)
committerJohn Stultz <john.stultz@linaro.org>
Fri, 15 Mar 2013 23:51:29 +0000 (16:51 -0700)
commite445cf1c4257cc0238d72e4129eb4739f46fd3de
tree5ff9c120a867939996d83dae6e885e81177c1819
parent82f9c080b22a5b859ae2b50822dfb6b812898fdb
timekeeping: utilize the suspend-nonstop clocksource to count suspended time

There are some new processors whose TSC clocksource won't stop during
suspend. Currently, after system resumes, kernel will use persistent
clock or RTC to compensate the sleep time, but with these nonstop
clocksources, we could skip the special compensation from external
sources, and just use current clocksource for time recounting.

This can solve some time drift bugs caused by some not-so-accurate or
error-prone RTC devices.

The current way to count suspended time is first try to use the persistent
clock, and then try the RTC if persistent clock can't be used. This
patch will change the trying order to:
suspend-nonstop clocksource -> persistent clock -> RTC

When counting the sleep time with nonstop clocksource, use an accurate way
suggested by Jason Gunthorpe to cover very large delta cycles.

Signed-off-by: Feng Tang <feng.tang@intel.com>
[jstultz: Small optimization, avoiding re-reading the clocksource]
Signed-off-by: John Stultz <john.stultz@linaro.org>
kernel/time/timekeeping.c