From patchwork Thu Apr 18 19:30:09 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 2462271 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) by patchwork2.kernel.org (Postfix) with ESMTP id 35D61DF2E5 for ; Thu, 18 Apr 2013 19:30:59 +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 1USuXX-0001r9-GE; Thu, 18 Apr 2013 19:30:39 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1USuXS-0006j1-OC; Thu, 18 Apr 2013 19:30:34 +0000 Received: from mail-vb0-x22a.google.com ([2607:f8b0:400c:c02::22a]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1USuXH-0006hq-NE for linux-arm-kernel@lists.infradead.org; Thu, 18 Apr 2013 19:30:25 +0000 Received: by mail-vb0-f42.google.com with SMTP id p12so2892019vbe.29 for ; Thu, 18 Apr 2013 12:30:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer; bh=ukizSCHggwpBm4lCtb8nfGHAmZZkDBh3b4V/m4ru82A=; b=hV10bvaS0gV97AKNMXHna+S0AKS4tmwRYis81sXPeVc8gv3iECfaEeUrDmqZymvQIG ORFUbdYC5nohb8NXVZs4+ReO74javv3OMQbWr7zZZGBcA1Rm7HWTgGuwGDBafasMA2Gg JHsVP2wkjLUD7APJL1YZ220JE41pR6NwiNCwlg2bfXgbEn02wKVcHNGYcBF4ge6Zqxm0 Jw1cgAWYTsK2gaLxDdnLtlG0klGl2GRaRhlggl51jN78OKkqLEzAVYcfJ6qkGnrcUZh9 UXD9uQbyP+zqiPWG59pju55I9VXNe1tAAQ4Se+mWfL1k44+vZrI7VljDSorD1Pe5PVr+ /dVA== X-Received: by 10.220.119.200 with SMTP id a8mr9252285vcr.38.1366313418769; Thu, 18 Apr 2013 12:30:18 -0700 (PDT) Received: from rob-laptop.calxeda.com ([173.226.190.126]) by mx.google.com with ESMTPS id u20sm10937613vdt.10.2013.04.18.12.30.16 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 18 Apr 2013 12:30:18 -0700 (PDT) From: Rob Herring To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] clocksource: arm_arch_timer: unify sched_clock init Date: Thu, 18 Apr 2013 14:30:09 -0500 Message-Id: <1366313410-16692-1-git-send-email-robherring2@gmail.com> X-Mailer: git-send-email 1.7.10.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130418_153023_826725_1E53182B X-CRM114-Status: GOOD ( 15.33 ) X-Spam-Score: -1.8 (-) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-1.8 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (robherring2[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit (robherring2[at]gmail.com) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: Russell King , Catalin Marinas , Will Deacon , Rob Herring , arm@kernel.org, John Stultz , Thomas Gleixner 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 From: Rob Herring In preparation to fix initial time and suspend/resume handling, unify the sched_clock init and implementation for arch timer on arm and arm64. Signed-off-by: Rob Herring Cc: Russell King Cc: Catalin Marinas Cc: Will Deacon Cc: John Stultz Cc: Thomas Gleixner Cc: Stephen Boyd Acked-by: Catalin Marinas --- arch/arm/kernel/arch_timer.c | 12 ------------ arch/arm64/kernel/time.c | 10 ---------- drivers/clocksource/arm_arch_timer.c | 14 ++++++++++++++ include/clocksource/arm_arch_timer.h | 1 + 4 files changed, 15 insertions(+), 22 deletions(-) diff --git a/arch/arm/kernel/arch_timer.c b/arch/arm/kernel/arch_timer.c index 59dcdce..df6825e 100644 --- a/arch/arm/kernel/arch_timer.c +++ b/arch/arm/kernel/arch_timer.c @@ -22,13 +22,6 @@ static unsigned long arch_timer_read_counter_long(void) return arch_timer_read_counter(); } -static u32 sched_clock_mult __read_mostly; - -static unsigned long long notrace arch_timer_sched_clock(void) -{ - return arch_timer_read_counter() * sched_clock_mult; -} - static struct delay_timer arch_delay_timer; static void __init arch_timer_delay_timer_register(void) @@ -48,11 +41,6 @@ int __init arch_timer_arch_init(void) arch_timer_delay_timer_register(); - /* Cache the sched_clock multiplier to save a divide in the hot path. */ - sched_clock_mult = NSEC_PER_SEC / arch_timer_rate; sched_clock_func = arch_timer_sched_clock; - pr_info("sched_clock: ARM arch timer >56 bits at %ukHz, resolution %uns\n", - arch_timer_rate / 1000, sched_clock_mult); - return 0; } diff --git a/arch/arm64/kernel/time.c b/arch/arm64/kernel/time.c index a551f88..3a369aa 100644 --- a/arch/arm64/kernel/time.c +++ b/arch/arm64/kernel/time.c @@ -61,13 +61,6 @@ unsigned long profile_pc(struct pt_regs *regs) EXPORT_SYMBOL(profile_pc); #endif -static u64 sched_clock_mult __read_mostly; - -unsigned long long notrace sched_clock(void) -{ - return arch_timer_read_counter() * sched_clock_mult; -} - int read_current_timer(unsigned long *timer_value) { *timer_value = arch_timer_read_counter(); @@ -84,9 +77,6 @@ void __init time_init(void) if (!arch_timer_rate) panic("Unable to initialise architected timer.\n"); - /* Cache the sched_clock multiplier to save a divide in the hot path. */ - sched_clock_mult = NSEC_PER_SEC / arch_timer_rate; - /* Calibrate the delay loop directly */ lpj_fine = arch_timer_rate / HZ; } diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c index 122ff05..17ed8e4 100644 --- a/drivers/clocksource/arm_arch_timer.c +++ b/drivers/clocksource/arm_arch_timer.c @@ -266,6 +266,15 @@ static struct notifier_block arch_timer_cpu_nb __cpuinitdata = { .notifier_call = arch_timer_cpu_notify, }; +static u64 sched_clock_mult __read_mostly; + +unsigned long long notrace arch_timer_sched_clock(void) +{ + return arch_timer_read_counter() * sched_clock_mult; +} +unsigned long long sched_clock(void) \ + __attribute__((weak, alias("arch_timer_sched_clock"))); + static int __init arch_timer_register(void) { int err; @@ -318,6 +327,11 @@ static int __init arch_timer_register(void) /* Immediately configure the timer on the boot CPU */ arch_timer_setup(this_cpu_ptr(arch_timer_evt)); + /* Cache the sched_clock multiplier to save a divide in the hot path. */ + sched_clock_mult = NSEC_PER_SEC / arch_timer_rate; + pr_info("sched_clock: ARM arch timer >56 bits at %ukHz, resolution %lluns\n", + arch_timer_rate / 1000, sched_clock_mult); + return 0; out_free_irq: diff --git a/include/clocksource/arm_arch_timer.h b/include/clocksource/arm_arch_timer.h index e6c9c4c..ded7c77 100644 --- a/include/clocksource/arm_arch_timer.h +++ b/include/clocksource/arm_arch_timer.h @@ -34,6 +34,7 @@ extern u32 arch_timer_get_rate(void); extern u64 (*arch_timer_read_counter)(void); extern struct timecounter *arch_timer_get_timecounter(void); +extern unsigned long long notrace arch_timer_sched_clock(void); #else