public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC] Improved add_timer_randomness for __CRIS__ (instead of rdtsc())
@ 2002-08-20  9:31 johan.adolfsson
  2002-08-20 14:03 ` Oliver Xymoron
  0 siblings, 1 reply; 11+ messages in thread
From: johan.adolfsson @ 2002-08-20  9:31 UTC (permalink / raw)
  To: linux-kernel; +Cc: Johan Adolfsson

The cris architecture don't have any tsc, but it has a couple of
timer registers that can be used to get better than jiffie resolution.

I set the time to a 40 us resolution counter with a slight
"jump" since lower 8 bit only counts from 0 to 249,
the patch does not take wrapping of the register into account either
to save some cycles, is that a problem or a good thing?

The num is xor:d with the value from 2 timer registers,
which in turn contains different fields breifly described below.

Does the patch below look sane?

/Johan Adolfsson


--- random.c    7 Dec 2001 16:53:17 -0000       1.10
+++ random.c    20 Aug 2002 09:10:04 -0000
@@ -746,6 +746,15 @@ static void add_timer_randomness(struct
        __u32 high;
        rdtsc(time, high);
        num ^= high;
+#elif defined (__CRIS__)
+       /* R_TIMER0_DATA, 8 bit, 40 us resolution, counting down from 250 */
+       /* R_TIMER_DATA, 4*8 bit, timer1, timer0, 38.4kHz, 7.3728MHz */
+       /* R_PRESCALE_STATUS, upper 16 bit: 320ns resolution,
+          lower 16 bit: 40 ns resolution, ~10 bits used,
+          counting down from 1000 */
+       time = jiffies << 8;
+       time |= (TIMER0_DIV - *R_TIMER0_DATA);
+       num ^= *R_PRESCALE_STATUS ^ *R_TIMER_DATA;
 #else
        time = jiffies;
 #endif



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

end of thread, other threads:[~2002-08-21  9:02 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-08-20  9:31 [RFC] Improved add_timer_randomness for __CRIS__ (instead of rdtsc()) johan.adolfsson
2002-08-20 14:03 ` Oliver Xymoron
2002-08-20 16:32   ` johan.adolfsson
2002-08-20 17:06     ` Oliver Xymoron
2002-08-20 17:34       ` johan.adolfsson
2002-08-20 18:02         ` Oliver Xymoron
2002-08-20 19:20           ` johan.adolfsson
2002-08-20 19:34             ` Oliver Xymoron
2002-08-20 22:17               ` johan.adolfsson
2002-08-20 23:00                 ` Oliver Xymoron
2002-08-21  9:11                   ` johan.adolfsson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox