mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jim Paris <jim@jtan.com>
To: Willy Tarreau <willy@w.ods.org>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] Re: time() glitch on 2.4.18: solved
Date: Tue, 5 Nov 2002 12:42:34 -0500	[thread overview]
Message-ID: <20021105124234.A5837@neurosis.mit.edu> (raw)
In-Reply-To: <20021105171406.GC879@alpha.home.local>; from willy@w.ods.org on Tue, Nov 05, 2002 at 06:14:06PM +0100

> BTW, why not trying to resync, with something like :
> 
>    if (count >= LATCH)
> 	count = (count >> 8) | inb(0x40) << 8;

That's best if we really are out of sync, but it's hard to tell.  It
could be that the 8253's latch value got clobbered somehow, in which
case we definitely want to fix that or our timer interrupts will come
out at the wrong rate.  We also still need to double-check that
count < LATCH after your code.

Unless we assume that an unpaired read is more common than having the
latch value clobbered in some other way, then I think just resetting
the counter should be okay.  Since none of this _should_ ever happen
(but did on my system, grr), it's probably not worth making it too
complicated just to try to figure out what went wrong.

Updated patch with the printk and corrected conditional is below.

-jim

diff -urN linux-2.4.18/arch/i386/kernel/time.c linux-2.4.18-jim/arch/i386/kernel/time.c
--- linux-2.4.18/arch/i386/kernel/time.c	Fri Mar 15 18:28:53 2002
+++ linux-2.4.18-jim/arch/i386/kernel/time.c	Tue Nov  5 12:39:38 2002
@@ -501,6 +501,18 @@
 
 		count = inb_p(0x40);    /* read the latched count */
 		count |= inb(0x40) << 8;
+
+		/* Any unpaired read will cause the above to swap MSB/LSB
+		   forever.  Try to detect this and reset the counter. */
+		if (count >= LATCH) {
+			printk(KERN_WARNING 
+			       "i8253 count too high! resetting..\n");
+			outb_p(0x34, 0x43);
+			outb_p(LATCH & 0xff, 0x40);
+			outb(LATCH >> 8, 0x40);
+			count = LATCH - 1;
+		}
+
 		spin_unlock(&i8253_lock);
 
 		count = ((LATCH-1) - count) * TICK_SIZE;

  reply	other threads:[~2002-11-05 17:36 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-02  6:37 time() glitch on 2.4.18 at 177 days uptime? Jim Paris
2002-11-03 19:32 ` time() glitch on 2.4.18: solved Jim Paris
2002-11-03 20:30   ` Alan Cox
2002-11-05 16:30     ` [PATCH] " Jim Paris
2002-11-05 16:54       ` george anzinger
2002-11-05 17:10       ` Willy Tarreau
2002-11-05 18:16         ` Alan Cox
2002-11-05 18:02           ` Jim Paris
2002-11-05 18:37             ` Alan Cox
2002-11-05 18:20               ` Willy Tarreau
2002-11-05 18:50                 ` Jim Paris
2002-11-05 17:14       ` Willy Tarreau
2002-11-05 17:42         ` Jim Paris [this message]
2002-11-05 18:57           ` Richard B. Johnson
2002-11-05 19:08             ` Willy Tarreau
2002-11-05 19:29               ` Richard B. Johnson
2002-11-05 20:07                 ` Alan Cox
2002-11-05 20:14                   ` Willy Tarreau
2002-11-05 20:38                     ` Richard B. Johnson
2002-11-05 23:15                       ` Willy Tarreau
2002-11-06 12:47                         ` Richard B. Johnson
2002-11-06 13:25                           ` Alan Cox
2002-11-06 23:21                             ` Jim Paris
2002-11-05 20:23                   ` Richard B. Johnson
2002-11-05 20:57                     ` Alan Cox
2002-11-05 20:41                       ` Richard B. Johnson
2002-11-06 15:09                         ` Christer Weinigel
2002-11-06 15:49                           ` Richard B. Johnson
2002-11-05 20:06             ` Alan Cox
2002-11-05 17:32       ` Alan Cox

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=20021105124234.A5837@neurosis.mit.edu \
    --to=jim@jtan.com \
    --cc=alan@lxorguk.ukuu.org.uk \
    --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

all inboxes | Powered by JetHome®