From 000775c50a19fa899121115f57f355c7f26e4346 Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Wed, 9 Jan 2008 05:09:06 -0800 Subject: [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 --- arch/sparc/kernel/time.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/arch/sparc/kernel/time.c b/arch/sparc/kernel/time.c index 45cb7c5286d..00b393c3a4a 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. -- cgit v1.2.3 From bf4a7972d638741bbb0672653c1fa10e4480c385 Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Thu, 10 Jan 2008 21:10:54 -0800 Subject: [SPARC64]: Fix build with SPARSEMEM_VMEMMAP disabled. Signed-off-by: David S. Miller --- arch/sparc64/kernel/ktlb.S | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/sparc64/kernel/ktlb.S b/arch/sparc64/kernel/ktlb.S index 964527d2ffa..cef8defcd7a 100644 --- a/arch/sparc64/kernel/ktlb.S +++ b/arch/sparc64/kernel/ktlb.S @@ -1,6 +1,6 @@ /* arch/sparc64/kernel/ktlb.S: Kernel mapping TLB miss handling. * - * Copyright (C) 1995, 1997, 2005 David S. Miller + * Copyright (C) 1995, 1997, 2005, 2008 David S. Miller * Copyright (C) 1996 Eddie C. Dost (ecd@brainaid.de) * Copyright (C) 1996 Miguel de Icaza (miguel@nuclecu.unam.mx) * Copyright (C) 1996,98,99 Jakub Jelinek (jj@sunsite.mff.cuni.cz) @@ -226,6 +226,7 @@ kvmap_dtlb_load: ba,pt %xcc, sun4v_dtlb_load mov %g5, %g3 +#ifdef CONFIG_SPARSEMEM_VMEMMAP kvmap_vmemmap: sub %g4, %g5, %g5 srlx %g5, 22, %g5 @@ -234,6 +235,7 @@ kvmap_vmemmap: or %g1, %lo(vmemmap_table), %g1 ba,pt %xcc, kvmap_dtlb_load ldx [%g1 + %g5], %g5 +#endif kvmap_dtlb_nonlinear: /* Catch kernel NULL pointer derefs. */ @@ -242,12 +244,14 @@ kvmap_dtlb_nonlinear: bleu,pn %xcc, kvmap_dtlb_longpath nop +#ifdef CONFIG_SPARSEMEM_VMEMMAP /* Do not use the TSB for vmemmap. */ mov (VMEMMAP_BASE >> 24), %g5 sllx %g5, 24, %g5 cmp %g4,%g5 bgeu,pn %xcc, kvmap_vmemmap nop +#endif KERN_TSB_LOOKUP_TL1(%g4, %g6, %g5, %g1, %g2, %g3, kvmap_dtlb_load) -- cgit v1.2.3