From patchwork Wed Oct 6 08:38:55 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas.Gaer@baslerweb.com X-Patchwork-Id: 235311 Received: from bear.ext.ti.com (bear.ext.ti.com [192.94.94.41]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o968enpq029775 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 6 Oct 2010 08:41:10 GMT Received: from dlep34.itg.ti.com ([157.170.170.115]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id o968dMtN005493 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 6 Oct 2010 03:39:22 -0500 Received: from linux.omap.com (localhost [127.0.0.1]) by dlep34.itg.ti.com (8.13.7/8.13.7) with ESMTP id o968dKsB003514; Wed, 6 Oct 2010 03:39:21 -0500 (CDT) Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id 34BAB80627; Wed, 6 Oct 2010 03:39:20 -0500 (CDT) X-Original-To: Davinci-linux-open-source@linux.davincidsp.com Delivered-To: Davinci-linux-open-source@linux.davincidsp.com Received: from dflp53.itg.ti.com (dflp53.itg.ti.com [128.247.5.6]) by linux.omap.com (Postfix) with ESMTP id 51A6380626 for ; Wed, 6 Oct 2010 03:39:16 -0500 (CDT) Received: from medina.ext.ti.com (localhost [127.0.0.1]) by dflp53.itg.ti.com (8.13.8/8.13.8) with ESMTP id o968dFx2029280 for ; Wed, 6 Oct 2010 03:39:15 -0500 (CDT) Received: from psmtp.com (na3sys009amx180.postini.com [74.125.149.161]) by medina.ext.ti.com (8.13.7/8.13.7) with SMTP id o968dFce028585 for ; Wed, 6 Oct 2010 03:39:15 -0500 Received: from source ([80.156.24.166]) by na3sys009amx180.postini.com ([74.125.148.10]) with SMTP; Wed, 06 Oct 2010 08:39:15 GMT Received: from mail.baslerweb.com ([80.156.24.162]) by mail01-out.baslerweb.com with ESMTP; 06 Oct 2010 10:39:47 +0200 Received: (from smtpd@127.0.0.1) by mail.baslerweb.com (8.13.4/8.13.4) id o968dBsW025184; Wed, 6 Oct 2010 10:39:11 +0200 Received: from unknown [80.156.24.166] by gateway id /processing/kw8CSDSj; Wed Oct 06 10:39:11 2010 Received: from unknown (HELO AHR075S.basler.corp) ([172.16.20.75]) by mail01-out.baslerweb.com with ESMTP; 06 Oct 2010 10:39:36 +0200 Received: from rd-ipcam.basler.corp ([172.16.13.131]) by AHR075S.basler.corp with Microsoft SMTPSVC(6.0.3790.4675); Wed, 6 Oct 2010 10:39:02 +0200 From: Andreas.Gaer@baslerweb.com To: Davinci-linux-open-source@linux.davincidsp.com Date: Wed, 6 Oct 2010 10:38:55 +0200 Message-Id: <1286354335-31819-1-git-send-email-Andreas.Gaer@baslerweb.com> X-Mailer: git-send-email 1.7.2.2 X-OriginalArrivalTime: 06 Oct 2010 08:39:02.0996 (UTC) FILETIME=[EDF09140:01CB6531] X-SecurE-Mail-Gateway: Version: 5.00.3.1 (smtpd: 6.53.8.7) Date: 20101006083911Z Subject: [PATCH] davinci: Implement sched_clock() X-pstn-neptune: 0/0/0.00/0 X-pstn-levels: (S:82.09003/99.90000 CV:99.9000 FC:95.5390 LC:95.5390 R:95.9108 P:95.9108 M:97.0282 C:98.6951 ) X-pstn-settings: 2 (0.5000:0.5000) s cv gt3 gt2 gt1 r p m c X-pstn-addresses: from [db-null] Cc: linux-arm-kernel@lists.infradead.org X-BeenThere: davinci-linux-open-source@linux.davincidsp.com X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: davinci-linux-open-source-bounces@linux.davincidsp.com Errors-To: davinci-linux-open-source-bounces@linux.davincidsp.com X-Greylist: Sender succeeded STARTTLS authentication, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Wed, 06 Oct 2010 08:41:10 +0000 (UTC) diff --git a/arch/arm/mach-davinci/time.c b/arch/arm/mach-davinci/time.c index 0f21c36..5d1eea0 100644 --- a/arch/arm/mach-davinci/time.c +++ b/arch/arm/mach-davinci/time.c @@ -272,15 +272,36 @@ static cycle_t read_cycles(struct clocksource *cs) return (cycles_t)timer32_read(t); } +/* + * Kernel assumes that sched_clock can be called early but may not have + * things ready yet. + */ +static cycle_t read_dummy(struct clocksource *cs) +{ + return 0; +} + + static struct clocksource clocksource_davinci = { .rating = 300, - .read = read_cycles, + .read = read_dummy, .mask = CLOCKSOURCE_MASK(32), .shift = 24, .flags = CLOCK_SOURCE_IS_CONTINUOUS, }; /* + * Overwrite weak default sched_clock with something more precise + */ +unsigned long long notrace sched_clock(void) +{ + const cycle_t cyc = clocksource_davinci.read(&clocksource_davinci); + + return clocksource_cyc2ns(cyc, clocksource_davinci.mult, + clocksource_davinci.shift); +} + +/* * clockevent */ static int davinci_set_next_event(unsigned long cycles, @@ -377,6 +398,7 @@ static void __init davinci_timer_init(void) davinci_clock_tick_rate = clk_get_rate(timer_clk); /* setup clocksource */ + clocksource_davinci.read = read_cycles; clocksource_davinci.name = id_to_name[clocksource_id]; clocksource_davinci.mult = clocksource_khz2mult(davinci_clock_tick_rate/1000,