From patchwork Fri Jun 24 13:53:38 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sanjeev Premi X-Patchwork-Id: 916332 X-Patchwork-Delegate: khilman@deeprootsystems.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p5ODrwXI012545 for ; Fri, 24 Jun 2011 13:53:59 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753542Ab1FXNx5 (ORCPT ); Fri, 24 Jun 2011 09:53:57 -0400 Received: from devils.ext.ti.com ([198.47.26.153]:51228 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751921Ab1FXNx5 (ORCPT ); Fri, 24 Jun 2011 09:53:57 -0400 Received: from dbdp20.itg.ti.com ([172.24.170.38]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id p5ODrpU7015518 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 24 Jun 2011 08:53:53 -0500 Received: from dbde71.ent.ti.com (localhost [127.0.0.1]) by dbdp20.itg.ti.com (8.13.8/8.13.8) with ESMTP id p5ODrnkg005720; Fri, 24 Jun 2011 19:23:50 +0530 (IST) Received: from dbdp31.itg.ti.com (172.24.170.98) by DBDE71.ent.ti.com (172.24.170.149) with Microsoft SMTP Server id 8.3.106.1; Fri, 24 Jun 2011 19:23:49 +0530 Received: from psplinux050.india.ti.com (dbdp20.itg.ti.com [172.24.170.38]) by dbdp31.itg.ti.com (8.13.8/8.13.8) with ESMTP id p5ODrjDC019776; Fri, 24 Jun 2011 19:23:46 +0530 (IST) From: Sanjeev Premi To: , CC: Sanjeev Premi Subject: [PATCHv2] omap2+: pm: cpufreq: Fix loops_per_jiffy calculation Date: Fri, 24 Jun 2011 19:23:38 +0530 Message-ID: <1308923618-5333-1-git-send-email-premi@ti.com> X-Mailer: git-send-email 1.7.2.2 MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Fri, 24 Jun 2011 13:53:59 +0000 (UTC) Currently, loops_per_jiffy is being calculated twice for non-SMP processors. - Before calling cpufreq_notify_transition() - From within cpufreq_notify_transition() Double adjustment leads to incorrect value being assigned to loops_per_jiffy. This manifests as incorrect BogoMIPS in "cat /proc/cpuinfo". The value of loops_per_jiffy needs to be calculated only when CONFIG_SMP is true. It is the core change included in this patch. The patch also leverages the definition of for_each_cpu() with and without CONFIG_SMP to consolidate the mechanism to call cpufreq_notify_transition(). Signed-off-by: Sanjeev Premi --- Changes since v1: * loops_per_jiffy are updated when CONFIG_SMP is true. * leverage definition of for_each_cpu() Tested on OMAP3EVM with and without CONFIG_SMP. Since the log is rather long, will be posting the log in a follow-up mail. arch/arm/mach-omap2/omap2plus-cpufreq.c | 27 +++++++++++++++------------ 1 files changed, 15 insertions(+), 12 deletions(-) -- 1.7.2.2 -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/arm/mach-omap2/omap2plus-cpufreq.c b/arch/arm/mach-omap2/omap2plus-cpufreq.c index 346519e..0263cae 100644 --- a/arch/arm/mach-omap2/omap2plus-cpufreq.c +++ b/arch/arm/mach-omap2/omap2plus-cpufreq.c @@ -97,12 +97,8 @@ static int omap_target(struct cpufreq_policy *policy, return ret; /* Notify transitions */ - if (is_smp()) { - for_each_cpu(i, policy->cpus) { - freqs.cpu = i; - cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); - } - } else { + for_each_cpu(i, policy->cpus) { + freqs.cpu = i; cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); } @@ -114,13 +110,20 @@ static int omap_target(struct cpufreq_policy *policy, freqs.new = omap_getspeed(policy->cpu); +#ifdef CONFIG_SMP + /* Adjust jiffies before transition */ + for_each_cpu(i, policy->cpus) { + unsigned long lpj = per_cpu(cpu_data, i).loops_per_jiffy; + + per_cpu(cpu_data, i).loops_per_jiffy = cpufreq_scale(lpj, + freqs.old, + freqs.new); + } +#endif + /* Notify transitions */ - if (is_smp()) { - for_each_cpu(i, policy->cpus) { - freqs.cpu = i; - cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); - } - } else { + for_each_cpu(i, policy->cpus) { + freqs.cpu = i; cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); }