From patchwork Sat Nov 30 15:56:20 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 21903 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pb0-f69.google.com (mail-pb0-f69.google.com [209.85.160.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E4EE520DB9 for ; Sat, 30 Nov 2013 15:56:40 +0000 (UTC) Received: by mail-pb0-f69.google.com with SMTP id md12sf29103668pbc.8 for ; Sat, 30 Nov 2013 07:56:40 -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=dCArDE9W1vugDD9pKmi1lhmmUO4w1JnimpV4pdoVkFA=; b=Gd5/EmwAdd4vljcHF0pZ0MNF2y4KXNiKSL0BKSeZEtJc5ayQ72V9filTYNacvdVye3 56vFhXnJzZEkyfI9s6ozBmSgp1tKcSbYBx2cNyCVZDBpxq/3W1ndXXXxq/JLdd+LluGL JNF5s7POwsIvohIMTsu+0Rf80hTVaIXRvVGBODQP9hzih7/m2hnVDaorKBvG4B1u5FcO hlp5LfsQsXg6TsL++TQ6nWbLpKVhPQk9P8RtSGApLeODKZ3I3I7xVCXZPwEsukA+5+0+ KsojAPbZwO35GpSQzGtZb657QNKO285mKlYCJj0xq9BnP6mMGzMw0x6NnY5bCWKPRlxK P8Ig== X-Gm-Message-State: ALoCoQlZxBo81gF223Ssq+0BCRQKwjtQC9AyFSUpGYo1vsIwM2QK/E0VeU0yUJ16pozz4dy1JVRL X-Received: by 10.66.66.163 with SMTP id g3mr18303167pat.3.1385827000205; Sat, 30 Nov 2013 07:56:40 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.60.169 with SMTP id i9ls4101389qer.65.gmail; Sat, 30 Nov 2013 07:56:40 -0800 (PST) X-Received: by 10.220.47.10 with SMTP id l10mr38224vcf.32.1385827000098; Sat, 30 Nov 2013 07:56:40 -0800 (PST) Received: from mail-vc0-f170.google.com (mail-vc0-f170.google.com [209.85.220.170]) by mx.google.com with ESMTPS id be7si26560927vcb.110.2013.11.30.07.56.40 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 30 Nov 2013 07:56:40 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.170 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.170; Received: by mail-vc0-f170.google.com with SMTP id ht10so7547907vcb.1 for ; Sat, 30 Nov 2013 07:56:40 -0800 (PST) X-Received: by 10.220.11.7 with SMTP id r7mr46307248vcr.12.1385826999995; Sat, 30 Nov 2013 07:56:39 -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 u4csp3798vcz; Sat, 30 Nov 2013 07:56:39 -0800 (PST) X-Received: by 10.68.211.39 with SMTP id mz7mr21816483pbc.90.1385826998900; Sat, 30 Nov 2013 07:56:38 -0800 (PST) Received: from mail-pb0-f48.google.com (mail-pb0-f48.google.com [209.85.160.48]) by mx.google.com with ESMTPS id yg5si42860169pbc.146.2013.11.30.07.56.38 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 30 Nov 2013 07:56:38 -0800 (PST) Received-SPF: neutral (google.com: 209.85.160.48 is neither permitted nor denied by best guess record for domain of viresh.kumar@linaro.org) client-ip=209.85.160.48; Received: by mail-pb0-f48.google.com with SMTP id md12so16030345pbc.21 for ; Sat, 30 Nov 2013 07:56:38 -0800 (PST) X-Received: by 10.66.253.169 with SMTP id ab9mr2032700pad.156.1385826998464; Sat, 30 Nov 2013 07:56:38 -0800 (PST) Received: from localhost ([122.167.133.207]) by mx.google.com with ESMTPSA id fk4sm124598390pab.23.2013.11.30.07.56.35 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 30 Nov 2013 07:56:37 -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 2/5] cpufreq: send new set of notification for transition failures Date: Sat, 30 Nov 2013 21:26:20 +0530 Message-Id: <4834ba7f5ae3838515f7b85102987cc3ec066627.1385826776.git.viresh.kumar@linaro.org> 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.220.170 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. Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index a862aa9..557bb49 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1764,17 +1764,8 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy, pr_err("%s: Failed to change cpu frequency: %d\n", __func__, retval); - if (notify) { - /* - * Notify with old freq in case we failed to change - * frequency - */ - if (retval) - freqs.new = freqs.old; - - cpufreq_notify_transition(policy, &freqs, - CPUFREQ_POSTCHANGE); - } + if (notify) + cpufreq_notify_post_transition(policy, &freqs, retval); } out: