linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: Screwy clock after apm suspend
@ 2004-12-29 11:38 Mikael Pettersson
  2005-01-03 17:34 ` Pavel Machek
  0 siblings, 1 reply; 25+ messages in thread
From: Mikael Pettersson @ 2004-12-29 11:38 UTC (permalink / raw)
  To: linux-kernel, plazmcman

On Tue, 28 Dec 2004 16:29:44 -0800, Brannon Klopfer wrote:
>2.6.10 screws up my system clock.
>Two kernel/hardware clock readings, before and after suspend.
>-------------
>plaz@gonzo:~$ date ;hwclock
>Tue Dec 28 15:52:39 PST 2004
>Tue Dec 28 14:54:07 2004 -0.503621 seconds
>#suspend, resume
>plaz@gonzo:~$ date ;hwclock
>Tue Dec 28 16:11:58 PST 2004
>Tue Dec 28 15:04:06 2004 -0.168262 seconds
...
>I did not have this problem with 2.6.9. My machine uses APM, clock 
>stores local time (specified in kernel config). I use PIT for 
>timesource, as others were losing ticks when on battery power (changes 
>CPU clock speed). Again, did _not_ have this problem with 2.6.9.

I reported this problem a while ago for 2.6.10-rc1:
http://marc.theaimsgroup.com/?l=linux-kernel&m=110172841429272&w=2.
At the time I thought the APM daemon's hwclock --hctosys at resume
might be in conflict with the kernel change, but I've since disabled
that and it didn't solve the problem.

For now, I'm using the patch below to revert the i386 time.c's
behaviour to what it was before the broken change in 2.6.10-rc1.

/Mikael

--- linux-2.6.10/arch/i386/kernel/time.c.~1~	2004-12-25 12:16:17.000000000 +0100
+++ linux-2.6.10/arch/i386/kernel/time.c	2004-12-25 23:56:19.000000000 +0100
@@ -319,7 +319,7 @@ unsigned long get_cmos_time(void)
 	return retval;
 }
 
-static long clock_cmos_diff, sleep_start;
+static long clock_cmos_diff;
 
 static int timer_suspend(struct sys_device *dev, u32 state)
 {
@@ -328,7 +328,6 @@ static int timer_suspend(struct sys_devi
 	 */
 	clock_cmos_diff = -get_cmos_time();
 	clock_cmos_diff += get_seconds();
-	sleep_start = get_cmos_time();
 	return 0;
 }
 
@@ -336,19 +335,16 @@ static int timer_resume(struct sys_devic
 {
 	unsigned long flags;
 	unsigned long sec;
-	unsigned long sleep_length;
 
 #ifdef CONFIG_HPET_TIMER
 	if (is_hpet_enabled())
 		hpet_reenable();
 #endif
 	sec = get_cmos_time() + clock_cmos_diff;
-	sleep_length = get_cmos_time() - sleep_start;
 	write_seqlock_irqsave(&xtime_lock, flags);
 	xtime.tv_sec = sec;
 	xtime.tv_nsec = 0;
 	write_sequnlock_irqrestore(&xtime_lock, flags);
-	jiffies += sleep_length * HZ;
 	return 0;
 }
 

^ permalink raw reply	[flat|nested] 25+ messages in thread
* Re: Screwy clock after apm suspend
@ 2005-01-15 18:30 Mikael Pettersson
  2005-01-16 19:47 ` Alex Romosan
  0 siblings, 1 reply; 25+ messages in thread
From: Mikael Pettersson @ 2005-01-15 18:30 UTC (permalink / raw)
  To: pavel; +Cc: bernard, linux-kernel, shawv

On Tue, 11 Jan 2005 14:10:19 +0100, Pavel Machek wrote:
>>  > Looking harder, in arch/i386/kernel/apm.c the system time is also
>>  > saved and restored in a very similar way to timer_suspend/resume.
>>  > Would this account for the time drift in APM mode? (sleep time being
>>  > accounted for twice?)
>> 
>> No, apm.c's update to xtime is absolute, just like time.c's.
>> Doing both is pointless but not harmful. (I've already tried
>> with apm.c's xtime update commented out, but the time-warp
>> bug remained.)
>> 
>> My 0.02 SEK says it's the jiffies update that's broken.
>
>Okay, can you
>
>* kill jiffie update (x86-64, too)
>* remove apm.c variant
>* test it (or make someone test it) with apm?
>
>I now see the drift with acpi, too :-(. I can do the acpi testing...

I'm no longer seeing any time jumps after resumes with the
2.6.11-rc1 kernel. It looks like the wall_jiffies change in
time.c fixed the bug.

/Mikael

^ permalink raw reply	[flat|nested] 25+ messages in thread
* Re: Screwy clock after apm suspend
@ 2005-01-07 18:08 Shaw
  2005-01-09 22:47 ` Pavel Machek
  0 siblings, 1 reply; 25+ messages in thread
From: Shaw @ 2005-01-07 18:08 UTC (permalink / raw)
  To: Pavel Machek, Mikael Pettersson; +Cc: linux-kernel, plazmcman

Hi, 

Just thought I'd add that I too am seeing a big time drift on my
Thinkpad (T30) without ACPI during an APM suspend w/ 2.6.10.  If I can
help by testing patches, or providing any additional information,
please let me know.

Thanks,
Shaw

^ permalink raw reply	[flat|nested] 25+ messages in thread
* Screwy clock after apm suspend
@ 2004-12-29  0:29 Brannon Klopfer
  2004-12-29  1:18 ` Nigel Cunningham
  0 siblings, 1 reply; 25+ messages in thread
From: Brannon Klopfer @ 2004-12-29  0:29 UTC (permalink / raw)
  To: linux kernel

2.6.10
Slackware 10/-current
IBM ThinkPad 600E
----------------

2.6.10 screws up my system clock.
Two kernel/hardware clock readings, before and after suspend.
-------------
plaz@gonzo:~$ date ;hwclock
Tue Dec 28 15:52:39 PST 2004
Tue Dec 28 14:54:07 2004 -0.503621 seconds
#suspend, resume
plaz@gonzo:~$ date ;hwclock
Tue Dec 28 16:11:58 PST 2004
Tue Dec 28 15:04:06 2004 -0.168262 seconds
---------------------
These are all when the comp is on without suspend (difference about the 
same throughout).
----------------
plaz@gonzo:~$ date ;hwclock
Tue Dec 28 16:14:52 PST 2004
Tue Dec 28 15:07:00 2004 -0.251812 seconds
plaz@gonzo:~$ date ;hwclock
Tue Dec 28 16:15:26 PST 2004
Tue Dec 28 15:07:34 2004 -0.236138 seconds
plaz@gonzo:~$ date ;hwclock
Tue Dec 28 16:19:48 PST 2004
Tue Dec 28 15:11:57 2004 -0.908540 seconds
plaz@gonzo:~$
------------
I did not have this problem with 2.6.9. My machine uses APM, clock 
stores local time (specified in kernel config). I use PIT for 
timesource, as others were losing ticks when on battery power (changes 
CPU clock speed). Again, did _not_ have this problem with 2.6.9.

Be glad to try out patches,
Brannon Klopfer

^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2005-01-16 19:52 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-29 11:38 Screwy clock after apm suspend Mikael Pettersson
2005-01-03 17:34 ` Pavel Machek
  -- strict thread matches above, loose matches on Subject: below --
2005-01-15 18:30 Mikael Pettersson
2005-01-16 19:47 ` Alex Romosan
2005-01-07 18:08 Shaw
2005-01-09 22:47 ` Pavel Machek
2005-01-10  2:15   ` Alex Romosan
2005-01-10  7:28   ` Shaw
2005-01-10  7:44     ` bernard
2005-01-10 10:57       ` Pavel Machek
2005-01-10 17:48         ` Bernard Blackham
2005-01-11  0:14           ` Pavel Machek
2005-01-11  1:10             ` Nigel Cunningham
2005-01-11  3:12               ` Pavel Machek
2005-01-11  1:16             ` Bernard Blackham
2005-01-11  3:21               ` Pavel Machek
2005-01-11 12:36               ` Mikael Pettersson
2005-01-11 13:10                 ` Pavel Machek
2005-01-11 14:15                   ` Mikael Pettersson
2005-01-11 20:18                     ` Pavel Machek
2005-01-11  3:13             ` Stephen Rothwell
2005-01-11  3:19               ` Pavel Machek
2005-01-11 12:32                 ` Mikael Pettersson
2004-12-29  0:29 Brannon Klopfer
2004-12-29  1:18 ` Nigel Cunningham

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).