From: Pavel Machek <pavel@suse.cz>
To: George Anzinger <george@mvista.com>
Cc: john stultz <johnstul@us.ibm.com>,
Patrick Mochel <mochel@osdl.org>,
kernel list <linux-kernel@vger.kernel.org>
Subject: Re: [pm] fix time after suspend-to-*
Date: Fri, 24 Oct 2003 01:40:19 +0200 [thread overview]
Message-ID: <20031023234019.GB714@elf.ucw.cz> (raw)
In-Reply-To: <3F9838B4.5010401@mvista.com>
Hi!
> >>Forgive me, I'm not totally familiar w/ the sysfs/pm stuff, but normally
> >>you need to have the xtime_lock to safely manipulate xtime. Also,
> >>couldn't you just call settimeofday() instead? The bit about manually
> >>setting the timezone also confuses me, as we don't normally do this at
> >>bootup in the kernel.
> >>
> >
> >
> >I took it straight from apm.c... But it is well possible that it needs
> >some locking. OTOH this runs with interrupts disabled, perhaps
> >thats enough?
>
> I lost (never saw) the first of this thread, BUT, if this is 2.6, I
> strongly recommend that settimeofday() NOT be called. It will try to
> adjust wall_to_motonoic, but, as this appears to be a correction for time
> lost while sleeping, wall_to_monotonic should not change.
>
> As to locking, ints off for UP, but you need the full lock for SMP systems.
Okay, suspend is currently not supported on SMP, but we should play it
safe. What about this one? [Compile tested only, have to get some sleep.]
Pavel
--- clean/arch/i386/kernel/time.c 2003-10-09 00:13:14.000000000 +0200
+++ linux/arch/i386/kernel/time.c 2003-10-24 01:38:04.000000000 +0200
@@ -271,16 +271,37 @@
unsigned long retval;
spin_lock(&rtc_lock);
-
retval = mach_get_cmos_time();
-
spin_unlock(&rtc_lock);
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)
+{
+ 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;
+}
+
static struct sysdev_class pit_sysclass = {
set_kset_name("pit"),
+ .resume = pit_resume,
+ .suspend = pit_suspend,
};
/* XXX this driverfs stuff should probably go elsewhere later -john */
--
When do you have a heart between your knees?
[Johanka's followup: and *two* hearts?]
next prev parent reply other threads:[~2003-10-23 23:40 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-10-22 23:33 Pavel Machek
2003-10-22 23:52 ` john stultz
2003-10-23 8:17 ` Pavel Machek
2003-10-23 20:23 ` George Anzinger
2003-10-23 20:55 ` john stultz
2003-10-23 23:09 ` George Anzinger
2003-10-23 23:38 ` Pavel Machek
2003-10-24 0:29 ` john stultz
2003-10-24 0:39 ` john stultz
2003-10-24 2:10 ` George Anzinger
2003-10-24 7:48 ` Pavel Machek
2003-10-27 23:24 ` George Anzinger
2003-10-27 23:43 ` Patrick Mochel
2003-10-28 1:35 ` Nigel Cunningham
2003-10-28 8:33 ` Felipe Alfaro Solana
2003-10-28 9:32 ` Pavel Machek
2003-10-28 11:41 ` Stephen Rothwell
2003-10-28 12:29 ` Pavel Machek
2003-10-28 12:39 ` Stephen Rothwell
2003-10-28 22:23 ` Peter Chubb
2003-10-29 2:24 ` Valdis.Kletnieks
2003-10-29 9:43 ` Pavel Machek
2003-10-28 14:30 ` Felipe Alfaro Solana
2003-10-28 17:28 ` Pavel Machek
2003-10-28 20:16 ` Felipe Alfaro Solana
2003-10-28 21:13 ` Andreas Schwab
2003-10-28 21:29 ` George Anzinger
2003-10-29 9:38 ` Pavel Machek
2003-10-29 11:28 ` Gabriel Paubert
2003-10-29 11:55 ` PCI Bus error 6290 or 0290 Remus
2003-10-29 12:40 ` Meelis Roos
2003-10-29 12:49 ` Remus
2003-10-29 20:42 ` [pm] fix time after suspend-to-* George Anzinger
2003-10-30 9:02 ` Pavel Machek
2003-10-28 15:21 ` Valdis.Kletnieks
2003-10-28 17:26 ` Pavel Machek
2003-10-28 18:20 ` Patrick Mochel
2003-10-28 19:36 ` Valdis.Kletnieks
2003-10-28 20:19 ` Felipe Alfaro Solana
2003-10-24 7:49 ` Pavel Machek
2003-10-23 23:40 ` Pavel Machek [this message]
2003-10-27 22:43 ` Patrick Mochel
2003-10-22 23:57 ` Måns Rullgård
2003-10-29 8:20 Mathias Fröhlich
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=20031023234019.GB714@elf.ucw.cz \
--to=pavel@suse.cz \
--cc=george@mvista.com \
--cc=johnstul@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mochel@osdl.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
all inboxes | Powered by JetHome®