From patchwork Tue Oct 5 11:38:13 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: 232241 Received: from devils.ext.ti.com (devils.ext.ti.com [198.47.26.153]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o95BeCnN000566 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 5 Oct 2010 11:40:33 GMT Received: from dlep33.itg.ti.com ([157.170.170.112]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id o95Bcbk4002509 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 5 Oct 2010 06:38:37 -0500 Received: from linux.omap.com (localhost [127.0.0.1]) by dlep33.itg.ti.com (8.13.7/8.13.7) with ESMTP id o95BcaIk016755; Tue, 5 Oct 2010 06:38:36 -0500 (CDT) Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id 63F9080627; Tue, 5 Oct 2010 06:38:36 -0500 (CDT) X-Original-To: Davinci-linux-open-source@linux.davincidsp.com Delivered-To: Davinci-linux-open-source@linux.davincidsp.com Received: from dflp51.itg.ti.com (dflp51.itg.ti.com [128.247.22.94]) by linux.omap.com (Postfix) with ESMTP id C397B80626 for ; Tue, 5 Oct 2010 06:38:34 -0500 (CDT) Received: from white.ext.ti.com (localhost [127.0.0.1]) by dflp51.itg.ti.com (8.13.7/8.13.7) with ESMTP id o95BcYMG005498 for ; Tue, 5 Oct 2010 06:38:34 -0500 (CDT) Received: from psmtp.com (na3sys009amx166.postini.com [74.125.149.92]) by white.ext.ti.com (8.13.7/8.13.7) with SMTP id o95BcXCN032633 for ; Tue, 5 Oct 2010 06:38:33 -0500 Received: from source ([80.156.24.166]) by na3sys009amx166.postini.com ([74.125.148.10]) with SMTP; Tue, 05 Oct 2010 04:38:33 PDT Received: from mail.baslerweb.com ([80.156.24.162]) by mail01-out.baslerweb.com with ESMTP; 05 Oct 2010 13:39:05 +0200 Received: (from smtpd@127.0.0.1) by mail.baslerweb.com (8.13.4/8.13.4) id o95BcU6V024380 for ; Tue, 5 Oct 2010 13:38:30 +0200 Received: from unknown [80.156.24.166] by gateway id /processing/kwds6mWP; Tue Oct 05 13:38:30 2010 Received: from unknown (HELO AHR075S.basler.corp) ([172.16.20.75]) by mail01-out.baslerweb.com with ESMTP; 05 Oct 2010 13:39:03 +0200 Received: from rd-ipcam.basler.corp ([172.16.13.131]) by AHR075S.basler.corp with Microsoft SMTPSVC(6.0.3790.4675); Tue, 5 Oct 2010 13:38:28 +0200 From: Andreas.Gaer@baslerweb.com To: Davinci-linux-open-source@linux.davincidsp.com Date: Tue, 5 Oct 2010 13:38:13 +0200 Message-Id: <1286278693-21122-1-git-send-email-Andreas.Gaer@baslerweb.com> X-Mailer: git-send-email 1.7.2.2 X-OriginalArrivalTime: 05 Oct 2010 11:38:28.0755 (UTC) FILETIME=[D46B4630:01CB6481] X-SecurE-Mail-Gateway: Version: 5.00.3.1 (smtpd: 6.53.8.7) Date: 20101005113830Z Subject: [PATCH] davinci: Implement sched_clock() X-pstn-neptune: 0/0/0.00/0 X-pstn-levels: (S:85.07555/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] 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]); Tue, 05 Oct 2010 11:40:33 +0000 (UTC) diff --git a/arch/arm/mach-davinci/time.c b/arch/arm/mach-davinci/time.c index 0f21c36..9facd6f 100644 --- a/arch/arm/mach-davinci/time.c +++ b/arch/arm/mach-davinci/time.c @@ -272,15 +272,35 @@ 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 +397,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,