From patchwork Sun May 26 12:12:47 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baruch Siach X-Patchwork-Id: 2615251 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) by patchwork1.kernel.org (Postfix) with ESMTP id AC9623FD4E for ; Sun, 26 May 2013 12:15:23 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UgZqm-0003lP-Bp; Sun, 26 May 2013 12:15:00 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UgZqf-0004Tz-PH; Sun, 26 May 2013 12:14:53 +0000 Received: from tango.tkos.co.il ([62.219.50.35]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UgZqU-0004SQ-C4 for linux-arm-kernel@lists.infradead.org; Sun, 26 May 2013 12:14:43 +0000 Received: from tarshish.tkos.co.il (80.179.12.157.static.012.net.il [80.179.12.157]) (authenticated bits=0) by tango.tkos.co.il (8.14.4/8.12.11) with ESMTP id r4QCDSOx004382; Sun, 26 May 2013 15:13:36 +0300 From: Baruch Siach To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 2/2] clocksource: dw_apb: allow build for architectures other than arm Date: Sun, 26 May 2013 15:12:47 +0300 Message-Id: <1369570367-994-2-git-send-email-baruch@tkos.co.il> X-Mailer: git-send-email 1.7.10.4 X-Spam-Level: -2.312 () BAYES_00 X-Scanned-By: MIMEDefang 2.62 on 62.219.50.35 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130526_081442_986931_6BF22EC2 X-CRM114-Status: UNSURE ( 9.76 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -3.0 (---) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-3.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -1.1 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Baruch Siach , Peter Zijlstra , Ingo Molnar , John Stultz , Jamie Iles , Thomas Gleixner , Dinh Nguyen X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org ARM is the only architecture providing sched_clock.h and setup_sched_clock(). Implement sched_clock() for use by other architectures. Cc: Ingo Molnar Cc: Peter Zijlstra Cc: John Stultz Cc: Thomas Gleixner Cc: Jamie Iles Cc: Dinh Nguyen Signed-off-by: Baruch Siach --- arch/arm/Kconfig | 1 + drivers/clocksource/Kconfig | 3 +++ drivers/clocksource/dw_apb_timer_of.c | 18 ++++++++++++++++++ 3 files changed, 22 insertions(+) diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 1cacda4..7489604 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -47,6 +47,7 @@ config ARM select HAVE_OPROFILE if (HAVE_PERF_EVENTS) select HAVE_PERF_EVENTS select HAVE_REGS_AND_STACK_ACCESS_API + select HAVE_SETUP_SCHED_CLOCK select HAVE_SYSCALL_TRACEPOINTS select HAVE_UID16 select KTIME_SCALAR diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig index e507ab7..0fd6d13 100644 --- a/drivers/clocksource/Kconfig +++ b/drivers/clocksource/Kconfig @@ -1,3 +1,6 @@ +config HAVE_SETUP_SCHED_CLOCK + bool + config CLKSRC_OF bool diff --git a/drivers/clocksource/dw_apb_timer_of.c b/drivers/clocksource/dw_apb_timer_of.c index 5a61ebc..9fdb4d3 100644 --- a/drivers/clocksource/dw_apb_timer_of.c +++ b/drivers/clocksource/dw_apb_timer_of.c @@ -21,7 +21,11 @@ #include #include +#ifdef CONFIG_HAVE_SETUP_SCHED_CLOCK #include +#else +#include +#endif static void timer_get_base_and_rate(struct device_node *np, void __iomem **base, u32 *rate) @@ -73,6 +77,9 @@ static void add_clocksource(struct device_node *source_timer) } static void __iomem *sched_io_base; +#ifndef CONFIG_HAVE_SETUP_SCHED_CLOCK +static u64 sched_clock_mult __read_mostly; +#endif static u32 read_sched_clock(void) { @@ -97,7 +104,11 @@ static void init_sched_clock(void) timer_get_base_and_rate(sched_timer, &sched_io_base, &rate); of_node_put(sched_timer); +#ifdef CONFIG_HAVE_SETUP_SCHED_CLOCK setup_sched_clock(read_sched_clock, 32, rate); +#else + sched_clock_mult = NSEC_PER_SEC / rate; +#endif } static const struct of_device_id osctimer_ids[] __initconst = { @@ -124,3 +135,10 @@ void __init dw_apb_timer_init(void) init_sched_clock(); } + +#ifndef CONFIG_HAVE_SETUP_SCHED_CLOCK +unsigned long long notrace sched_clock() +{ + return read_sched_clock() * sched_clock_mult; +} +#endif