From: Xunlei Pang <pang.xunlei@linaro.org>
To: John Stultz <john.stultz@linaro.org>
Cc: Xunlei Pang <xlpang@126.com>, lkml <linux-kernel@vger.kernel.org>,
"rtc-linux@googlegroups.com" <rtc-linux@googlegroups.com>,
Thomas Gleixner <tglx@linutronix.de>,
Alessandro Zummo <a.zummo@towertech.it>,
Arnd Bergmann <arnd.bergmann@linaro.org>
Subject: Re: [PATCH v3 1/2] time: Don't bother to run rtc_resume() for the nonstop clocksource
Date: Wed, 11 Feb 2015 14:52:57 +0800 [thread overview]
Message-ID: <CADcy93VvMMwhu7y3ULmPp2Utr0NXsi+H9mokwzMeSnWu-xJE5w@mail.gmail.com> (raw)
In-Reply-To: <CALAqxLW5YGD1wY6OaYJ_G8JN5Afo_OF2C5SHOp0N=Um3KP8z=g@mail.gmail.com>
Hi John,
On 11 February 2015 at 08:01, John Stultz <john.stultz@linaro.org> wrote:
> On Thu, Jan 29, 2015 at 11:59 PM, Xunlei Pang <xlpang@126.com> wrote:
>> From: Xunlei Pang <pang.xunlei@linaro.org>
>>
>> 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@linaro.org>
>> ---
>> v2->v3:
>> Refine according to John's comments using internal variable.
>>
>> drivers/rtc/class.c | 2 +-
>> include/linux/timekeeping.h | 1 +
>> kernel/time/timekeeping.c | 32 ++++++++++++++++++++------------
>> 3 files changed, 22 insertions(+), 13 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;
>
> Took a closer look here.. So you're replacing has_persistent_clock()
> in the resume side, but not the suspend... Can we not cleanup
> has_persistent_clock and consolidate to one accessor for both sides of
> the suspend?
The sequential calls when the system is suspended are:
rtc_suspend(), then timekeeping_suspend().
The sequential calls when the system is resumed are:
timekeeping_resume(), then rtc_resume().
Obviously, timekeeping_sleeptime_injected() used by rtc_resume()
can be easily determined at timekeeping_resume().
And for nonstop clocksources, currently we have code below:
timekeeping_resume():
cycle_now = tk->tkr.read(clock);
if ((clock->flags & CLOCK_SOURCE_SUSPEND_NONSTOP) &&
cycle_now > tk->tkr.cycle_last) {
Here comes the confusing thing: "cycle_now > tk->tkr.cycle_last".
I can't quite catch what's the purpose by judging cycle_now and cycle_last here,
May Nonstop clocksource get wrapped or still can get disfunctional during
system suspend? If so, I think it would be hard to judge exactly whether
rtc_suspend() is needed for nonstop clocksource cases.
If we can get rid of this judgement, I think it would be easy to
consolidate this just
using read_persistent_clock() and CLOCK_SOURCE_SUSPEND_NONSTOP flag.
Any suggestion for this?
Thanks,
Xunlei
>
>>
>> rtc_hctosys_ret = -ENODEV;
>> diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h
>> index 9b63d13..17a460d 100644
>> --- a/include/linux/timekeeping.h
>> +++ b/include/linux/timekeeping.h
>> @@ -225,6 +225,7 @@ static inline void timekeeping_clocktai(struct timespec *ts)
>> /*
>> * RTC specific
>> */
>> +extern bool timekeeping_sleeptime_injected(void);
>> extern void timekeeping_inject_sleeptime64(struct timespec64 *delta);
>>
>> /*
>> diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
>> index 6a93185..b02133e 100644
>> --- a/kernel/time/timekeeping.c
>> +++ b/kernel/time/timekeeping.c
>> @@ -1125,12 +1125,26 @@ static void __timekeeping_inject_sleeptime(struct timekeeper *tk,
>> tk_debug_account_sleep_time(delta);
>> }
>>
>> +static bool sleeptime_inject;
>> +
>> +#if defined(CONFIG_RTC_CLASS) && \
>> + defined(CONFIG_PM_SLEEP) && \
>> + defined(CONFIG_RTC_HCTOSYS_DEVICE)
>
> This change wasn't explained in the commit message. Its fine as a
> small optimization, but probably should be split into its own patch.
>
> thanks
> -john
prev parent reply other threads:[~2015-02-11 6:52 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-29 15:59 [PATCH v3 1/2] time: Don't bother to run rtc_resume() for the nonstop clocksource Xunlei Pang
2015-01-29 15:59 ` [PATCH v3 2/2] rtc: Remove redundant rtc_valid_tm() from rtc_resume() Xunlei Pang
2015-02-04 13:59 ` [PATCH v3 1/2] time: Don't bother to run rtc_resume() for the nonstop clocksource Xunlei Pang
2015-02-10 14:19 ` Peter Zijlstra
2015-02-11 0:01 ` John Stultz
2015-02-11 6:52 ` Xunlei Pang [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CADcy93VvMMwhu7y3ULmPp2Utr0NXsi+H9mokwzMeSnWu-xJE5w@mail.gmail.com \
--to=pang.xunlei@linaro.org \
--cc=a.zummo@towertech.it \
--cc=arnd.bergmann@linaro.org \
--cc=john.stultz@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rtc-linux@googlegroups.com \
--cc=tglx@linutronix.de \
--cc=xlpang@126.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).