Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757456AbZDOBeZ (ORCPT ); Tue, 14 Apr 2009 21:34:25 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753109AbZDOBeQ (ORCPT ); Tue, 14 Apr 2009 21:34:16 -0400 Received: from e33.co.us.ibm.com ([32.97.110.151]:40382 "EHLO e33.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752762AbZDOBeP (ORCPT ); Tue, 14 Apr 2009 21:34:15 -0400 Subject: [RESEND][PATCH 1/2] Create arch_gettimeoffset infrastructure for use in the generic timekeeping core. From: john stultz To: lkml Cc: Andrew Morton , rmk+lkml@arm.linux.org.uk, cooloney@kernel.org, starvik@axis.com, takata@linux-m32r.org, geert@linux-m68k.org, Roman Zippel , lethal@linux-sh.org, Magnus Damm , wli@holomorphy.com, rth@twiddle.net In-Reply-To: <1239759163.6064.25.camel@localhost> References: <1239759163.6064.25.camel@localhost> Content-Type: text/plain Date: Tue, 14 Apr 2009 18:34:11 -0700 Message-Id: <1239759251.6064.27.camel@localhost> Mime-Version: 1.0 X-Mailer: Evolution 2.24.3 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2713 Lines: 72 Andrew, all, 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. Please consider for inclusion into -mm in preparation for 2.6.31. Signed-off-by: John Stultz diff --git a/include/linux/time.h b/include/linux/time.h index 242f624..01145d5 100644 --- a/include/linux/time.h +++ b/include/linux/time.h @@ -113,6 +113,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 900f1b6..45d777f 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -77,6 +77,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; @@ -111,6 +115,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); -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/