Subject: clock interrupt rate seems to be slow after resuming from
To: None <port-i386@NetBSD.ORG>
From: enami tsugutomo <enami@but-b.or.jp>
List: port-i386
Date: 01/10/1998 18:45:56
I recently got a new laptop and i've installed NetBSD on it.  Almost
works fine except that clock interrupt rate seems to be slow on it
after resuming from hybernation (on the other hand, it is ok if from
suspend or stanby mode).

Normally clockintr() should be called 100 times per second (and
actually called as so), but after resuming from hybernation, only
about 18 calls per second.

It seems reseting timer0 after resuming as follows works for me, but
is this right solution?

enami.
Index: include/cpu.h
===================================================================
RCS file: /a/cvsroot/NetBSD/src/sys/arch/i386/include/cpu.h,v
retrieving revision 1.1.1.8
diff -u -r1.1.1.8 cpu.h
--- cpu.h	1997/11/27 20:21:45	1.1.1.8
+++ cpu.h	1998/01/10 08:48:47
@@ -148,6 +148,7 @@
 
 /* clock.c */
 void	startrtclock __P((void));
+void	initrtclock __P((void));
 
 /* npx.c */
 void	npxdrop __P((void));
Index: i386/apm.c
===================================================================
RCS file: /a/cvsroot/NetBSD/src/sys/arch/i386/i386/apm.c,v
retrieving revision 1.1.1.11
diff -u -r1.1.1.11 apm.c
--- apm.c	1997/11/13 16:13:30	1.1.1.11
+++ apm.c	1998/01/10 08:49:05
@@ -179,6 +179,7 @@
 #else
 int	apm_v11_enabled = 1;
 #endif
+int	apm_initrtclock = 1;
 
 /* variables used during operation (XXX cgd) */
 struct apm_connect_info apminfo;
@@ -462,12 +463,16 @@
 
 	case APM_NORMAL_RESUME:
 		DPRINTF(APMDEBUG_EVENTS, ("apmev: resume system\n"));
+		if (apm_initrtclock)
+			initrtclock();
 		inittodr(time.tv_sec);
 		apm_record_event(sc, regs->bx);
 		break;
 
 	case APM_CRIT_RESUME:
 		DPRINTF(APMDEBUG_EVENTS, ("apmev: critical resume system"));
+		if (apm_initrtclock)
+			initrtclock();
 		inittodr(time.tv_sec);
 		apm_record_event(sc, regs->bx);
 		break;
Index: isa/clock.c
===================================================================
RCS file: /a/cvsroot/NetBSD/src/sys/arch/i386/isa/clock.c,v
retrieving revision 1.1.1.5
diff -u -r1.1.1.5 clock.c
--- clock.c	1997/02/13 14:49:05	1.1.1.5
+++ clock.c	1998/01/10 09:39:07
@@ -165,6 +165,18 @@
 u_short	isa_timer_lsb_table[256];	/* timer->usec conversion for LSB */
 
 void
+initrtclock()
+{
+
+	/* Initialize 8253 clock */
+	outb(TIMER_MODE, TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT);
+
+	/* Correct rounding will buy us a better precision in timekeeping */
+	outb(TIMER_CNTR0, isa_timer_count % 256);
+	outb(TIMER_CNTR0, isa_timer_count / 256);
+}
+
+void
 startrtclock()
 {
 	int s;
@@ -243,12 +255,7 @@
 		}
 	}
 
-	/* initialize 8253 clock */
-	outb(TIMER_MODE, TIMER_SEL0|TIMER_RATEGEN|TIMER_16BIT);
-
-	/* Correct rounding will buy us a better precision in timekeeping */
-	outb(IO_TIMER1, isa_timer_count % 256);
-	outb(IO_TIMER1, isa_timer_count / 256);
+	initrtclock();
 
 	/* Check diagnostic status */
 	if ((s = mc146818_read(NULL, NVRAM_DIAG)) != 0) { /* XXX softc */