Skip to contentSkip to conversation

sparc64: show time stamps from zero

PATCH Superseded Pavel Tatashin 1 participant 1 message Jun 12, 2017 SPARC + UltraSPARC (sparc/sparc64)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 3/8 sparc64: show time stamps from zero

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.

---
 arch/sparc/kernel/time_64.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
arch/sparc/kernel/time_64.c +8 -2
index 6724bcb..5f53b74 100644
@@ -392,6 +392,7 @@ static int hbtick_add_compare(unsigned long adj)
 };
 
 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);
@@ -786,6 +787,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;
 
@@ -813,8 +818,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)
Signature · 1 line
1.7.1