[MIPS] VSMP: Synchronize cp0 counters on bootup.
authorRalf Baechle <ralf@linux-mips.org>
Tue, 31 Oct 2006 18:33:09 +0000 (18:33 +0000)
committerRalf Baechle <ralf@linux-mips.org>
Tue, 31 Oct 2006 20:13:22 +0000 (20:13 +0000)
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
arch/mips/kernel/smp-mt.c
arch/mips/mips-boards/generic/time.c
include/asm-mips/mipsmtregs.h

index 06b29fa73f56fd66026dce18bf293ac3de9f0dac..2ac19a6cbf68d61d6c2b2f6e93055c8c250e0d08 100644 (file)
@@ -153,6 +153,8 @@ static void __init smp_copy_vpe_config(void)
 
        /* Propagate Config7 */
        write_vpe_c0_config7(read_c0_config7());
+
+       write_vpe_c0_count(read_c0_count());
 }
 
 static unsigned int __init smp_vpe_init(unsigned int tc, unsigned int mvpconf0,
index 659706705005de54b94527910cc4a87e9e68e509..d817c60c5ca50caeb08ff5390517083e707828a5 100644 (file)
@@ -209,6 +209,7 @@ static unsigned int __init estimate_cpu_frequency(void)
 #endif
 #if defined(CONFIG_MIPS_ATLAS) || defined(CONFIG_MIPS_MALTA)
        unsigned long flags;
+       unsigned int start;
 
        local_irq_save(flags);
 
@@ -217,13 +218,13 @@ static unsigned int __init estimate_cpu_frequency(void)
        while (!(CMOS_READ(RTC_REG_A) & RTC_UIP));
 
        /* Start r4k counter. */
-       write_c0_count(0);
+       start = read_c0_count();
 
        /* Read counter exactly on falling edge of update flag */
        while (CMOS_READ(RTC_REG_A) & RTC_UIP);
        while (!(CMOS_READ(RTC_REG_A) & RTC_UIP));
 
-       count = read_c0_count();
+       count = read_c0_count() - start;
 
        /* restore interrupts */
        local_irq_restore(flags);
index f637ce70758fb363b930f18615726c6205d060d7..3e9468f424f43a7ed51b513b4416c23f44ee21ca 100644 (file)
@@ -352,6 +352,8 @@ do {                                                                        \
 #define write_vpe_c0_vpecontrol(val)   mttc0(1, 1, val)
 #define read_vpe_c0_vpeconf0()         mftc0(1, 2)
 #define write_vpe_c0_vpeconf0(val)     mttc0(1, 2, val)
+#define read_vpe_c0_count()            mftc0(9, 0)
+#define write_vpe_c0_count(val)                mttc0(9, 0, val)
 #define read_vpe_c0_status()           mftc0(12, 0)
 #define write_vpe_c0_status(val)       mttc0(12, 0, val)
 #define read_vpe_c0_cause()            mftc0(13, 0)