From patchwork Mon Dec 2 05:34:13 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 21908 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f200.google.com (mail-ie0-f200.google.com [209.85.223.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8E82420DB9 for ; Mon, 2 Dec 2013 05:34:26 +0000 (UTC) Received: by mail-ie0-f200.google.com with SMTP id at1sf40127599iec.7 for ; Sun, 01 Dec 2013 21:34:26 -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=6qpbye/lOkX70LJu9ny9Vjy6a3h6mfrZTJzf5Ut+QxE=; b=Cf091Oe48QrR/KFs/Bmu+4HZu0KGuwml4mfF4AHOxlbnS5Ty17cLYHpfk09AoyZ75P hZ0FiwbyDqjaw1mfEX0c3LVAffr2D2/IUCVBLxAQm2Av/tc6mOUbhzvdS9I4kN1YDi2y opbMpmFoWGzJ+H1Ie3PqBS5Kz3wAnSpcRnwvIdej9n3tA/MxQ3ekP3r8jna6B42cgLSu sisPFJRkp2E0nZqsSYvejEo4aKpMRcV0KLhR6HXVf4vBEohm8AqoO91/n7YTR4TCTSsQ Qbsjg4Lnoq07E8r3JxSUoyVJdSR2r6IjqyepbYgogUAUk9yIcc0h8BPTgjTPzJjrjt+S bE1Q== X-Gm-Message-State: ALoCoQm+pd8FFdLHmQ59dURve8JZH577waUUm0x43K072CK0e+2MElSKoZG8wfsanUM+k0OXWbQV X-Received: by 10.42.67.19 with SMTP id r19mr17784394ici.6.1385962466293; Sun, 01 Dec 2013 21:34:26 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.2.41 with SMTP id 9ls1073386qer.99.gmail; Sun, 01 Dec 2013 21:34:26 -0800 (PST) X-Received: by 10.221.40.10 with SMTP id to10mr1151443vcb.22.1385962466210; Sun, 01 Dec 2013 21:34:26 -0800 (PST) Received: from mail-ve0-f174.google.com (mail-ve0-f174.google.com [209.85.128.174]) by mx.google.com with ESMTPS id v5si29004338ves.80.2013.12.01.21.34.26 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 01 Dec 2013 21:34:26 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.174 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.174; Received: by mail-ve0-f174.google.com with SMTP id pa12so8304139veb.19 for ; Sun, 01 Dec 2013 21:34:26 -0800 (PST) X-Received: by 10.58.107.4 with SMTP id gy4mr146236veb.39.1385962466091; Sun, 01 Dec 2013 21:34:26 -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 u4csp91869vcz; Sun, 1 Dec 2013 21:34:25 -0800 (PST) X-Received: by 10.49.39.165 with SMTP id q5mr30334026qek.48.1385962465702; Sun, 01 Dec 2013 21:34:25 -0800 (PST) Received: from mail-qe0-f42.google.com (mail-qe0-f42.google.com [209.85.128.42]) by mx.google.com with ESMTPS id ej3si16353260qab.18.2013.12.01.21.34.25 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 01 Dec 2013 21:34:25 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.42 is neither permitted nor denied by best guess record for domain of viresh.kumar@linaro.org) client-ip=209.85.128.42; Received: by mail-qe0-f42.google.com with SMTP id b4so12083201qen.1 for ; Sun, 01 Dec 2013 21:34:25 -0800 (PST) X-Received: by 10.224.138.4 with SMTP id y4mr109547801qat.65.1385962465515; Sun, 01 Dec 2013 21:34:25 -0800 (PST) Received: from localhost (git.linaro.org. [54.235.93.228]) by mx.google.com with ESMTPSA id a5sm94583483qae.2.2013.12.01.21.34.24 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sun, 01 Dec 2013 21:34:25 -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 2/5] cpufreq: send new set of notification for transition failures Date: Mon, 2 Dec 2013 11:04:13 +0530 Message-Id: <09131009236f613c6589737449f5973f7eb6f216.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.174 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 3b877d4..a7fcb84 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1815,17 +1815,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: