From patchwork Fri Dec 30 02:56:03 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Zhao X-Patchwork-Id: 5997 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 0834923E0E for ; Fri, 30 Dec 2011 02:56:37 +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 EC2AEA180EC for ; Fri, 30 Dec 2011 02:56:36 +0000 (UTC) Received: by mail-ey0-f180.google.com with SMTP id c11so12267378eaa.11 for ; Thu, 29 Dec 2011 18:56:36 -0800 (PST) Received: by 10.204.133.207 with SMTP id g15mr8777860bkt.17.1325213796724; Thu, 29 Dec 2011 18:56: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 ac16cs243581bkc; Thu, 29 Dec 2011 18:56:36 -0800 (PST) Received: by 10.52.99.231 with SMTP id et7mr18102402vdb.114.1325213794599; Thu, 29 Dec 2011 18:56:34 -0800 (PST) Received: from ch1outboundpool.messaging.microsoft.com (ch1ehsobe003.messaging.microsoft.com. [216.32.181.183]) by mx.google.com with ESMTPS id gh6si7512302vcb.65.2011.12.29.18.56.33 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 29 Dec 2011 18:56:34 -0800 (PST) Received-SPF: neutral (google.com: 216.32.181.183 is neither permitted nor denied by best guess record for domain of richard.zhao@linaro.org) client-ip=216.32.181.183; Authentication-Results: mx.google.com; spf=neutral (google.com: 216.32.181.183 is neither permitted nor denied by best guess record for domain of richard.zhao@linaro.org) smtp.mail=richard.zhao@linaro.org Received: from mail201-ch1-R.bigfish.com (10.43.68.249) by CH1EHSOBE006.bigfish.com (10.43.70.56) with Microsoft SMTP Server id 14.1.225.23; Fri, 30 Dec 2011 02:56:09 +0000 Received: from mail201-ch1 (localhost [127.0.0.1]) by mail201-ch1-R.bigfish.com (Postfix) with ESMTP id CD8AA3A00FC; Fri, 30 Dec 2011 02:56:09 +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 mail201-ch1 (localhost.localdomain [127.0.0.1]) by mail201-ch1 (MessageSwitch) id 1325213767481195_32300; Fri, 30 Dec 2011 02:56:07 +0000 (UTC) Received: from CH1EHSMHS029.bigfish.com (snatpool1.int.messaging.microsoft.com [10.43.68.246]) by mail201-ch1.bigfish.com (Postfix) with ESMTP id 663FD580049; Fri, 30 Dec 2011 02:56:07 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by CH1EHSMHS029.bigfish.com (10.43.70.29) with Microsoft SMTP Server (TLS) id 14.1.225.23; Fri, 30 Dec 2011 02:56:07 +0000 Received: from az33smr01.freescale.net (10.64.34.199) by 039-SN1MMR1-003.039d.mgd.msft.net (10.84.1.16) with Microsoft SMTP Server id 14.1.355.3; Thu, 29 Dec 2011 20:56:29 -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 pBU2uCwb006169; Thu, 29 Dec 2011 20:56:23 -0600 (CST) From: Richard Zhao To: , , CC: , , , , , , , , , , , , , , , , , Richard Zhao Subject: [PATCH V6 1/7] ARM: add cpufreq transiton notifier to adjust loops_per_jiffy for smp Date: Fri, 30 Dec 2011 10:56:03 +0800 Message-ID: <1325213769-11752-2-git-send-email-richard.zhao@linaro.org> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1325213769-11752-1-git-send-email-richard.zhao@linaro.org> References: <1325213769-11752-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