From patchwork Thu Dec 22 07:09:07 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Zhao X-Patchwork-Id: 5940 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 47B4723E2D for ; Thu, 22 Dec 2011 07:09:36 +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 3E1AAA180F2 for ; Thu, 22 Dec 2011 07:09:36 +0000 (UTC) Received: by mail-ey0-f180.google.com with SMTP id c11so5443261eaa.11 for ; Wed, 21 Dec 2011 23:09:36 -0800 (PST) Received: by 10.205.138.136 with SMTP id is8mr2787208bkc.35.1324537776046; Wed, 21 Dec 2011 23:09:36 -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.82.144 with SMTP id ac16cs58757bkc; Wed, 21 Dec 2011 23:09:35 -0800 (PST) Received: by 10.227.197.147 with SMTP id ek19mr9232847wbb.3.1324537774275; Wed, 21 Dec 2011 23:09:34 -0800 (PST) Received: from DB3EHSOBE005.bigfish.com (db3ehsobe005.messaging.microsoft.com. [213.199.154.143]) by mx.google.com with ESMTPS id fb6si4187716wbb.25.2011.12.21.23.09.33 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 21 Dec 2011 23:09:34 -0800 (PST) Received-SPF: neutral (google.com: 213.199.154.143 is neither permitted nor denied by best guess record for domain of richard.zhao@linaro.org) client-ip=213.199.154.143; Authentication-Results: mx.google.com; spf=neutral (google.com: 213.199.154.143 is neither permitted nor denied by best guess record for domain of richard.zhao@linaro.org) smtp.mail=richard.zhao@linaro.org Received: from mail77-db3-R.bigfish.com (10.3.81.246) by DB3EHSOBE005.bigfish.com (10.3.84.25) with Microsoft SMTP Server id 14.1.225.23; Thu, 22 Dec 2011 07:09:22 +0000 Received: from mail77-db3 (localhost [127.0.0.1]) by mail77-db3-R.bigfish.com (Postfix) with ESMTP id 24EA15C034D; Thu, 22 Dec 2011 07:09:57 +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-SS: 13, X-FB-DOMAIN-IP-MATCH: fail Received: from mail77-db3 (localhost.localdomain [127.0.0.1]) by mail77-db3 (MessageSwitch) id 1324537796863138_26867; Thu, 22 Dec 2011 07:09:56 +0000 (UTC) Received: from DB3EHSMHS019.bigfish.com (unknown [10.3.81.246]) by mail77-db3.bigfish.com (Postfix) with ESMTP id C2FBF80042; Thu, 22 Dec 2011 07:09:56 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by DB3EHSMHS019.bigfish.com (10.3.87.119) with Microsoft SMTP Server (TLS) id 14.1.225.23; Thu, 22 Dec 2011 07:09:20 +0000 Received: from az33smr01.freescale.net (10.64.34.199) by 039-SN1MMR1-002.039d.mgd.msft.net (10.84.1.15) with Microsoft SMTP Server id 14.1.355.3; Thu, 22 Dec 2011 01:09:30 -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 pBM79FSL010925; Thu, 22 Dec 2011 01:09:24 -0600 (CST) From: Richard Zhao To: , , CC: , , , , , , , , , , , , , , , , , Richard Zhao Subject: [PATCH v4 1/7] ARM: add cpufreq transiton notifier to adjust loops_per_jiffy for smp Date: Thu, 22 Dec 2011 15:09:07 +0800 Message-ID: <1324537753-30590-2-git-send-email-richard.zhao@linaro.org> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1324537753-30590-1-git-send-email-richard.zhao@linaro.org> References: <1324537753-30590-1-git-send-email-richard.zhao@linaro.org> MIME-Version: 1.0 X-OriginatorOrg: sigmatel.com 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 --- 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 ef5640b..ac9cadc 100644 --- a/arch/arm/kernel/smp.c +++ b/arch/arm/kernel/smp.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -631,3 +632,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