linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Richard B. Johnson" <root@chaos.analogic.com>
To: Willy Tarreau <willy@w.ods.org>
Cc: Linux kernel <linux-kernel@vger.kernel.org>
Subject: Re: Linux 2.4.20 RTC Timer bug
Date: Fri, 18 Jul 2003 08:39:29 -0400 (EDT)	[thread overview]
Message-ID: <Pine.LNX.4.53.0307180834520.189@chaos> (raw)
In-Reply-To: <20030718043129.GA3229@alpha.home.local>

On Fri, 18 Jul 2003, Willy Tarreau wrote:

> On Thu, Jul 17, 2003 at 04:38:05PM -0400, Richard B. Johnson wrote:
>
[SNIPPED...]

> > Or leaves the index register somewhere that a power-fail sequence will
> > trash a checksummed register..
>
> yes, that's possible too.
>
>
>
> is it in the spec that it has to be set to 0xFF or because you chose this
> value since it's out of the checksummed area ? On older chips, it will be
> equal to 0x3F (0xBF if we include NMI) and on newer ones, 0x7F. If the BIOS
> uses these bytes to write the checksum of the advanced setup, it might be
> dangerous. I would personaly prefer to set it to something not checked, such
> as the alarm, status, or so (except if the chip does a special case of FF).

Well, yes. It probably should be left at status register 'D'.  Here's
a patch. Let's see if the Linux folks accept it....

Problem:
Power failure can cause CMOS checksum corruption and failure to boot.
Patch (tested -- running now):


--- linux-2.4.20/include/asm-i386/mc146818rtc.h.orig	Thu Jul 17 15:06:33 2003
+++ linux-2.4.20/include/asm-i386/mc146818rtc.h	Fri Jul 18 08:01:58 2003
@@ -10,18 +10,28 @@
 #define RTC_PORT(x)	(0x70 + (x))
 #define RTC_ALWAYS_BCD	1	/* RTC operates in binary mode */
 #endif
+#define RTC_FAILSAFE  0x0d
+#define NMI_ENABLE    0x80

 /*
  * The yet supported machines all access the RTC index register via
  * an ISA port access but the way to access the date register differs ...
+ * Modified 18-JUL-2003
+ * Willy Tarreau <willy@w.ods.org>, Richard Johnson <rjohnson@analogic.com>
+ * Leave index register at status register D so a power failure doesn't
+ * corrupt checksummed CMOS. Keep NMI bit enabled (in case it really exists).
  */
 #define CMOS_READ(addr) ({ \
-outb_p((addr),RTC_PORT(0)); \
-inb_p(RTC_PORT(1)); \
+int __val; \
+outb_p((addr)|NMI_ENABLE,RTC_PORT(0)); \
+__val = inb_p(RTC_PORT(1)); \
+outb_p(RTC_FAILSAFE|NMI_ENABLE, RTC_PORT(0)); \
+__val; \
 })
 #define CMOS_WRITE(val, addr) ({ \
-outb_p((addr),RTC_PORT(0)); \
+outb_p((addr)|NMI_ENABLE,RTC_PORT(0)); \
 outb_p((val),RTC_PORT(1)); \
+outb_p(RTC_FAILSAFE|NMI_ENABLE, RTC_PORT(0)); \
 })

 #define RTC_IRQ 8




Cheers,
Dick Johnson
Penguin : Linux version 2.4.20 on an i686 machine (797.90 BogoMips).
            Note 96.31% of all statistics are fiction.


      parent reply	other threads:[~2003-07-18 12:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-07-16 20:31 Linux 2.4.20 RTC Timer bug Richard B. Johnson
2003-07-16 21:18 ` Willy Tarreau
2003-07-17 11:25   ` Richard B. Johnson
2003-07-17 19:17     ` Willy Tarreau
     [not found]       ` <Pine.LNX.4.53.0307171624510.12702@chaos>
     [not found]         ` <20030718043129.GA3229@alpha.home.local>
2003-07-18 12:39           ` Richard B. Johnson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.53.0307180834520.189@chaos \
    --to=root@chaos.analogic.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=willy@w.ods.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).