From patchwork Wed Feb 29 07:18:14 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Zhao X-Patchwork-Id: 6998 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 2B0B823EAF for ; Wed, 29 Feb 2012 07:18:36 +0000 (UTC) Received: from mail-iy0-f180.google.com (mail-iy0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id C47A6A180DB for ; Wed, 29 Feb 2012 07:18:35 +0000 (UTC) Received: by iage36 with SMTP id e36so2786662iag.11 for ; Tue, 28 Feb 2012 23:18:35 -0800 (PST) Received: from mr.google.com ([10.50.170.41]) by 10.50.170.41 with SMTP id aj9mr25765030igc.0.1330499915322 (num_hops = 1); Tue, 28 Feb 2012 23:18:35 -0800 (PST) Received: by 10.50.170.41 with SMTP id aj9mr20884717igc.0.1330499915272; Tue, 28 Feb 2012 23:18:35 -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.231.11.10 with SMTP id r10csp26274ibr; Tue, 28 Feb 2012 23:18:34 -0800 (PST) Received: by 10.180.14.73 with SMTP id n9mr36529333wic.16.1330499913283; Tue, 28 Feb 2012 23:18:33 -0800 (PST) Received: from DB3EHSOBE003.bigfish.com (db3ehsobe001.messaging.microsoft.com. [213.199.154.139]) by mx.google.com with ESMTPS id l33si16267833weq.6.2012.02.28.23.18.32 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 28 Feb 2012 23:18:33 -0800 (PST) Received-SPF: neutral (google.com: 213.199.154.139 is neither permitted nor denied by best guess record for domain of richard.zhao@linaro.org) client-ip=213.199.154.139; Authentication-Results: mx.google.com; spf=neutral (google.com: 213.199.154.139 is neither permitted nor denied by best guess record for domain of richard.zhao@linaro.org) smtp.mail=richard.zhao@linaro.org Received: from mail39-db3-R.bigfish.com (10.3.81.225) by DB3EHSOBE003.bigfish.com (10.3.84.23) with Microsoft SMTP Server id 14.1.225.23; Wed, 29 Feb 2012 07:18:32 +0000 Received: from mail39-db3 (localhost [127.0.0.1]) by mail39-db3-R.bigfish.com (Postfix) with ESMTP id 344074405A3; Wed, 29 Feb 2012 07:18:32 +0000 (UTC) X-SpamScore: 0 X-BigFish: VS0(zzzz1202hzz8275dhz2dh87h2a8h668h839h) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI X-FB-DOMAIN-IP-MATCH: fail Received: from mail39-db3 (localhost.localdomain [127.0.0.1]) by mail39-db3 (MessageSwitch) id 1330499910345542_30144; Wed, 29 Feb 2012 07:18:30 +0000 (UTC) Received: from DB3EHSMHS005.bigfish.com (unknown [10.3.81.238]) by mail39-db3.bigfish.com (Postfix) with ESMTP id 4535E38004D; Wed, 29 Feb 2012 07:18:30 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by DB3EHSMHS005.bigfish.com (10.3.87.105) with Microsoft SMTP Server (TLS) id 14.1.225.23; Wed, 29 Feb 2012 07:18:29 +0000 Received: from az33smr01.freescale.net (10.64.34.199) by 039-SN1MMR1-001.039d.mgd.msft.net (10.84.1.13) with Microsoft SMTP Server id 14.1.355.3; Wed, 29 Feb 2012 01:18:28 -0600 Received: from b20223-02.ap.freescale.net (b20223-02.ap.freescale.net [10.192.242.124]) by az33smr01.freescale.net (8.13.1/8.13.0) with ESMTP id q1T7IH9i008037; Wed, 29 Feb 2012 01:18:25 -0600 (CST) From: Richard Zhao To: , CC: , , , , , , , , , Richard Zhao Subject: [PATCH 1/2] ARM: add cpufreq transiton notifier to adjust loops_per_jiffy for smp Date: Wed, 29 Feb 2012 15:18:14 +0800 Message-ID: <1330499895-12364-2-git-send-email-richard.zhao@linaro.org> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1330499895-12364-1-git-send-email-richard.zhao@linaro.org> References: <1330499895-12364-1-git-send-email-richard.zhao@linaro.org> MIME-Version: 1.0 X-OriginatorOrg: sigmatel.com X-Gm-Message-State: ALoCoQnzNitHY1z+KbQSQewmqPC/ZOVpmBmuVVeapB2HEsfvizr8o5gwgPizeuLol0u1nOk64G6z If CONFIG_SMP, cpufreq skips loops_per_jiffy update, because different arch has different per-cpu loops_per_jiffy definition. Signed-off-by: Richard Zhao Acked-by: Russell King Acked-by: Santosh Shilimkar --- arch/arm/kernel/smp.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 54 insertions(+), 0 deletions(-) diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c index cdeb727..4381bef 100644 --- a/arch/arm/kernel/smp.c +++ b/arch/arm/kernel/smp.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -599,3 +600,56 @@ int setup_profiling_timer(unsigned int multiplier) { return -EINVAL; } + +#ifdef CONFIG_CPU_FREQ + +static DEFINE_PER_CPU(unsigned long, l_p_j_ref); +static DEFINE_PER_CPU(unsigned long, l_p_j_ref_freq); +static unsigned long global_l_p_j_ref; +static unsigned long global_l_p_j_ref_freq; + +static int cpufreq_callback(struct notifier_block *nb, + unsigned long val, void *data) +{ + struct cpufreq_freqs *freq = data; + int cpu = freq->cpu; + + if (freq->flags & CPUFREQ_CONST_LOOPS) + return NOTIFY_OK; + + if (!per_cpu(l_p_j_ref, cpu)) { + per_cpu(l_p_j_ref, cpu) = + per_cpu(cpu_data, cpu).loops_per_jiffy; + per_cpu(l_p_j_ref_freq, cpu) = freq->old; + if (!global_l_p_j_ref) { + global_l_p_j_ref = loops_per_jiffy; + global_l_p_j_ref_freq = freq->old; + } + } + + if ((val == CPUFREQ_PRECHANGE && freq->old < freq->new) || + (val == CPUFREQ_POSTCHANGE && freq->old > freq->new) || + (val == CPUFREQ_RESUMECHANGE || val == CPUFREQ_SUSPENDCHANGE)) { + loops_per_jiffy = cpufreq_scale(global_l_p_j_ref, + global_l_p_j_ref_freq, + freq->new); + per_cpu(cpu_data, cpu).loops_per_jiffy = + cpufreq_scale(per_cpu(l_p_j_ref, cpu), + per_cpu(l_p_j_ref_freq, cpu), + freq->new); + } + return NOTIFY_OK; +} + +static struct notifier_block cpufreq_notifier = { + .notifier_call = cpufreq_callback, +}; + +static int __init register_cpufreq_notifier(void) +{ + return cpufreq_register_notifier(&cpufreq_notifier, + CPUFREQ_TRANSITION_NOTIFIER); +} +core_initcall(register_cpufreq_notifier); + +#endif