public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Mukesh Ojha <mojha@codeaurora.org>
To: john.stultz@linaro.org, tglx@linutronix.de, linux-kernel@vger.kernel.org
Cc: neeraju@codeaurora.org, gkohli@codeaurora.org,
	cpandya@codeaurora.org, Mukesh Ojha <mojha@codeaurora.org>
Subject: [PATCH v2] time: Fix sleeptime injection for non-stop clocksource & persistent clock
Date: Wed, 30 May 2018 17:14:59 +0530	[thread overview]
Message-ID: <1527680699-16068-1-git-send-email-mojha@codeaurora.org> (raw)

Currently, for both non-stop clocksource and persistent clock
there is a corner case, when a driver failed to go suspend mode.
rtc_resume() injects the sleeptime as timekeeping_rtc_skipresume()
returned 'false'(sleeptime_injected=false) due to which we can
see mismatch in timestamps between system clock and other timers.

Fix this by updating sleeptime_injected=true for both non-stop
clocksource and persistent clock.

Success case:
------------
                                         {sleeptime_injected=true}
rtc_suspend() => timekeeping_suspend() => timekeeping_resume() =>
  rtc_resume()

Failure case:
------------
             {failure in sleep path} {sleeptime_injected=false}
rtc_suspend()          =>            rtc_resume()

Signed-off-by: Mukesh Ojha <mojha@codeaurora.org>
---
Changes in v2:
 * Updated the commit text.
 * Removed extra variable and used the earlier static
   variable 'sleeptime_injected'.

 kernel/time/timekeeping.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 49cbcee..2754c1b 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -1610,6 +1610,17 @@ static void __timekeeping_inject_sleeptime(struct timekeeper *tk,
  */
 bool timekeeping_rtc_skipresume(void)
 {
+	struct timekeeper *tk = &tk_core.timekeeper;
+	/*
+	 * This is to ensure that we don't end up injecting
+	 * the sleeptime via rtc_resume() for non-stop clocksource
+	 * when we fail to sleep.
+	 */
+	if (!sleeptime_injected)
+		sleeptime_injected = ((tk->tkr_mono.clock->flags &
+			CLOCK_SOURCE_SUSPEND_NONSTOP) ||
+			(persistent_clock_exists)) ? true : false;
+
 	return sleeptime_injected;
 }
 
-- 
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center,
Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project

             reply	other threads:[~2018-05-30 11:45 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-30 11:44 Mukesh Ojha [this message]
2018-06-14 14:07 ` [PATCH v2] time: Fix sleeptime injection for non-stop clocksource & persistent clock Mukesh Ojha
2018-06-22 21:27 ` Thomas Gleixner
2018-06-25 14:38   ` Mukesh Ojha
2018-06-25 15:04     ` Thomas Gleixner
2018-07-06  8:15       ` Mukesh Ojha
2018-07-06  8:58         ` Thomas Gleixner

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=1527680699-16068-1-git-send-email-mojha@codeaurora.org \
    --to=mojha@codeaurora.org \
    --cc=cpandya@codeaurora.org \
    --cc=gkohli@codeaurora.org \
    --cc=john.stultz@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=neeraju@codeaurora.org \
    --cc=tglx@linutronix.de \
    /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