Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1764216AbXHONA0 (ORCPT ); Wed, 15 Aug 2007 09:00:26 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1761115AbXHOMzH (ORCPT ); Wed, 15 Aug 2007 08:55:07 -0400 Received: from mx1.redhat.com ([66.187.233.31]:56298 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755191AbXHOMzD (ORCPT ); Wed, 15 Aug 2007 08:55:03 -0400 From: Glauber de Oliveira Costa To: linux-kernel@vger.kernel.org Cc: akpm@linux-foundation.org, rusty@rustcorp.com.au, ak@suse.de, mingo@elte.hu, chrisw@sous-sol.org, jeremy@goop.org, avi@qumranet.com, anthony@codemonkey.ws, virtualization@lists.linux-foundation.org, lguest@ozlabs.org, glommer@gmail.com, Glauber de Oliveira Costa , Steven Rostedt Subject: [PATCH 19/25][V3] time-related functions paravirt provisions Date: Wed, 15 Aug 2007 09:49:39 -0300 Message-Id: <11871824081337-git-send-email-gcosta@redhat.com> X-Mailer: git-send-email 1.5.0.6 In-Reply-To: <11871823991803-git-send-email-gcosta@redhat.com> References: <11871821854176-git-send-email-gcosta@redhat.com> <1187182197314-git-send-email-gcosta@redhat.com> <11871822062386-git-send-email-gcosta@redhat.com> <11871822163867-git-send-email-gcosta@redhat.com> <11871822244170-git-send-email-gcosta@redhat.com> <11871822342754-git-send-email-gcosta@redhat.com> <11871822421713-git-send-email-gcosta@redhat.com> <1187182253740-git-send-email-gcosta@redhat.com> <1187182268408-git-send-email-gcosta@redhat.com> <1187182282913-git-send-email-gcosta@redhat.com> <11871822951747-git-send-email-gcosta@redhat.com> <11871823042011-git-send-email-gcosta@redhat.com> <11871823151789-git-send-email-gcosta@redhat.com> <11871823273810-git-send-email-gcosta@redhat.com> <11871823373106-git-send-email-gcosta@redhat.com> <11871823673236-git-send-email-gcosta@redhat.com> <11871823782610-git-send-email-gcosta@redhat.com> <11871823892519-git-send-email-gcosta@redhat.com> <11871823991803-git-send-email-gcosta@redhat.com> Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3850 Lines: 150 This patch add provisions for time related functions so they can be later replaced by paravirt versions. it basically encloses {g,s}et_wallclock inside the already existent functions update_persistent_clock and read_persistent_clock, and defines {s,g}et_wallclock to the core of such functions. The timer interrupt setup also have to be replaced. The job is done by time_init_hook(). Signed-off-by: Glauber de Oliveira Costa Signed-off-by: Steven Rostedt --- arch/x86_64/kernel/time.c | 37 +++++++++++++++++++++++++------------ include/asm-x86_64/time.h | 18 ++++++++++++++++++ 2 files changed, 43 insertions(+), 12 deletions(-) diff --git a/arch/x86_64/kernel/time.c b/arch/x86_64/kernel/time.c index 6d48a4e..29fcd91 100644 --- a/arch/x86_64/kernel/time.c +++ b/arch/x86_64/kernel/time.c @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -82,18 +83,12 @@ EXPORT_SYMBOL(profile_pc); * sheet for details. */ -static int set_rtc_mmss(unsigned long nowtime) +int do_set_rtc_mmss(unsigned long nowtime) { int retval = 0; int real_seconds, real_minutes, cmos_minutes; unsigned char control, freq_select; -/* - * IRQs are disabled when we're called from the timer interrupt, - * no need for spin_lock_irqsave() - */ - - spin_lock(&rtc_lock); /* * Tell the clock it's being set and stop it. @@ -143,14 +138,22 @@ static int set_rtc_mmss(unsigned long nowtime) CMOS_WRITE(control, RTC_CONTROL); CMOS_WRITE(freq_select, RTC_FREQ_SELECT); - spin_unlock(&rtc_lock); - return retval; } int update_persistent_clock(struct timespec now) { - return set_rtc_mmss(now.tv_sec); + int retval; + +/* + * IRQs are disabled when we're called from the timer interrupt, + * no need for spin_lock_irqsave() + */ + spin_lock(&rtc_lock); + retval = set_wallclock(now.tv_sec); + spin_unlock(&rtc_lock); + + return retval; } void main_timer_handler(void) @@ -195,7 +198,7 @@ static irqreturn_t timer_interrupt(int irq, void *dev_id) return IRQ_HANDLED; } -unsigned long read_persistent_clock(void) +unsigned long do_get_cmos_time(void) { unsigned int year, mon, day, hour, min, sec; unsigned long flags; @@ -246,6 +249,11 @@ unsigned long read_persistent_clock(void) return mktime(year, mon, day, hour, min, sec); } +unsigned long read_persistent_clock(void) +{ + return get_wallclock(); +} + /* calibrate_cpu is used on systems with fixed rate TSCs to determine * processor frequency */ #define TICK_COUNT 100000000 @@ -365,6 +373,11 @@ static struct irqaction irq0 = { .name = "timer" }; +inline void time_init_hook() +{ + setup_irq(0, &irq0); +} + void __init time_init(void) { if (nohpet) @@ -403,7 +416,7 @@ void __init time_init(void) cpu_khz / 1000, cpu_khz % 1000); init_tsc_clocksource(); - setup_irq(0, &irq0); + do_time_init(); } /* diff --git a/include/asm-x86_64/time.h b/include/asm-x86_64/time.h new file mode 100644 index 0000000..9a72355 --- /dev/null +++ b/include/asm-x86_64/time.h @@ -0,0 +1,18 @@ +#ifndef _ASM_X86_64_TIME_H +#define _ASM_X86_64_TIME_H + +inline void time_init_hook(void); +unsigned long do_get_cmos_time(void); +int do_set_rtc_mmss(unsigned long nowtime); + +#ifdef CONFIG_PARAVIRT +#include +#else /* !CONFIG_PARAVIRT */ + +#define get_wallclock() do_get_cmos_time() +#define set_wallclock(x) do_set_rtc_mmss(x) +#define do_time_init() time_init_hook() + +#endif /* CONFIG_PARAVIRT */ + +#endif -- 1.4.4.2 - 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/