From patchwork Sat Nov 30 15:56:23 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 21906 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f69.google.com (mail-yh0-f69.google.com [209.85.213.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id DC64220DB9 for ; Sat, 30 Nov 2013 15:57:04 +0000 (UTC) Received: by mail-yh0-f69.google.com with SMTP id a41sf23834900yho.8 for ; Sat, 30 Nov 2013 07:57:04 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:in-reply-to:references :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=6hOQ1UJzcVZUSzYTCMBJatQpb2Pg0fAg+D9ohBc9pG4=; b=jlJ4D0LqvXfO1jPiyiPHf2PCWZYvzM4heppfWI6gyVWovcHd6/gUTdT16ty+vK6Qoe DA2ZjJI5jvpMRNTwxxTN4FC9jy/P4y8HOY1L3CO3IUkvxJ13cOW9D/R0ul6TBvmZ+tvz 9+BkxxArm6kVhrNs3ImU8n5ImTQKwkIJK4FlW2r4LGicyjS75evWKofTkQFwy7E84i3s FxLoiAwgSvSwaDPuwNhhyW7LGVzsvqNiqKSwcIsIIB6lwZ0z5kkE8x+kloEwX7qTJYrG IN3DNZZcIYjJOPNVhoIw4z7s5bPTFoTLyO9V+vyZQ2zkl8rhMAXCt/lRMJDE41YAStGE a3Aw== X-Gm-Message-State: ALoCoQmiqGVElXAi7qKz0qaLaEiNglMZiCTyzHwW20ru6lX5HMr+pYFtGdW6P75tyayfJEAMkJVP X-Received: by 10.58.204.2 with SMTP id ku2mr820444vec.39.1385827024657; Sat, 30 Nov 2013 07:57:04 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.104.76 with SMTP id gc12ls2369786qeb.44.gmail; Sat, 30 Nov 2013 07:57:04 -0800 (PST) X-Received: by 10.58.254.200 with SMTP id ak8mr46525303ved.12.1385827024435; Sat, 30 Nov 2013 07:57:04 -0800 (PST) Received: from mail-ve0-f173.google.com (mail-ve0-f173.google.com [209.85.128.173]) by mx.google.com with ESMTPS id bj1si26594184ved.2.2013.11.30.07.57.04 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 30 Nov 2013 07:57:04 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.173 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.173; Received: by mail-ve0-f173.google.com with SMTP id oz11so7622092veb.18 for ; Sat, 30 Nov 2013 07:57:04 -0800 (PST) X-Received: by 10.220.11.7 with SMTP id r7mr46308106vcr.12.1385827024373; Sat, 30 Nov 2013 07:57:04 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp3821vcz; Sat, 30 Nov 2013 07:57:03 -0800 (PST) X-Received: by 10.68.106.98 with SMTP id gt2mr21853852pbb.61.1385827023535; Sat, 30 Nov 2013 07:57:03 -0800 (PST) Received: from mail-pd0-f172.google.com (mail-pd0-f172.google.com [209.85.192.172]) by mx.google.com with ESMTPS id f4si14687963pbm.115.2013.11.30.07.57.03 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 30 Nov 2013 07:57:03 -0800 (PST) Received-SPF: neutral (google.com: 209.85.192.172 is neither permitted nor denied by best guess record for domain of viresh.kumar@linaro.org) client-ip=209.85.192.172; Received: by mail-pd0-f172.google.com with SMTP id g10so15423562pdj.3 for ; Sat, 30 Nov 2013 07:57:03 -0800 (PST) X-Received: by 10.66.218.226 with SMTP id pj2mr58055050pac.62.1385827023123; Sat, 30 Nov 2013 07:57:03 -0800 (PST) Received: from localhost ([122.167.133.207]) by mx.google.com with ESMTPSA id y9sm124541239pas.10.2013.11.30.07.56.58 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 30 Nov 2013 07:57:02 -0800 (PST) From: Viresh Kumar To: rjw@rjwysocki.net Cc: linaro-kernel@lists.linaro.org, patches@linaro.org, cpufreq@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Viresh Kumar Subject: [PATCH 5/5] cpufreq: unicore2: send new set of notification for transition failures Date: Sat, 30 Nov 2013 21:26:23 +0530 Message-Id: X-Mailer: git-send-email 1.7.12.rc2.18.g61b472e In-Reply-To: <0d635c6701654a75f6d25dd435705dc1ede3e19c.1385826776.git.viresh.kumar@linaro.org> References: <0d635c6701654a75f6d25dd435705dc1ede3e19c.1385826776.git.viresh.kumar@linaro.org> In-Reply-To: <0d635c6701654a75f6d25dd435705dc1ede3e19c.1385826776.git.viresh.kumar@linaro.org> References: <0d635c6701654a75f6d25dd435705dc1ede3e19c.1385826776.git.viresh.kumar@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: viresh.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.173 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , In the current code, if we fail during a frequency transition we simply send the POSTCHANGE notification with old frequency. This isn't enough. One of the core user of these notifications is the code responsible for keeping loops_per_jiffy aligned with frequency change. And mostly it is written as: if ((val == CPUFREQ_PRECHANGE && freq->old < freq->new) || (val == CPUFREQ_POSTCHANGE && freq->old > freq->new)) { update-loops-per-jiffy... } So, suppose we are changing to a higher frequency and failed during transition, then following will happen: - CPUFREQ_PRECHANGE notification with freq-new > freq-old - CPUFREQ_POSTCHANGE notification with freq-new == freq-old The first one will update loops_per_jiffy and second one will do nothing. Even if we send the 2nd notification by exchanging values of freq-new and old, some users of these notifications might get unstable. This can be fixed by simply calling cpufreq_notify_post_transition() with error code and this routine will take care of sending notifications in correct order. Also it returns a proper error message in case frequency transition failed. Signed-off-by: Viresh Kumar --- drivers/cpufreq/unicore2-cpufreq.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/cpufreq/unicore2-cpufreq.c b/drivers/cpufreq/unicore2-cpufreq.c index 653ae29..3e79dae 100644 --- a/drivers/cpufreq/unicore2-cpufreq.c +++ b/drivers/cpufreq/unicore2-cpufreq.c @@ -49,17 +49,16 @@ static int ucv2_target(struct cpufreq_policy *policy, unsigned int cur = ucv2_getspeed(0); struct cpufreq_freqs freqs; struct clk *mclk = clk_get(NULL, "MAIN_CLK"); + int ret; - cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); - - if (!clk_set_rate(mclk, target_freq * 1000)) { - freqs.old = cur; - freqs.new = target_freq; - } + freqs.old = cur; + freqs.new = target_freq; - cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); + cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); + ret = clk_set_rate(mclk, target_freq * 1000); + cpufreq_notify_post_transition(policy, &freqs, ret); - return 0; + return ret; } static int __init ucv2_cpu_init(struct cpufreq_policy *policy)