From patchwork Mon Dec 2 05:34:14 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 21909 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f72.google.com (mail-oa0-f72.google.com [209.85.219.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8D0AE20DB9 for ; Mon, 2 Dec 2013 05:34:30 +0000 (UTC) Received: by mail-oa0-f72.google.com with SMTP id o6sf41299264oag.3 for ; Sun, 01 Dec 2013 21:34:30 -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=wrCTSlgdX/JjLmNWzUkp3uWb9ltVeS7smo+twYMCzCQ=; b=hIXPNrf5OSGxTwVG+uEz+/zVVB2SE8vK/cTjtwPRcjp7x0bdecAcelVMT0va7cBWHx aCR53Br/zdZuxrHkLqELFdfYQ61jhX+VgBrUZyt2jialD4QPMbPsAJEeJug7j21/9zyY AZbapnLHRuCQKma1uppeGSi5bE/P/+M43KmlrCk2ICc7jcZ7unEb31ILhNjNjt2OrlTe 12GXDSaR+e9PX6huZ4cgw+w8YDE8TgepKsmSw9KuXDaauvTAG7WweBooeuNYG/PlZ4aj 9XJIoI0U8VZA64Vraf1f8valNCE1ab1DP02wwxT9G8H99XjZbgmWAG5KRlBmVmG/nfBI w4AQ== X-Gm-Message-State: ALoCoQkDmD695bmUBeH5UjcmoeX+3kuLcCBvt3Vkc22V6yzV8seaO91t+n0pCGaBmgobhZN0toWL X-Received: by 10.182.22.73 with SMTP id b9mr20309853obf.17.1385962470141; Sun, 01 Dec 2013 21:34:30 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.116.42 with SMTP id jt10ls4424292qeb.66.gmail; Sun, 01 Dec 2013 21:34:30 -0800 (PST) X-Received: by 10.58.180.227 with SMTP id dr3mr149584vec.36.1385962469981; Sun, 01 Dec 2013 21:34:29 -0800 (PST) Received: from mail-ve0-f178.google.com (mail-ve0-f178.google.com [209.85.128.178]) by mx.google.com with ESMTPS id om4si29009368vcb.68.2013.12.01.21.34.29 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 01 Dec 2013 21:34:29 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.178 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.178; Received: by mail-ve0-f178.google.com with SMTP id c14so8296240vea.23 for ; Sun, 01 Dec 2013 21:34:29 -0800 (PST) X-Received: by 10.52.120.11 with SMTP id ky11mr959470vdb.28.1385962469905; Sun, 01 Dec 2013 21:34:29 -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 u4csp91874vcz; Sun, 1 Dec 2013 21:34:29 -0800 (PST) X-Received: by 10.49.50.161 with SMTP id d1mr110437773qeo.51.1385962469506; Sun, 01 Dec 2013 21:34:29 -0800 (PST) Received: from mail-qa0-f49.google.com (mail-qa0-f49.google.com [209.85.216.49]) by mx.google.com with ESMTPS id n6si50935599qel.109.2013.12.01.21.34.29 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 01 Dec 2013 21:34:29 -0800 (PST) Received-SPF: neutral (google.com: 209.85.216.49 is neither permitted nor denied by best guess record for domain of viresh.kumar@linaro.org) client-ip=209.85.216.49; Received: by mail-qa0-f49.google.com with SMTP id ii20so3950916qab.8 for ; Sun, 01 Dec 2013 21:34:29 -0800 (PST) X-Received: by 10.49.131.5 with SMTP id oi5mr68928154qeb.38.1385962469382; Sun, 01 Dec 2013 21:34:29 -0800 (PST) Received: from localhost (git.linaro.org. [54.235.93.228]) by mx.google.com with ESMTPSA id p20sm151057567qay.0.2013.12.01.21.34.28 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sun, 01 Dec 2013 21:34:28 -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 V2 3/5] cpufreq: pcc: send new set of notification for transition failures Date: Mon, 2 Dec 2013 11:04:14 +0530 Message-Id: <3d86feabdc6f223b68a4936c9529b4edec3e39ba.1385962178.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 1.7.12.rc2.18.g61b472e In-Reply-To: References: In-Reply-To: References: 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.178 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 fills freqs.old before starting the first notification, this was missing since ever. Signed-off-by: Viresh Kumar --- drivers/cpufreq/pcc-cpufreq.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/drivers/cpufreq/pcc-cpufreq.c b/drivers/cpufreq/pcc-cpufreq.c index e2b4f40..1c0f106 100644 --- a/drivers/cpufreq/pcc-cpufreq.c +++ b/drivers/cpufreq/pcc-cpufreq.c @@ -213,6 +213,7 @@ static int pcc_cpufreq_target(struct cpufreq_policy *policy, cpu, target_freq, (pcch_virt_addr + pcc_cpu_data->input_offset)); + freqs.old = policy->cur; freqs.new = target_freq; cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); @@ -228,25 +229,20 @@ static int pcc_cpufreq_target(struct cpufreq_policy *policy, memset_io((pcch_virt_addr + pcc_cpu_data->input_offset), 0, BUF_SZ); status = ioread16(&pcch_hdr->status); + iowrite16(0, &pcch_hdr->status); + + cpufreq_notify_post_transition(policy, &freqs, status != CMD_COMPLETE); + spin_unlock(&pcc_lock); + if (status != CMD_COMPLETE) { pr_debug("target: FAILED for cpu %d, with status: 0x%x\n", cpu, status); - goto cmd_incomplete; + return -EINVAL; } - iowrite16(0, &pcch_hdr->status); - cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); pr_debug("target: was SUCCESSFUL for cpu %d\n", cpu); - spin_unlock(&pcc_lock); return 0; - -cmd_incomplete: - freqs.new = freqs.old; - cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); - iowrite16(0, &pcch_hdr->status); - spin_unlock(&pcc_lock); - return -EINVAL; } static int pcc_get_offset(int cpu)