From patchwork Mon Dec 2 05:34:16 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 21911 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f197.google.com (mail-vc0-f197.google.com [209.85.220.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D451120DB9 for ; Mon, 2 Dec 2013 05:34:38 +0000 (UTC) Received: by mail-vc0-f197.google.com with SMTP id id10sf27576053vcb.4 for ; Sun, 01 Dec 2013 21:34:38 -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=X9GSNOGKxE7Uc4g02ue2PlW1Y5LO6dUniOvmPNaI6Iw=; b=HKme1iU8zZjg9gyY6P375BT1/iOOl9YWQnZ4dXOIAx50vf2v9xZL+o0YHVUm7l4vr9 bLAf3aGqU4XyOym1m6k4HUJxCq+sUy5/0ga+eV5yLDS6zB9hJhK6pNxbNWWO/J0Vk6Uo ARTyoKs0DB1MF8q5BaZvsM30EQWJghTm1yOzp5oThVCuRvMx9HgSquI76F+6LfHXPOk2 y8Rgfwi5AQ/bR4xh+PU5FvNjHQqXIYbvK3ZtPPaap+/cG5VSjZdfkO/V2BZ1grRkufhN kmaZtelBHcuSV0jkF+eEBxblt/fHIDmShhStivD66FjgZ1BgwhCcM98E1/llc6ucatx9 bEdg== X-Gm-Message-State: ALoCoQkoZa+MnTBhWRZCcuc67QwjvM+e3hsCE/8jaL5q/2JNkDwooYAx3TEFspvzslETkSO4PYT6 X-Received: by 10.59.5.68 with SMTP id ck4mr22391097ved.9.1385962478409; Sun, 01 Dec 2013 21:34:38 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.97.201 with SMTP id ec9ls1816129qeb.60.gmail; Sun, 01 Dec 2013 21:34:38 -0800 (PST) X-Received: by 10.220.113.143 with SMTP id a15mr142922vcq.38.1385962478323; Sun, 01 Dec 2013 21:34:38 -0800 (PST) Received: from mail-vc0-f178.google.com (mail-vc0-f178.google.com [209.85.220.178]) by mx.google.com with ESMTPS id tw10si28993940vec.120.2013.12.01.21.34.38 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 01 Dec 2013 21:34:38 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.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.220.178; Received: by mail-vc0-f178.google.com with SMTP id lh4so8058991vcb.37 for ; Sun, 01 Dec 2013 21:34:38 -0800 (PST) X-Received: by 10.221.40.10 with SMTP id to10mr1151822vcb.22.1385962478258; Sun, 01 Dec 2013 21:34:38 -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 u4csp91881vcz; Sun, 1 Dec 2013 21:34:38 -0800 (PST) X-Received: by 10.229.56.200 with SMTP id z8mr109768500qcg.1.1385962477837; Sun, 01 Dec 2013 21:34:37 -0800 (PST) Received: from mail-qa0-f52.google.com (mail-qa0-f52.google.com [209.85.216.52]) by mx.google.com with ESMTPS id q18si25050926qeu.6.2013.12.01.21.34.37 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 01 Dec 2013 21:34:37 -0800 (PST) Received-SPF: neutral (google.com: 209.85.216.52 is neither permitted nor denied by best guess record for domain of viresh.kumar@linaro.org) client-ip=209.85.216.52; Received: by mail-qa0-f52.google.com with SMTP id k4so3975173qaq.4 for ; Sun, 01 Dec 2013 21:34:37 -0800 (PST) X-Received: by 10.49.2.170 with SMTP id 10mr2705755qev.24.1385962477619; Sun, 01 Dec 2013 21:34:37 -0800 (PST) Received: from localhost (git.linaro.org. [54.235.93.228]) by mx.google.com with ESMTPSA id g10sm2669656qaf.9.2013.12.01.21.34.35 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sun, 01 Dec 2013 21:34:36 -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 5/5] cpufreq: unicore2: send new set of notification for transition failures Date: Mon, 2 Dec 2013 11:04:16 +0530 Message-Id: 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.220.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 returns a proper error message in case frequency transition failed. Signed-off-by: Viresh Kumar --- drivers/cpufreq/unicore2-cpufreq.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/cpufreq/unicore2-cpufreq.c b/drivers/cpufreq/unicore2-cpufreq.c index 951152f..99d280d6 100644 --- a/drivers/cpufreq/unicore2-cpufreq.c +++ b/drivers/cpufreq/unicore2-cpufreq.c @@ -38,19 +38,17 @@ static int ucv2_target(struct cpufreq_policy *policy, unsigned int target_freq, unsigned int relation) { - unsigned int cur = policy->cur; struct cpufreq_freqs freqs; + int ret; - cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); - - if (!clk_set_rate(policy->clk, target_freq * 1000)) { - freqs.old = cur; - freqs.new = target_freq; - } + freqs.old = policy->cur; + freqs.new = target_freq; - cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); + cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); + ret = clk_set_rate(policy->clk, target_freq * 1000); + cpufreq_notify_post_transition(policy, &freqs, ret); - return 0; + return ret; } static int __init ucv2_cpu_init(struct cpufreq_policy *policy)