From patchwork Wed Dec 14 04:31:28 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Turquette X-Patchwork-Id: 5669 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 0749023E01 for ; Wed, 14 Dec 2011 04:34:59 +0000 (UTC) Received: from mail-ey0-f180.google.com (mail-ey0-f180.google.com [209.85.215.180]) by fiordland.canonical.com (Postfix) with ESMTP id F1A4AA183B5 for ; Wed, 14 Dec 2011 04:34:58 +0000 (UTC) Received: by mail-ey0-f180.google.com with SMTP id k10so61148eaa.11 for ; Tue, 13 Dec 2011 20:34:58 -0800 (PST) Received: by 10.205.127.12 with SMTP id gy12mr204781bkc.108.1323837298799; Tue, 13 Dec 2011 20:34:58 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.205.129.2 with SMTP id hg2cs101269bkc; Tue, 13 Dec 2011 20:34:58 -0800 (PST) Received: by 10.68.190.232 with SMTP id gt8mr1090914pbc.61.1323837296589; Tue, 13 Dec 2011 20:34:56 -0800 (PST) Received: from na3sys009aog103.obsmtp.com ([74.125.149.71]) by mx.google.com with SMTP id j1si5064188pbi.221.2011.12.13.20.34.52 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 13 Dec 2011 20:34:56 -0800 (PST) Received-SPF: pass (google.com: domain of mturquette@ti.com designates 74.125.149.71 as permitted sender) client-ip=74.125.149.71; Authentication-Results: mx.google.com; spf=pass (google.com: domain of mturquette@ti.com designates 74.125.149.71 as permitted sender) smtp.mail=mturquette@ti.com Received: from mail-yx0-f170.google.com ([209.85.213.170]) (using TLSv1) by na3sys009aob103.postini.com ([74.125.148.12]) with SMTP ID DSNKTugnbB3QUKCCRUxmgIhGBcN/RayabjLf@postini.com; Tue, 13 Dec 2011 20:34:56 PST Received: by mail-yx0-f170.google.com with SMTP id l6so344944yen.29 for ; Tue, 13 Dec 2011 20:34:52 -0800 (PST) Received: by 10.236.123.108 with SMTP id u72mr8609010yhh.45.1323837292135; Tue, 13 Dec 2011 20:34:52 -0800 (PST) Received: from localhost.localdomain (dragon.ti.com. [192.94.94.33]) by mx.google.com with ESMTPS id v48sm2145601yhk.6.2011.12.13.20.34.48 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 13 Dec 2011 20:34:51 -0800 (PST) From: Mike Turquette To: linux@arm.linux.org.uk Cc: linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org, khilman@ti.com, tony@atomide.com, b-cousson@ti.com, rnayak@ti.com, jeremy.kerr@canonical.com, paul@pwsan.com, broonie@opensource.wolfsonmicro.com, tglx@linutronix.de, linus.walleij@stericsson.com, amit.kucheria@linaro.org, dsaxena@linaro.org, patches@linaro.org, linaro-dev@lists.linaro.org, grant.likely@secretlab.ca, sboyd@quicinc.com, shawn.guo@freescale.com, skannan@quicinc.com, magnus.damm@gmail.com, arnd.bergmann@linaro.org, eric.miao@linaro.org, richard.zhao@linaro.org, mturquette@linaro.org, mturquette@ti.com, andrew@lunn.ch Subject: [PATCH 6/6] HACK: arm: reprogram twd based on clk notifier Date: Tue, 13 Dec 2011 20:31:28 -0800 Message-Id: <1323837088-2469-7-git-send-email-mturquette@ti.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1323837088-2469-1-git-send-email-mturquette@ti.com> References: <1323837088-2469-1-git-send-email-mturquette@ti.com> From: Mike Turquette As a proof-of-concept, convert the existing smp_twd code to use clk notifiers in place of CPUfreq notifiers. This works out nicely for Cortex-A9 MPcore designs that scale all CPUs at the same frequency. For chips which can scale frequency independently this change makes less sense. (but I don't know how they were doing it in the first place...) The primary purpose behind this change is to test the new clk notifier code. If you find it useful beyond that, please let me know! Not-signed-off-by: Mike Turquette --- arch/arm/kernel/smp_twd.c | 40 ++++++++++++++++++++-------------------- 1 files changed, 20 insertions(+), 20 deletions(-) diff --git a/arch/arm/kernel/smp_twd.c b/arch/arm/kernel/smp_twd.c index 92dbd80..8bdbaad 100644 --- a/arch/arm/kernel/smp_twd.c +++ b/arch/arm/kernel/smp_twd.c @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include @@ -95,51 +94,45 @@ void twd_timer_stop(struct clock_event_device *clk) disable_percpu_irq(clk->irq); } -#ifdef CONFIG_CPU_FREQ - /* * Updates clockevent frequency when the cpu frequency changes. * Called on the cpu that is changing frequency with interrupts disabled. */ -static void twd_update_frequency(void *data) +static void twd_update_frequency(void *new_rate) { - twd_timer_rate = clk_get_rate(twd_clk); + unsigned long *rate = new_rate; - clockevents_update_freq(__get_cpu_var(twd_ce), twd_timer_rate); + clockevents_update_freq(__get_cpu_var(twd_ce), *rate/1000); } -static int twd_cpufreq_transition(struct notifier_block *nb, - unsigned long state, void *data) +static int twd_rate_change(struct notifier_block *nb, + unsigned long flags, void *data) { - struct cpufreq_freqs *freqs = data; + struct clk_notifier_data *cnd = data; /* * The twd clock events must be reprogrammed to account for the new * frequency. The timer is local to a cpu, so cross-call to the * changing cpu. */ - if (state == CPUFREQ_POSTCHANGE || state == CPUFREQ_RESUMECHANGE) - smp_call_function_single(freqs->cpu, twd_update_frequency, - NULL, 1); + if (flags == POST_RATE_CHANGE) + smp_call_function(twd_update_frequency, (void *)&cnd->new_rate, 1); return NOTIFY_OK; } -static struct notifier_block twd_cpufreq_nb = { - .notifier_call = twd_cpufreq_transition, +static struct notifier_block twd_clk_nb = { + .notifier_call = twd_rate_change, }; -static int twd_cpufreq_init(void) +static int twd_clk_init(void) { if (!IS_ERR_OR_NULL(twd_clk)) - return cpufreq_register_notifier(&twd_cpufreq_nb, - CPUFREQ_TRANSITION_NOTIFIER); + return clk_notifier_register(twd_clk, &twd_clk_nb); return 0; } -core_initcall(twd_cpufreq_init); - -#endif +core_initcall(twd_clk_init); static void __cpuinit twd_calibrate_rate(void) { @@ -203,6 +196,13 @@ static struct clk *twd_get_clock(void) return clk; } + err = clk_prepare(clk); + if (err) { + pr_err("smp_twd: clock failed to prepare: %d\n", err); + clk_put(clk); + return ERR_PTR(err); + } + err = clk_enable(clk); if (err) { pr_err("smp_twd: clock failed to enable: %d\n", err);