From: Pavel Machek <pavel@ucw.cz>
To: Andrew Morton <akpm@osdl.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: suspend/resume support for PIT (time.c)
Date: Sun, 11 Jan 2004 12:53:49 +0100 [thread overview]
Message-ID: <20040111115349.GA831@elf.ucw.cz> (raw)
In-Reply-To: <20040110144624.1571488f.akpm@osdl.org>
Hi!
> > +static int pit_resume(struct sys_device *dev)
> > +{
> > + write_seqlock_irq(&xtime_lock);
> > + xtime.tv_sec = get_cmos_time() + clock_cmos_diff;
> > + xtime.tv_nsec = 0;
> > + write_sequnlock_irq(&xtime_lock);
> > + return 0;
> > +}
>
> Have you checked the lock ranking here? get_cmos_time() takes a ton of
> locks, especially if EFI is enabled. Do all those rank inside xtime_lock?
>
> It _looks_ right, but perhaps it would be saner to move the get_coms_time()
> call outside the lock?
Yes, good idea, I do not want to check every change in
get_cmos_time().
Pavel
Index: linux/arch/i386/kernel/time.c
===================================================================
--- linux.orig/arch/i386/kernel/time.c 2004-01-09 20:26:08.000000000 +0100
+++ linux/arch/i386/kernel/time.c 2004-01-11 12:12:48.000000000 +0100
@@ -307,7 +307,31 @@
return retval;
}
+static long clock_cmos_diff;
+
+static int pit_suspend(struct sys_device *dev, u32 state)
+{
+ /*
+ * Estimate time zone so that set_time can update the clock
+ */
+ clock_cmos_diff = -get_cmos_time();
+ clock_cmos_diff += get_seconds();
+ return 0;
+}
+
+static int pit_resume(struct sys_device *dev)
+{
+ unsigned long sec = get_cmos_time() + clock_cmos_diff;
+ write_seqlock_irq(&xtime_lock);
+ xtime.tv_sec = sec;
+ xtime.tv_nsec = 0;
+ write_sequnlock_irq(&xtime_lock);
+ return 0;
+}
+
static struct sysdev_class pit_sysclass = {
+ .resume = pit_resume,
+ .suspend = pit_suspend,
set_kset_name("pit"),
};
--
When do you have a heart between your knees?
[Johanka's followup: and *two* hearts?]
next prev parent reply other threads:[~2004-01-11 11:53 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-01-10 20:03 Pavel Machek
2004-01-10 22:46 ` Andrew Morton
2004-01-11 11:53 ` Pavel Machek [this message]
2004-01-12 18:33 ` john stultz
2004-01-12 22:39 ` Pavel Machek
2004-01-12 23:12 ` Andrew Morton
2004-01-12 23:14 ` Pavel Machek
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=20040111115349.GA831@elf.ucw.cz \
--to=pavel@ucw.cz \
--cc=akpm@osdl.org \
--cc=linux-kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome