Gitweb: http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=000775c50a19fa899121115f57f355c7f26e4346 Commit: 000775c50a19fa899121115f57f355c7f26e4346 Parent: d0c4c9d4a2e46f052178806c4004d52cd3ae040f Author: David S. Miller <[EMAIL PROTECTED]> AuthorDate: Wed Jan 9 05:09:06 2008 -0800 Committer: David S. Miller <[EMAIL PROTECTED]> CommitDate: Sat Jan 12 21:52:15 2008 -0800
[SPARC]: Make gettimeofday() monotonic again. 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 <[EMAIL PROTECTED]> --- arch/sparc/kernel/time.c | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletions(-) diff --git a/arch/sparc/kernel/time.c b/arch/sparc/kernel/time.c index 45cb7c5..00b393c 100644 --- a/arch/sparc/kernel/time.c +++ b/arch/sparc/kernel/time.c @@ -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. - To unsubscribe from this list: send the line "unsubscribe git-commits-head" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html