From nobody@FreeBSD.org  Tue Apr  4 15:38:40 2000
Return-Path: <nobody@FreeBSD.org>
Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21])
	by hub.freebsd.org (Postfix) with ESMTP id 2F30B37B5AC
	for <freebsd-gnats-submit@FreeBSD.org>; Tue,  4 Apr 2000 15:38:40 -0700 (PDT)
	(envelope-from nobody@FreeBSD.org)
Received: (from nobody@localhost)
	by freefall.freebsd.org (8.9.3/8.9.2) id PAA55218;
	Tue, 4 Apr 2000 15:38:40 -0700 (PDT)
	(envelope-from nobody@FreeBSD.org)
Message-Id: <200004042238.PAA55218@freefall.freebsd.org>
Date: Tue, 4 Apr 2000 15:38:40 -0700 (PDT)
From: jose@we.lc.ehu.es
Sender: nobody@FreeBSD.org
To: freebsd-gnats-submit@FreeBSD.org
Subject: [PATCH] problem with statclock initialization

>Number:         17800
>Category:       i386
>Synopsis:       [PATCH] problem with statclock initialization
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    bde
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Apr  4 15:40:01 PDT 2000
>Closed-Date:    Thu Feb 03 19:06:29 GMT 2005
>Last-Modified:  Thu Feb 03 19:06:29 GMT 2005
>Originator:     Jose M. Alcaide
>Release:        3.4, 4.0, -CURRENT :-)
>Organization:
Universidad del Pais Vasco - Dept. de Electricidad y Electronica
>Environment:
FreeBSD v-ger.we.lc.ehu.es 3.4-RELEASE FreeBSD 3.4-RELEASE #0: Tue Apr  4 23:53:52 CEST 2000     root@v-ger.we.lc.ehu.es:/usr/src/sys/compile/V-GER  i386

>Description:
I found that the RTC does not generate statclock interrupts on a
Dell Inspiron 3700 laptop under some circumstances (after rebooting while
connected to AC power).  Probably the BIOS fiddles the MC146818A in
such a way that an interrupt is pending when the kernel initializes
the system clocks.  The routine cpu_initclocks() should ensure that
there are no RTC interrupts pending before enabling IRQ8 in the ICU.
This can be easily accomplished simply reading the RTC_INTR register.
I tested this solution on my I3.7k laptop, and now the statclock always
works.  Maybe other laptops are affected by the same problem.
>How-To-Repeat:
Install FreeBSD 3.x, 4.0-STABLE or 5.0-CURRENT on a Dell Inspiron 3700 :-)
Be sure that apm(4)'s 0x20 flag is _not_ set.
Reboot with shutdown -r (warm boot).
Type "vmstat -i" or "systat -vmstat".
>Fix:
The following patch (against 4.0-RELEASE's clock.c, but I think it is
applicable to -CURRENT) does the trick:

--------------------------- CUT HERE --------------------------
--- sys/i386/isa/clock.c.orig	Tue Jan  4 23:24:59 2000
+++ sys/i386/isa/clock.c	Wed Apr  5 00:04:45 2000
@@ -1022,6 +1022,7 @@
 	/* Initialize RTC. */
 	writertc(RTC_STATUSA, rtc_statusa);
 	writertc(RTC_STATUSB, RTCSB_24HR);
+	rtcin(RTC_INTR); /* clear any pending interrupt */
 
 	/* Don't bother enabling the statistics clock. */
 	if (statclock_disable)
--------------------------- CUT HERE --------------------------


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->bde 
Responsible-Changed-By: jmas 
Responsible-Changed-When: Wed Apr 5 05:49:13 PDT 2000 
Responsible-Changed-Why:  
Over to maintainer (I think) 

From: Charlie Schluting <charlie@schluting.com>
To: freebsd-gnats-submit@FreeBSD.org
Cc: jose@we.lc.ehu.es, current@freebsd.org
Subject: Re: i386/17800:PATCH problem with statclock initialization (NEW Patch)
Date: Thu, 18 Nov 2004 13:12:05 -0800

 I had the same problem described in this PR with a Dell Latitude CPt. I 
 believe its the same motherboard, or very similar. In both 5.2.1 and 
 6-CURRENT I couldn't get cpu usage stats.
 
 Jose's patch fixes it... though the patch is no longer valid in 
 6-CURRENT (from cvs 2 days ago).
 
 New patch. Same content, different location:
 ---------------------------------------------------------------------
 --- sys/i386/isa/clock.c.old    Thu Nov 18 11:18:59 2004
 +++ sys/i386/isa/clock.c        Thu Nov 18 11:12:10 2004
 @@ -946,6 +946,7 @@
          /* Initialize RTC. */
          writertc(RTC_STATUSA, rtc_statusa);
          writertc(RTC_STATUSB, RTCSB_24HR);
 +       rtcin(RTC_INTR); /* clear any pending interrupt */
 
          /* Don't bother enabling the statistics clock. */
          if (!statclock_disable) {
 ---------------------------------------------------------------------
 
 Tested, and it works.
 Please commit :)
 
 -Charlie Schluting
State-Changed-From-To: open->closed 
State-Changed-By: jhb 
State-Changed-When: Thu Feb 3 19:06:13 GMT 2005 
State-Changed-Why:  
Expanded version of the patch committed. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=17800 
>Unformatted:
 X-Send-Pr-Version: www-1.0
 
 
 
