[PATCH] Timing with TOY on Au1100

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxx
Linux Device Driver                             giometti@xxxxxxxxx
Embedded Systems                     		giometti@xxxxxxxx
UNIX programming                     phone:     +39 349 2432127


[Index of Archives]     [Linux MIPS Home]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Linux]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux