Re: [PATCH v2 1/3] time: Don't bother to run rtc_resume() for the nonstop clocksource
From: John Stultz
Date: Thu Jan 22 2015 - 13:31:06 EST
On Thu, Jan 22, 2015 at 4:01 AM, Xunlei Pang <pang.xunlei@xxxxxxxxxx> wrote:
> If a system does not provide a persistent_clock(), the time
> will be updated on resume by rtc_resume(). With the addition
> of the non-stop clocksources for suspend timing, those systems
> set the time on resume in timekeeping_resume(), but may not
> provide a valid persistent_clock().
>
> This results in the rtc_resume() logic thinking no one has set
> the time and it then will over-write the suspend time again,
> which is not necessary and only increases clock error.
>
> So, fix this for rtc_resume().
>
> Signed-off-by: Xunlei Pang <pang.xunlei@xxxxxxxxxx>
> ---
> v1->v2:
> Modify according to Thomas' feedback.
>
> drivers/rtc/class.c | 2 +-
> include/linux/timekeeping.h | 7 +++++++
> kernel/time/timekeeping.c | 16 +++++-----------
> 3 files changed, 13 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/rtc/class.c b/drivers/rtc/class.c
> index 472a5ad..6100af5 100644
> --- a/drivers/rtc/class.c
> +++ b/drivers/rtc/class.c
> @@ -102,7 +102,7 @@ static int rtc_resume(struct device *dev)
> struct timespec64 sleep_time;
> int err;
>
> - if (has_persistent_clock())
> + if (timekeeping_sleeptime_injected())
> return 0;
>
> rtc_hctosys_ret = -ENODEV;
> diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h
> index 9b63d13..2b87c64 100644
> --- a/include/linux/timekeeping.h
> +++ b/include/linux/timekeeping.h
> @@ -238,6 +238,13 @@ extern void getnstime_raw_and_real(struct timespec *ts_raw,
> */
> extern bool persistent_clock_exist;
> extern int persistent_clock_is_local;
> +extern bool timekeeping_sleeptime_inject;
> +
> +/* Used by rtc_resume() */
> +static inline bool timekeeping_sleeptime_injected(void)
> +{
> + return timekeeping_sleeptime_inject;
> +}
>
Again, there's no reason to make this a static inline, nor the
sleeptime_inject variable global.
Just make it a function in timekeeping and provide definition so it
can be used by the rtc resume.
thanks
-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/