mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hiroshi MIURA <miura@da-cha.org>
To: macro@ds2.pg.gda.pl, Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: linux-kernel@vger.kernel.org, "Ian S. Nelson" <nelcomp@attglobal.net>
Subject: Re: [PATCH] NSC Geode Companion chip workaround
Date: Sun, 10 Feb 2002 13:24:02 +0900 (JST)	[thread overview]
Message-ID: <20020210042402.B893E11825D@triton2> (raw)
In-Reply-To: <Pine.GSO.3.96.1020206150212.11725E-100000@delta.ds2.pg.gda.pl> <20020209041425.95409118231@triton2>
In-Reply-To: Hiroshi MIURA's message of "Sat, 9 Feb 2002 13:14:25 +0900 (JST)"	<20020209041425.95409118231@triton2>


the MediaGX/Geode companion chip CS5520 fails the latch with the read-back
8254 command as well as 8253 latch command.

test program:  <list1>

kernel configuration: CONFIG_M586

kernel code with read-back command: <list2> 

test results:
  1. kernel 2.4.16 (without any fix, TSC disable)
               fails iteration: 500-1,500
               value of '(now - prev)' when fail:
                               -100 - -200 micro sec
  2. kernel 2.4.16 (with my patch)
               fails iteration: 35,000-70,000 
               error value:  -10 - -20 micro sec
  3. kernel 2.4.16 (with read-back command, TSC enable)
               fails iteration: 5,000-7,000
               error value:  about -20,000 micro sec
  4. kernel 2.4.16 (without any fix but TSC enable)
               fails iteration: 5,000-7,000
               error value: about -20,000 micro sec

these means 'read-back command' fails as well as 'latch command'.
and my patch is better than others.


In message "Re: [PATCH] NSC Geode Companion chip workaround"
    on 02/02/09, Hiroshi MIURA <miura@da-cha.org> writes:
> In message "Re: [PATCH] NSC Geode Companion chip workaround"
>     on 02/02/06, "Maciej W. Rozycki" <macro@ds2.pg.gda.pl> writes:
> > On Wed, 6 Feb 2002, Hiroshi MIURA wrote:
> > 
> > > I've tryed several month with this patch, It seems good for me.
> > >     trial machine: Casio CASSIOPEIA FIVA 101 and Fiva 103.
> > >                    MediaGX 200MHz and NSC Geode 300MHz.
> > 
> >  Does the chip fail with the readback 8254 command as well?  If not, it
> > would be a less intrusive change. 
> 
> OK, I want to try  8254 readback command. I will report after weekend.
 
<list1>
----------------
#include <sys/time.h>
#include <time.h>
#include <assert.h>

int main(void) {
  struct timeval tv[2];
  struct timeval *now, *prev;
  int iterations = 0;

  now = &tv[0];
  prev = &tv[1];
  gettimeofday(prev, NULL);

  for (;;) {
    struct timeval *tmp;

    gettimeofday(now, NULL);
    if (!((now->tv_sec > prev->tv_sec) ||
	   (now->tv_sec == prev->tv_sec && now->tv_usec >= prev->tv_usec)))
		printf ("Err: prev: %d,  %d, now: %d, %d, iter: %d\n", prev->tv_sec,
			prev->tv_usec, now->tv_sec, now->tv_usec, iterations);
    tmp = prev;
    prev = now;
    now = tmp;
    iterations++;
  }
  return iterations;
}
----------------
<list2>
----------------
--- /usr/src/linux/arch/i386/kernel/time.c.multiread	Sat Feb  9 22:24:51 2002
+++ /usr/src/linux/arch/i386/kernel/time.c.readback	Sat Feb  9 20:36:41 2002
@@ -474,6 +474,7 @@
 #ifdef CONFIG_CS5520
 	int count1, count2, count3;
 	int n1, n2, n3;
+	int i, cont, status;
 #endif
 
 	/*
@@ -517,6 +518,26 @@
  
 	do_timer_interrupt(irq, NULL, regs);
 #else
+#if 1
+	    for (i = 0, cont = 1; cont && ( i < 3 ); i++) {
+		spin_lock(&i8253_lock);
+		outb_p(0xf2, 0x43);   /* read-back command */
+		status = inb_p(0x40);
+		count = inb_p(0x40);
+		count |= inb_p(0x40) << 8;
+		spin_unlock(&i8253_lock);
+
+		cont = status & (1 << 6);
+            }
+
+		if (cont) 
+			printk("PIT latch fails 3 times.\n");
+
+		count = ((LATCH-1) - count) * TICK_SIZE;
+		delay_at_last_interrupt = (count + LATCH/2) / LATCH;
+	}
+	do_timer_interrupt(irq, NULL, regs);
+#else
 		spin_lock(&i8253_lock);
 		outb_p(0x00, 0x43);	/* latch the count ASAP */
 /* this codes comes from FreeBSD */
@@ -568,6 +589,7 @@
 	}
 
       do_timer_interrupt(irq, NULL, regs);
+#endif
 #endif
 
 	write_unlock(&xtime_lock);


-- 
Hiroshi Miura  --- miura@da-cha.org http://www.da-cha.org/ 
CCNA, Oracle Silver Master, Network Specialist(JITEC)
My interest: http://www.cis.com.tw/Product/WS-U50R.htm



  reply	other threads:[~2002-02-10  3:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-02-06  2:20 Hiroshi MIURA
2002-02-06 14:06 ` Maciej W. Rozycki
2002-02-09  4:14   ` Hiroshi MIURA
2002-02-10  4:24     ` Hiroshi MIURA [this message]
2002-02-06 14:08 ` 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=20020210042402.B893E11825D@triton2 \
    --to=miura@da-cha.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=macro@ds2.pg.gda.pl \
    --cc=nelcomp@attglobal.net \
    /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®