linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] (comments requested) adding finer-grained timing to PPC  add_timer_randomness()
@ 2001-08-22 20:57 Chris Friesen
  2001-08-22 21:06 ` Ignacio Vazquez-Abrams
  0 siblings, 1 reply; 11+ messages in thread
From: Chris Friesen @ 2001-08-22 20:57 UTC (permalink / raw)
  To: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 780 bytes --]


I'd like some comments on the following patch.

This patch is designed to add finer-grained timing (similar to the i386 timing)
to add_timer_randomness().  The only tricky bit is that the PPC601 doesn't
support the timebase registers.  Accordingly, I've added a flag to the PPC port
that is used to keep track of whether or not the processor supports the timebase
register.

Is there a better way to keep track of this information?  i386 has a struct with
useful information stored, but it doesn't look like PPC does.

Thanks,

Chris


-- 
Chris Friesen                    | MailStop: 043/33/F10  
Nortel Networks                  | work: (613) 765-0557
3500 Carling Avenue              | fax:  (613) 765-2986
Nepean, ON K2H 8E9 Canada        | email: cfriesen@nortelnetworks.com

[-- Attachment #2: random.patch --]
[-- Type: text/plain, Size: 2158 bytes --]

diff -ru linux-2.2.19-clean/arch/ppc/kernel/setup.c linux-2.2.19/arch/ppc/kernel/setup.c
--- linux-2.2.19-clean/arch/ppc/kernel/setup.c	Sun Mar 25 11:31:49 2001
+++ linux-2.2.19/arch/ppc/kernel/setup.c	Wed Aug 22 16:34:51 2001
@@ -103,6 +103,14 @@
 unsigned long vgacon_remap_base;
 #endif
 
+/* the PPC601 chip does not support timebase registers,
+ * so this is used to keep track of whether or not we 
+ * support them
+ */
+#ifdef CONFIG_6xx
+extern int have_timebase = 1;
+#endif /* CONFIG_6xx */
+
 /* copy of the residual data */
 #ifndef CONFIG_MBX
 unsigned char __res[sizeof(RESIDUAL)] __prepdata = {0,};
@@ -243,6 +251,7 @@
 		{
 		case 1:
 			len += sprintf(len+buffer, "601\n");
+			have_timebase = 0;
 			break;
 		case 3:
 			len += sprintf(len+buffer, "603\n");
diff -ru linux-2.2.19-clean/drivers/char/random.c linux-2.2.19/drivers/char/random.c
--- linux-2.2.19-clean/drivers/char/random.c	Sun Mar 25 11:31:25 2001
+++ linux-2.2.19/drivers/char/random.c	Wed Aug 22 16:35:34 2001
@@ -699,6 +699,7 @@
  * are used for a high-resolution timer.
  *
  */
+ 
 static void add_timer_randomness(struct random_bucket *r,
 				 struct timer_rand_state *state, unsigned num)
 {
@@ -715,6 +716,16 @@
 			:"=a" (time), "=d" (high));
 		num ^= high;
 	} else {
+		time = jiffies;
+	}
+#elif defined (CONFIG_6xx)
+	if (have_timebase) {
+		__u32 high;
+		__asm__ __volatile__("mftbu %0" : "=r" (high) : );
+		__asm__ __volatile__("mftb %0" : "=r" (time) : );
+		num ^= high;
+	}
+	else {
 		time = jiffies;
 	}
 #else
diff -ru linux-2.2.19-clean/include/asm-ppc/processor.h linux-2.2.19/include/asm-ppc/processor.h
--- linux-2.2.19-clean/include/asm-ppc/processor.h	Sun Mar 25 11:31:08 2001
+++ linux-2.2.19/include/asm-ppc/processor.h	Wed Aug 22 16:34:51 2001
@@ -216,6 +216,14 @@
 void start_thread(struct pt_regs *regs, unsigned long nip, unsigned long sp);
 void release_thread(struct task_struct *);
 
+/* the PPC601 chip does not support timebase registers,
+ * so this is used to keep track of whether or not we 
+ * support them
+ */
+#ifdef CONFIG_6xx
+extern int have_timebase;
+#endif /* CONFIG_6xx */
+
 /*
  * Create a new kernel thread.
  */

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2001-08-28 20:50 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-08-22 20:57 [PATCH] (comments requested) adding finer-grained timing to PPC add_timer_randomness() Chris Friesen
2001-08-22 21:06 ` Ignacio Vazquez-Abrams
2001-08-22 21:27   ` Chris Friesen
2001-08-23  1:33   ` Paul Mackerras
2001-08-23  9:46     ` Gabriel Paubert
2001-08-23 13:11       ` Benjamin Herrenschmidt
2001-08-23 12:31     ` Paul Mackerras
2001-08-24  7:32       ` Gabriel Paubert
2001-08-24 13:59         ` Christopher Friesen
2001-08-28 20:50           ` Gabriel Paubert
2001-08-24 17:54         ` [PATCH] (comments requested) adding finer-grained timing to PPC Albert D. Cahalan

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).