lkml.org 
[lkml]   [2004]   [Jan]   [11]   [last100]   RSS Feed
Views: [more markup]  [less markup]  [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
DateSun, 11 Jan 2004 12:53:49 +0100
FromPavel Machek <>
SubjectRe: suspend/resume support for PIT (time.c)
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?]
-
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/

\
 
 \ /
  Last update: 2005-03-22 13:00    [from the cache]
©2003-2008