From patchwork Fri Jun 24 18:48:24 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Santosh Shilimkar X-Patchwork-Id: 917252 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p5OImstV006165 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 24 Jun 2011 18:49:17 GMT Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QaBQi-0006fI-CP; Fri, 24 Jun 2011 18:48:36 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1QaBQh-0001P7-W3; Fri, 24 Jun 2011 18:48:36 +0000 Received: from na3sys009aog126.obsmtp.com ([74.125.149.155]) by canuck.infradead.org with smtps (Exim 4.76 #1 (Red Hat Linux)) id 1QaBQe-0001Op-KO for linux-arm-kernel@lists.infradead.org; Fri, 24 Jun 2011 18:48:33 +0000 Received: from mail-yi0-f48.google.com ([209.85.218.48]) (using TLSv1) by na3sys009aob126.postini.com ([74.125.148.12]) with SMTP ID DSNKTgTb/AOs3Y0d3NLpSeygCCdq9md5sN7t@postini.com; Fri, 24 Jun 2011 11:48:32 PDT Received: by mail-yi0-f48.google.com with SMTP id 24so1883019yic.35 for ; Fri, 24 Jun 2011 11:48:28 -0700 (PDT) Received: by 10.236.193.98 with SMTP id j62mr5962151yhn.46.1308941307960; Fri, 24 Jun 2011 11:48:27 -0700 (PDT) Received: from [146.252.42.118] (dragon.ti.com [192.94.94.33]) by mx.google.com with ESMTPS id o47sm1869495yhn.2.2011.06.24.11.48.26 (version=SSLv3 cipher=OTHER); Fri, 24 Jun 2011 11:48:27 -0700 (PDT) Message-ID: <4E04DBF8.1050401@ti.com> Date: Fri, 24 Jun 2011 11:48:24 -0700 From: Santosh Shilimkar User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 MIME-Version: 1.0 To: Russell King - ARM Linux Subject: Re: [PATCHv2] omap2+: pm: cpufreq: Fix loops_per_jiffy calculation References: <1308923618-5333-1-git-send-email-premi@ti.com> <20110624140142.GM9449@n2100.arm.linux.org.uk> <20110624141402.GN9449@n2100.arm.linux.org.uk> <20110624151201.GO9449@n2100.arm.linux.org.uk> In-Reply-To: <20110624151201.GO9449@n2100.arm.linux.org.uk> X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110624_144832_994792_50F6CF63 X-CRM114-Status: GOOD ( 22.96 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- Cc: Kevin Hilman , "linux-omap@vger.kernel.org" , "Premi, Sanjeev" , "linux-arm-kernel@lists.infradead.org" X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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 18:49:18 +0000 (UTC) Russell, On 6/24/2011 8:12 AM, Russell King - ARM Linux wrote: > Right, thanks for the file. Here's the patch. > [.....] > Notice how we adjust _both_ the per-cpu loops_per_jiffy, and that we > adjust them with reference to the initial values. > > If you adjust lpj with reference to the last, then you _will_ build up > a progressively bigger and bigger error in the value over time. > Thanks Russell for the change. This change should fix the global lpj for UP machine as well when build with SMP_ON_UP. Can you have a look at below complete change which should make the BOGOMIPS happy on all OMAP2PLUS machines. Generated against Kevin's cpufreq branch. url = git://git.kernel.org/pub/scm/linux/kernel/git/khilman/linux-omap-pm.git pm-wip/cpufreq. Just compile tested with UP and SMP OMAP builds. After your review, I can give a test. Regards Santosh From 9a6154c0f68e39c4d1fbc4ef3fef5ce577ba87d4 Mon Sep 17 00:00:00 2001 From: Russell King Date: Fri, 24 Jun 2011 10:51:17 -0700 Subject: [PATCH] OMAP2+: CPUfreq: update lpj with refernce value to avoid progressive error. Adjust _both_ the per-cpu loops_per_jiffy and global lpj. Calibrate them with with reference to the initial values to avoid a progressively bigger and bigger error in the value over time. While at this also re-use the notifiers for UP/SMP since on UP machine or UP_ON_SMP policy->cpus mask would contain only the one CPU. Signed-off-by: Santosh Shilimkar [santosh.shilimkar@ti.com: rebased against omap cpufreq upstream branch] Signed-off-by: Russell King Cc: Kevin Hilman --- arch/arm/mach-omap2/omap2plus-cpufreq.c | 48 +++++++++++++++++------------- 1 files changed, 27 insertions(+), 21 deletions(-) diff --git a/arch/arm/mach-omap2/omap2plus-cpufreq.c b/arch/arm/mach-omap2/omap2plus-cpufreq.c index 1f3b2e1..434698e 100644 --- a/arch/arm/mach-omap2/omap2plus-cpufreq.c +++ b/arch/arm/mach-omap2/omap2plus-cpufreq.c @@ -38,6 +38,16 @@ #include +#ifdef CONFIG_SMP +struct lpj_info { + unsigned long ref; + unsigned int freq; +}; + +static DEFINE_PER_CPU(struct lpj_info, lpj_ref); +static struct lpj_info global_lpj_ref; +#endif + static struct cpufreq_frequency_table *freq_table; static atomic_t freq_table_users = ATOMIC_INIT(0); static struct clk *mpu_clk; @@ -96,11 +106,6 @@ static int omap_target(struct cpufreq_policy *policy, if (freqs.old == freqs.new && policy->cur == freqs.new) return ret; - if (!is_smp()) { - cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); - goto set_freq; - } - /* notifiers */ for_each_cpu(i, policy->cpus) { freqs.cpu = i; @@ -114,19 +119,7 @@ set_freq: ret = clk_set_rate(mpu_clk, freqs.new * 1000); - /* - * Generic CPUFREQ driver jiffy update is under !SMP. So jiffies - * won't get updated when UP machine cpufreq build with - * CONFIG_SMP enabled. Below code is added only to manage that - * scenario - */ freqs.new = omap_getspeed(policy->cpu); - if (!is_smp()) { - loops_per_jiffy = - cpufreq_scale(loops_per_jiffy, freqs.old, freqs.new); - cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); - goto skip_lpj; - } #ifdef CONFIG_SMP /* @@ -134,10 +127,24 @@ set_freq: * cpufreq driver. So, update the per-CPU loops_per_jiffy value * on frequency transition. We need to update all dependent CPUs. */ - for_each_cpu(i, policy->cpus) + for_each_cpu(i, policy->cpus) { + struct lpj_info *lpj = &per_cpu(lpj_ref, i); + if (!lpj->freq) { + lpj->ref = per_cpu(cpu_data, i).loops_per_jiffy; + lpj->freq = freqs.old; + } + per_cpu(cpu_data, i).loops_per_jiffy = - cpufreq_scale(per_cpu(cpu_data, i).loops_per_jiffy, - freqs.old, freqs.new); + cpufreq_scale(lpj->ref, lpj->freq, freqs.new); + } + + /* And don't forget to adjust the global one */ + if (!global_lpj_ref.freq) { + global_lpj_ref.ref = loops_per_jiffy; + global_lpj_ref.freq = freqs.old; + } + loops_per_jiffy = cpufreq_scale(global_lpj_ref.ref, global_lpj_ref.freq, + freqs.new); #endif /* notifiers */ @@ -146,7 +153,6 @@ set_freq: cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); } -skip_lpj: return ret; }