All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kevin Hilman <khilman@deeprootsystems.com>
To: linux-omap@vger.kernel.org
Subject: [PATCH] OMAP: timekeeping: time should not stop during suspend
Date: Thu, 24 Sep 2009 16:35:48 -0700	[thread overview]
Message-ID: <1253835348-12640-1-git-send-email-khilman@deeprootsystems.com> (raw)

During suspend, the kernel timekeeping subsystem is shut down.  Before
suspend and upon resume, it uses a weak function
read_persistent_clock() to determine the amount of time that elapsed
during suspend.

This function was not implemented on OMAP, so from the timekeeping
subsystem perspective (and thus userspace as well) it appeared that no
time elapsed during suspend.

This patch uses the 32k sync timer as a the persistent clock the 32k
sync timer value converted to seconds.

NOTE: This does *NOT* handle wrapping of the 32k sync timer, so
      wrapping of the 32k sync timer during suspend may cause
      problems.  Also, there are not interrupts when the 32k sync
      timer wraps, so something else has to be done.

Reported-by: Jon Hunter <jon-hunter@ti.com>
Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
---
Tested on OMAP3 using PM branch.
If no issues, I will queue for 2.6.32-rc fixes

 arch/arm/plat-omap/common.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/arch/arm/plat-omap/common.c b/arch/arm/plat-omap/common.c
index b3f70e6..3e4325b 100644
--- a/arch/arm/plat-omap/common.c
+++ b/arch/arm/plat-omap/common.c
@@ -178,6 +178,21 @@ unsigned long long sched_clock(void)
 	return ret;
 }
 
+/**
+ * read_persistent_clock -  Return time in seconds from the persistent clock.
+ */
+unsigned long read_persistent_clock(void)
+{
+	unsigned long long ret;
+	cycle_t cycles;
+
+	cycles = clocksource_32k.read(&clocksource_32k);
+	ret = (cycles * clocksource_32k.mult_orig) >> clocksource_32k.shift;
+	do_div(ret, NSEC_PER_SEC);
+
+	return (unsigned long)ret;
+}
+
 static int __init omap_init_clocksource_32k(void)
 {
 	static char err[] __initdata = KERN_ERR
-- 
1.6.4.3


             reply	other threads:[~2009-09-24 23:35 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-24 23:35 Kevin Hilman [this message]
2009-09-28  8:02 ` [PATCH] OMAP: timekeeping: time should not stop during suspend Jean Pihet
2009-10-20 16:33   ` Kevin Hilman
2009-10-22  0:19 ` Kevin Hilman

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=1253835348-12640-1-git-send-email-khilman@deeprootsystems.com \
    --to=khilman@deeprootsystems.com \
    --cc=linux-omap@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.