]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[SPARC]: Make gettimeofday() monotonic again.
authorDavid S. Miller <davem@davemloft.net>
Wed, 9 Jan 2008 13:09:06 +0000 (05:09 -0800)
committerDavid S. Miller <davem@davemloft.net>
Sun, 13 Jan 2008 05:52:15 +0000 (21:52 -0800)
When we switched away from the optimized C version
things stopped being monotonic.

The problem is that if we run this with interrupts disabled, we can
see the interrupt pending because the counter reached the limit value.
When this happens the counter has bit 31 set, and the low bits start
counting again from zero.

Reported by Martin Habets.

Signed-off-by: David S. Miller <davem@davemloft.net>
arch/sparc/kernel/time.c

index 45cb7c5286d7cb327d19d057de0ab07e77fbe2ce..00b393c3a4a09edcde2b89e283c9642199c09670 100644 (file)
@@ -436,7 +436,14 @@ void __init time_init(void)
 
 static inline unsigned long do_gettimeoffset(void)
 {
-       return (*master_l10_counter >> 10) & 0x1fffff;
+       unsigned long val = *master_l10_counter;
+       unsigned long usec = (val >> 10) & 0x1fffff;
+
+       /* Limit hit?  */
+       if (val & 0x80000000)
+               usec += 1000000 / HZ;
+
+       return usec;
 }
 
 /* Ok, my cute asm atomicity trick doesn't work anymore.