lkml.org 
[lkml]   [2008]   [Dec]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[RFC][PATCH 1/3] Create arch_gettimeoffset infrastructure for use in the generic timekeeping core.
From
Date
Some arches don't supply their own clocksource. This is mainly the case
in architectures that get their inter-tick times by reading the counter
on their interval timer. Since these timers wrap every tick, they're not
really useful as clocksources. Wrapping them to act like one is possible
but not very efficient. So we provide a callout these arches can
implement for use with the jiffies clocksource to provide finer then
tick granular time.


Signed-off-by: John Stultz <johnstul@us.ibm.com>

diff --git a/include/linux/time.h b/include/linux/time.h
index ce321ac..b0ea1d5 100644
--- a/include/linux/time.h
+++ b/include/linux/time.h
@@ -112,6 +112,21 @@ struct timespec current_kernel_time(void);
#define CURRENT_TIME (current_kernel_time())
#define CURRENT_TIME_SEC ((struct timespec) { get_seconds(), 0 })

+/* Some architectures do not supply their own clocksource.
+ * This is mainly the case in architectures that get their
+ * inter-tick times by reading the counter on their interval
+ * timer. Since these timers wrap every tick, they're not really
+ * useful as clocksources. Wrapping them to act like one is possible
+ * but not very efficient. So we provide a callout these arches
+ * can implement for use with the jiffies clocksource to provide
+ * finer then tick granular time.
+ */
+#ifdef CONFIG_ARCH_USES_GETTIMEOFFSET
+extern u32 arch_gettimeoffset(void);
+#else
+#define arch_gettimeoffset() (0)
+#endif
+
extern void do_gettimeofday(struct timeval *tv);
extern int do_settimeofday(struct timespec *tv);
extern int do_sys_settimeofday(struct timespec *tv, struct timezone *tz);
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index fa05e88..087a783 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -74,6 +74,10 @@ static void clocksource_forward_now(void)
clock->cycle_last = cycle_now;

nsec = cyc2ns(clock, cycle_delta);
+
+ /* If arch requires, add in gettimeoffset() */
+ nsec += arch_gettimeoffset();
+
timespec_add_ns(&xtime, nsec);

nsec = ((s64)cycle_delta * clock->mult_orig) >> clock->shift;
@@ -106,6 +110,9 @@ void getnstimeofday(struct timespec *ts)
/* convert to nanoseconds: */
nsecs = cyc2ns(clock, cycle_delta);

+ /* If arch requires, add in gettimeoffset() */
+ nsecs += arch_gettimeoffset();
+
} while (read_seqretry(&xtime_lock, seq));

timespec_add_ns(ts, nsecs);



\
 
 \ /
  Last update: 2008-12-09 04:53    [W:0.051 / U:0.696 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site