From patchwork Sat Nov 30 15:56:21 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 21904 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f69.google.com (mail-oa0-f69.google.com [209.85.219.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id ECA8220DB9 for ; Sat, 30 Nov 2013 15:56:48 +0000 (UTC) Received: by mail-oa0-f69.google.com with SMTP id h16sf36203852oag.4 for ; Sat, 30 Nov 2013 07:56:48 -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=f1QwXOhl7pvjB55OUO9Yr2CZV/CWAuU+figasMNjJWty/BhJIRMm2GGxygiSQqxB+W EEouVgrFOhUeXAzn8yKfmFaF001hkHKpTxDP9MMDp4qMKQuT3jQ5KqiTrp3JQDtQSbQA riKjezFlJf4XTDkUjKlOIxjuKaCVD7Sa1v/xD7UXcYOzrygnolPjPzADdsOFH+mVyHxE 7uKiD8C5A1JXPPuCcOtOgKZGNBED4XmQXLz6Y3XqmUarX9rNPKGQ+sizvZP+mdOm5SwW aXxin2HQzD9S1A9IAJTlqstcRvccifPwKUoQDIj3AuIR3M8uAXV4GD/oo9kXnSYyngrj Gd1A== X-Gm-Message-State: ALoCoQlS/ExtXzBisgxwzjyfzIDU4FUL5evKhcsPPpihEf7LeFwbxN00py6rklavALufecGnCqd9 X-Received: by 10.182.111.227 with SMTP id il3mr1055287obb.41.1385827008371; Sat, 30 Nov 2013 07:56:48 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.24.145 with SMTP id u17ls127252qef.42.gmail; Sat, 30 Nov 2013 07:56:48 -0800 (PST) X-Received: by 10.58.95.97 with SMTP id dj1mr2481605veb.21.1385827008281; Sat, 30 Nov 2013 07:56:48 -0800 (PST) Received: from mail-ve0-f176.google.com (mail-ve0-f176.google.com [209.85.128.176]) by mx.google.com with ESMTPS id a6si26514588vdp.65.2013.11.30.07.56.48 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 30 Nov 2013 07:56:48 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.176 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.176; Received: by mail-ve0-f176.google.com with SMTP id oz11so7696765veb.35 for ; Sat, 30 Nov 2013 07:56:48 -0800 (PST) X-Received: by 10.221.37.9 with SMTP id tc9mr33026vcb.39.1385827007955; Sat, 30 Nov 2013 07:56:47 -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 u4csp3805vcz; Sat, 30 Nov 2013 07:56:47 -0800 (PST) X-Received: by 10.69.31.1 with SMTP id ki1mr22027329pbd.124.1385827007013; Sat, 30 Nov 2013 07:56:47 -0800 (PST) Received: from mail-pd0-f174.google.com (mail-pd0-f174.google.com [209.85.192.174]) by mx.google.com with ESMTPS id kn3si42861485pbc.64.2013.11.30.07.56.46 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 30 Nov 2013 07:56:47 -0800 (PST) Received-SPF: neutral (google.com: 209.85.192.174 is neither permitted nor denied by best guess record for domain of viresh.kumar@linaro.org) client-ip=209.85.192.174; Received: by mail-pd0-f174.google.com with SMTP id y13so15253006pdi.5 for ; Sat, 30 Nov 2013 07:56:46 -0800 (PST) X-Received: by 10.67.3.34 with SMTP id bt2mr58687063pad.3.1385827006628; Sat, 30 Nov 2013 07:56:46 -0800 (PST) Received: from localhost ([122.167.133.207]) by mx.google.com with ESMTPSA id hn5sm98846769pbb.25.2013.11.30.07.56.43 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 30 Nov 2013 07:56:46 -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 3/5] cpufreq: pcc: send new set of notification for transition failures Date: Sat, 30 Nov 2013 21:26:21 +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.176 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)