Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 28 Oct 1999 02:11:44 +0900
From:      Mitsuru IWASAKI <iwasaki@jp.FreeBSD.org>
To:        mike@smith.net.au
Cc:        iwasaki@jp.FreeBSD.org, steveo@iol.ie, freebsd-mobile@freebsd.org, cvs-committers@freebsd.org
Subject:   Re: FreeBSD on a Compaq 1690 
Message-ID:  <199910271711.CAA28493@tasogare.imasy.or.jp>
In-Reply-To: Your message of "Wed, 27 Oct 1999 09:49:03 -0700" <199910271649.JAA03917@dingo.cdrom.com>
References:  <199910271649.JAA03917@dingo.cdrom.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Hi,

> > Linux people also are doing also reloading the countdown register of
> > i8254 after suspend in the same way.  It couldn't hurt, I think.
> > 
> > #ifdef INIT_TIMER_AFTER_SUSPEND
> 
> ...
> 
> Don't make it conditional on yet another obscure define.  It should be 
> the default behaviour.

Sure, I think so too.  My previous mail showed the equivalent code in
linux kernel :-)
The patch I'm going to commit is following.

Index: sys/i386/apm/apm.c
===================================================================
RCS file: /home/ncvs/src/sys/i386/apm/apm.c,v
retrieving revision 1.77.2.13
diff -u -r1.77.2.13 apm.c
--- apm.c	1999/10/13 22:06:46	1.77.2.13
+++ apm.c	1999/10/23 21:03:17
@@ -450,6 +450,7 @@
 
 	/* modified for adjkerntz */
 	pl = splsoftclock();
+	i8254_restore();		/* restore timer_freq and hz */
 	inittodr(0);			/* adjust time to RTC */
 	microtime(&resume_time);
 	getmicrotime(&tmp_time);
Index: sys/i386/include/clock.h
===================================================================
RCS file: /home/ncvs/src/sys/i386/include/clock.h,v
retrieving revision 1.34.2.2
diff -u -r1.34.2.2 clock.h
--- clock.h	1999/08/29 16:06:23	1.34.2.2
+++ clock.h	1999/10/23 21:02:24
@@ -44,6 +44,7 @@
 int	release_timer1 __P((void));
 #endif
 int	sysbeep __P((int pitch, int period));
+void	i8254_restore __P((void));
 
 #endif /* KERNEL */
 
Index: sys/i386/isa/clock.c
===================================================================
RCS file: /home/ncvs/src/sys/i386/isa/clock.c,v
retrieving revision 1.129.2.4
diff -u -r1.129.2.4 clock.c
--- clock.c	1999/08/29 16:07:14	1.129.2.4
+++ clock.c	1999/10/23 21:20:18
@@ -703,6 +703,28 @@
 }
 
 /*
+ * i8254_restore is called from apm_default_resume() to reload
+ * the countdown register.
+ * this should not be necessary but there are broken laptops that
+ * do not restore the countdown register on resume.
+ * when it happnes, it messes up the hardclock interval and system clock,
+ * which leads to the infamous "calcru: negative time" problem.
+ */
+void
+i8254_restore(void)
+{
+	u_long ef;
+
+	ef = read_eflags();
+	disable_intr();
+	outb(TIMER_MODE, TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT);
+	outb(TIMER_CNTR0, timer0_max_count & 0xff);
+	outb(TIMER_CNTR0, timer0_max_count >> 8);
+	CLOCK_UNLOCK();
+	write_eflags(ef);
+}
+
+/*
  * Initialize 8254 timer 0 early so that it can be used in DELAY().
  * XXX initialization of other timers is unintentionally left blank.
  */




To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-mobile" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199910271711.CAA28493>