Messages in this thread Patch in this message | | | Date | Fri, 24 Oct 2003 01:40:19 +0200 | From | Pavel Machek <> | Subject | Re: [pm] fix time after suspend-to-* |
| |
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?] - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |