LOCAL \ clocksource: arch_timer: Use physical cnt instead of virtual one.
authorJonghwa Lee <jonghwa3.lee@samsung.com>
Fri, 7 Aug 2015 07:42:26 +0000 (16:42 +0900)
committerSeung-Woo Kim <sw0312.kim@samsung.com>
Wed, 14 Dec 2016 04:47:04 +0000 (13:47 +0900)
This fixes unsynchronized timestamp on kernel log which is occured by
unitialized virtual counter of each CPU. Even ARM commented that to use
virtual counter is mandatory on ARMv8, but it failed on EXYNOS5433.
Let it uses physical counter instead of virtual counter on EXYNOS5433.

Signed-off-by: Jonghwa Lee <jonghwa3.lee@samsung.com>
arch/arm64/include/asm/arch_timer.h
drivers/clocksource/arm_arch_timer.c

index fbe0ca3..effff73 100644 (file)
@@ -105,6 +105,11 @@ static inline void arch_timer_set_cntkctl(u32 cntkctl)
        asm volatile("msr       cntkctl_el1, %0" : : "r" (cntkctl));
 }
 
+/* FIXME :
+ * For the case which firmware doesn't initialize virtual counter,
+ * it recalls the way of reading physical counter.
+ */
+#if 0
 static inline u64 arch_counter_get_cntpct(void)
 {
        /*
@@ -113,6 +118,16 @@ static inline u64 arch_counter_get_cntpct(void)
        BUG();
        return 0;
 }
+#endif
+static inline u64 arch_counter_get_cntpct(void)
+{
+       u64 cval;
+
+       isb();
+       asm volatile("mrs %0, cntpct_el0" : "=r" (cval));
+
+       return cval;
+}
 
 static inline u64 arch_counter_get_cntvct(void)
 {
index 0aa135d..7c67e63 100644 (file)
@@ -468,7 +468,7 @@ static void __init arch_counter_register(unsigned type)
 
        /* Register the CP15 based counter if we have one */
        if (type & ARCH_CP15_TIMER) {
-               if (IS_ENABLED(CONFIG_ARM64) || arch_timer_use_virtual)
+               if (arch_timer_use_virtual)
                        arch_timer_read_counter = arch_counter_get_cntvct;
                else
                        arch_timer_read_counter = arch_counter_get_cntpct;
@@ -737,6 +737,15 @@ static void __init arch_timer_of_init(struct device_node *np)
 
        arch_timer_c3stop = !of_property_read_bool(np, "always-on");
 
+       /* FIXME :
+        * ARM recommended to use vcnt for clocksource of ARMv8.
+        * However, On Exynos5433, it seemed that they aren't intialized
+        * properly, each of counters' value are not synchronized.
+        * For Exynos5433, let it uses pcnt for representive clock source.
+        */
+       if (of_machine_is_compatible("samsung,exynos5433"))
+               arch_timer_use_virtual = false;
+
        /*
         * If we cannot rely on firmware initializing the timer registers then
         * we should use the physical timers instead.