]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
sparc64: show time stamps from zero
authorPavel Tatashin <pasha.tatashin@oracle.com>
Mon, 12 Jun 2017 20:41:43 +0000 (16:41 -0400)
committerAllen Pais <allen.pais@oracle.com>
Thu, 29 Jun 2017 08:09:43 +0000 (13:39 +0530)
On most platforms, time is shown from the beginning of boot.  This patch is
adding offset to sched_clock() for SPARC, to also show time from 0.

This means we will have one more load, but we saved one in an ealier patch.

Signed-off-by: Pavel Tatashin <pasha.tatashin@oracle.com>
Reviewed-by: Bob Picco <bob.picco@oracle.com>
Reviewed-by: Steven Sistare <steven.sistare@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Orabug: 24401250
Orabug: 25637776

(cherry picked from commit b5dd4d807f0fe7da67c5cc67b2ec681b60e4994b)
Signed-off-by: Pavel Tatashin <pasha.tatashin@oracle.com>
Signed-off-by: Allen Pais <allen.pais@oracle.com>
arch/sparc/kernel/time_64.c

index 39df654b5cd8d6e67665afddb600922f83dd1fad..293b2aff05a6590e0b1ee54809c0f6c60213bb66 100644 (file)
@@ -392,6 +392,7 @@ static struct sparc64_tick_ops hbtick_operations __read_mostly = {
 };
 
 static unsigned long timer_ticks_per_nsec_quotient __read_mostly;
+static unsigned long timer_offset __read_mostly;
 
 unsigned long cmos_regs;
 EXPORT_SYMBOL(cmos_regs);
@@ -802,6 +803,10 @@ void __init time_init(void)
        timer_ticks_per_nsec_quotient =
                clocksource_hz2mult(freq, SPARC64_NSEC_PER_CYC_SHIFT);
 
+       timer_offset = (tick_operations.get_tick()
+                       * timer_ticks_per_nsec_quotient)
+                       >> SPARC64_NSEC_PER_CYC_SHIFT;
+
        clocksource_tick.name = tick_operations.name;
        clocksource_tick.read = clocksource_tick_read;
 
@@ -827,8 +832,9 @@ unsigned long long sched_clock(void)
 {
        unsigned long ticks = tick_operations.get_tick();
 
-       return (ticks * timer_ticks_per_nsec_quotient)
-               >> SPARC64_NSEC_PER_CYC_SHIFT;
+       return ((ticks * timer_ticks_per_nsec_quotient)
+               >> SPARC64_NSEC_PER_CYC_SHIFT)
+               - timer_offset;
 }
 
 int read_current_timer(unsigned long *timer_val)