From: john stultz <johnstul@us.ibm.com>
To: Andrew Morton <akpm@osdl.org>
Cc: linux-kernel@vger.kernel.org, pavel@ucw.cz,
Mikael Pettersson <mikpe@it.uu.se>,
Roman Zippel <zippel@linux-m68k.org>
Subject: [PATCH] improve timekeeping resume robustness
Date: Tue, 11 Jul 2006 15:49:34 -0700 [thread overview]
Message-ID: <1152658174.4852.4.camel@localhost> (raw)
In-Reply-To: <200607102336.k6ANaFpx020663@harpo.it.uu.se>
On Tue, 2006-07-11 at 01:36 +0200, Mikael Pettersson wrote:
> With this patch my Latitude resumes OK from APM suspend again.
This patch (against current git tree) resolves problems seen w/ APM
suspend.
Due to resume initialization ordering, its possible we could get a timer
interrupt before the timekeeping resume() function is called. This patch
ensures we don't do any timekeeping accounting before we're fully
resumed.
Signed-off-by: John Stultz <johnstul@us.ibm.com>
diff --git a/kernel/timer.c b/kernel/timer.c
index 2a87430..6ffff03 100644
--- a/kernel/timer.c
+++ b/kernel/timer.c
@@ -968,6 +968,7 @@ void __init timekeeping_init(void)
}
+static int timekeeping_suspended;
/*
* timekeeping_resume - Resumes the generic timekeeping subsystem.
* @dev: unused
@@ -983,6 +984,18 @@ static int timekeeping_resume(struct sys
write_seqlock_irqsave(&xtime_lock, flags);
/* restart the last cycle value */
clock->cycle_last = clocksource_read(clock);
+ clock->error = 0;
+ timekeeping_suspended = 0;
+ write_sequnlock_irqrestore(&xtime_lock, flags);
+ return 0;
+}
+
+static int timekeeping_suspend(struct sys_device *dev, pm_message_t state)
+{
+ unsigned long flags;
+
+ write_seqlock_irqsave(&xtime_lock, flags);
+ timekeeping_suspended = 1;
write_sequnlock_irqrestore(&xtime_lock, flags);
return 0;
}
@@ -990,6 +1003,7 @@ static int timekeeping_resume(struct sys
/* sysfs resume/suspend bits for timekeeping */
static struct sysdev_class timekeeping_sysclass = {
.resume = timekeeping_resume,
+ .suspend = timekeeping_suspend,
set_kset_name("timekeeping"),
};
@@ -1099,14 +1113,17 @@ static void clocksource_adjust(struct cl
static void update_wall_time(void)
{
cycle_t offset;
-
- clock->xtime_nsec += (s64)xtime.tv_nsec << clock->shift;
+
+ /* Make sure we're fully resumed: */
+ if (unlikely(timekeeping_suspended))
+ return;
#ifdef CONFIG_GENERIC_TIME
offset = (clocksource_read(clock) - clock->cycle_last) & clock->mask;
#else
offset = clock->cycle_interval;
#endif
+ clock->xtime_nsec += (s64)xtime.tv_nsec << clock->shift;
/* normally this loop will run just once, however in the
* case of lost or late ticks, it will accumulate correctly.
prev parent reply other threads:[~2006-07-11 22:49 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-07-10 23:36 [BUG] APM resume breakage from 2.6.18-rc1 clocksource changes Mikael Pettersson
2006-07-11 22:49 ` john stultz [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=1152658174.4852.4.camel@localhost \
--to=johnstul@us.ibm.com \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mikpe@it.uu.se \
--cc=pavel@ucw.cz \
--cc=zippel@linux-m68k.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.