All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rodolfo Giometti <giometti@linux.it>
To: Linux MIPS <linux-mips@linux-mips.org>
Subject: [PATCH] Timing with TOY on Au1100
Date: Wed, 29 Mar 2006 17:37:48 +0200	[thread overview]
Message-ID: <20060329153748.GU10460@enneenne.com> (raw)

I've checked the TOY programming on a board Au1100 based and I notice
that the frequency is not correct. Infact the TOY frequency is just
HZ/2... I suggest this patch that should fix this topic. 

The patch also try to fix (in a poor manner) a problem related with
the jiffie_drift and the fact that HZ may be in the range [100:1000].

The last block (@@ -189,15 +196,11 @@) remove a bug during system wake
up when HZ is 1000. The while() may loose too much time computing the
last_match20 parameter and if TOY must run at 1K the system hangs
since the TOY is programmed with an alredy passed time stamp.

Ciao,

Rodolfo

Index: common/time.c
===================================================================
RCS file: /home/develop/cvs_private/linux-mips-exadron/arch/mips/au1000/common/time.c,v
retrieving revision 1.3
diff -u -r1.3 time.c
--- a/common/time.c	26 Jul 2005 21:33:32 -0000	1.3
+++ b/common/time.c	29 Mar 2006 15:26:03 -0000
@@ -142,7 +143,7 @@
 		time_elapsed = pc0 - last_match20;
 	}
 
-	while (time_elapsed > 0) {
+	do {
 		do_timer(regs);
 #ifndef CONFIG_SMP
 		update_process_times(user_mode(regs));
@@ -150,14 +151,19 @@
 		time_elapsed -= MATCH20_INC;
 		last_match20 += MATCH20_INC;
 		jiffie_drift++;
-	}
+	} while (time_elapsed > MATCH20_INC);
 
 	last_pc0 = pc0;
 	au_writel(last_match20 + MATCH20_INC, SYS_TOYMATCH2);
 	au_sync();
 
-	/* our counter ticks at 10.009765625 ms/tick, we we're running
-	 * almost 10uS too slow per tick.
+#if HZ < 400
+	/* our counter ticks at 
+	 *   HZ =  100 -> 10.009765625    ms/tick
+	 *   HZ =  400 ->  2.50244140625  ms/tick
+	 *   HZ =  500 ->  1.983642578125 ms/tick
+	 *   HZ = 1000 ->  0.9765625      ms/tick
+	 * so HZ = 400 may be a good discriminating point...
 	 */
 
 	if (jiffie_drift >= 999) {
@@ -167,6 +173,7 @@
 		update_process_times(user_mode(regs));
 #endif
 	}
+#endif
 
 	return IRQ_HANDLED;
 }
@@ -189,15 +196,11 @@
 		time_elapsed = pc0 - last_match20;
 	}
 
-	while (time_elapsed > 0) {
-		time_elapsed -= MATCH20_INC;
-		last_match20 += MATCH20_INC;
-	}
+	last_match20 += time_elapsed - time_elapsed%MATCH20_INC;
 
 	last_pc0 = pc0;
 	au_writel(last_match20 + MATCH20_INC, SYS_TOYMATCH2);
 	au_sync();
-
 }
 
 /* This is just for debugging to set the timer for a sleep delay.

-- 

GNU/Linux Solutions                  e-mail:    giometti@enneenne.com
Linux Device Driver                             giometti@gnudd.com
Embedded Systems                     		giometti@linux.it
UNIX programming                     phone:     +39 349 2432127

                 reply	other threads:[~2006-03-29 15:26 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20060329153748.GU10460@enneenne.com \
    --to=giometti@linux.it \
    --cc=linux-mips@linux-mips.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.