From patchwork Tue Jul 2 11:06:28 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 18233 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qe0-f71.google.com (mail-qe0-f71.google.com [209.85.128.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 0873B2391D for ; Tue, 2 Jul 2013 11:07:07 +0000 (UTC) Received: by mail-qe0-f71.google.com with SMTP id 1sf5185943qee.10 for ; Tue, 02 Jul 2013 04:07:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-beenthere:x-forwarded-to:x-forwarded-for :delivered-to:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe; bh=dvqJ9odVNCgrz1143Uk4w0nb7lvl6j4PujiAQO0Nlag=; b=cGR+6Zs2SfY2aB9/2Lulb+fOVm1MV4FPvcnynf824TfkyxLov1APGipeVToa5d0AZn V7fouMvUN41E/w3u+3DG7GzeBDqe0S1XtsB6GuI4sGazojAfqt9oX2JP0xK9CeGrxKND HIvEP+HvJKq6aoRTC2izaXCgZXudsENS6S78hi7AY4N63ALinJdOiViSC9RyS5AFquPs u3xpl1PHBk5F+1PIDI1jBNc7yEqCjbg/Q/cef8c1pJ0uv/5BqewZHwFq8NsDq/h6kEQ6 /9PmNF/h1/ePRfIA+2jsgLJ10gsu9cNfLCwjiH4EkmZB7BlC9KAr5dHsh+IZx407pLMX 7EsA== X-Received: by 10.59.5.72 with SMTP id ck8mr3493673ved.35.1372763226473; Tue, 02 Jul 2013 04:07:06 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.120.234 with SMTP id lf10ls2586009qeb.49.gmail; Tue, 02 Jul 2013 04:07:06 -0700 (PDT) X-Received: by 10.52.72.15 with SMTP id z15mr9187431vdu.91.1372763226299; Tue, 02 Jul 2013 04:07:06 -0700 (PDT) Received: from mail-vb0-f45.google.com (mail-vb0-f45.google.com [209.85.212.45]) by mx.google.com with ESMTPS id sz6si5857493vdc.49.2013.07.02.04.07.06 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 02 Jul 2013 04:07:06 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.45 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.45; Received: by mail-vb0-f45.google.com with SMTP id p14so4423257vbm.4 for ; Tue, 02 Jul 2013 04:07:06 -0700 (PDT) X-Received: by 10.58.251.144 with SMTP id zk16mr10861950vec.37.1372763226186; Tue, 02 Jul 2013 04:07:06 -0700 (PDT) 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.58.165.8 with SMTP id yu8csp5593veb; Tue, 2 Jul 2013 04:07:05 -0700 (PDT) X-Received: by 10.66.240.104 with SMTP id vz8mr4341085pac.143.1372763225085; Tue, 02 Jul 2013 04:07:05 -0700 (PDT) Received: from mail-pd0-f176.google.com (mail-pd0-f176.google.com [209.85.192.176]) by mx.google.com with ESMTPS id pn6si13447554pbb.291.2013.07.02.04.07.04 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 02 Jul 2013 04:07:05 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.192.176 is neither permitted nor denied by best guess record for domain of viresh.kumar@linaro.org) client-ip=209.85.192.176; Received: by mail-pd0-f176.google.com with SMTP id t12so3480302pdi.35 for ; Tue, 02 Jul 2013 04:07:04 -0700 (PDT) X-Received: by 10.66.240.104 with SMTP id vz8mr4341024pac.143.1372763224317; Tue, 02 Jul 2013 04:07:04 -0700 (PDT) Received: from localhost ([223.182.123.252]) by mx.google.com with ESMTPSA id py6sm23488021pbb.33.2013.07.02.04.06.50 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 02 Jul 2013 04:07:03 -0700 (PDT) From: Viresh Kumar To: rjw@sisk.pl Cc: linaro-kernel@lists.linaro.org, patches@linaro.org, cpufreq@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, robin.randhawa@arm.com, Steve.Bannister@arm.com, Liviu.Dudau@arm.com, charles.garcia-tobin@arm.com, arvind.chauhan@arm.com, broonie@linaro.org, Viresh Kumar Subject: [PATCH] cpufreq: Fix serialization of frequency transitions Date: Tue, 2 Jul 2013 16:36:28 +0530 Message-Id: X-Mailer: git-send-email 1.7.12.rc2.18.g61b472e X-Gm-Message-State: ALoCoQm/USgMI4Shn6og2zmtYtLWNTd7DPFwxICW/fKUNjgI3jsCdNngcRCfF3cJuYi4YTUnSugU X-Original-Sender: viresh.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.45 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: , Commit 7c30ed ("cpufreq: make sure frequency transitions are serialized") interacts poorly with systems that have a single core freqency for all cores. On such systems we have a single policy for all cores with several CPUs. When we do a frequency transition the governor calls the pre and post change notifiers which causes cpufreq_notify_transition() per CPU. Since the policy is the same for all of them all CPUs after the first and the warnings added are generated by checking a per-policy flag the warnings will be triggered for all cores after the first. Fix this by allowing notifier to be called for n times. Where n is the number of cpus in policy->cpus. Reported-and-Tested-by: Mark Brown Signed-off-by: Viresh Kumar --- Hi Rafael, This is a fix for 3.11. drivers/cpufreq/cpufreq.c | 7 ++++--- include/linux/cpufreq.h | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index b557503..b7bda8d 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -312,11 +312,12 @@ static void __cpufreq_notify_transition(struct cpufreq_policy *policy, switch (state) { case CPUFREQ_PRECHANGE: - if (WARN(policy->transition_ongoing, + if (WARN(policy->transition_ongoing == + cpumask_weight(policy->cpus), "In middle of another frequency transition\n")) return; - policy->transition_ongoing = true; + policy->transition_ongoing++; /* detect if the driver reported a value as "old frequency" * which is not equal to what the cpufreq core thinks is @@ -341,7 +342,7 @@ static void __cpufreq_notify_transition(struct cpufreq_policy *policy, "No frequency transition in progress\n")) return; - policy->transition_ongoing = false; + policy->transition_ongoing--; adjust_jiffies(CPUFREQ_POSTCHANGE, freqs); pr_debug("FREQ: %lu - CPU: %lu", (unsigned long)freqs->new, diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index 4d7390b..90d5a15 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -119,7 +119,7 @@ struct cpufreq_policy { struct kobject kobj; struct completion kobj_unregister; - bool transition_ongoing; /* Tracks transition status */ + int transition_ongoing; /* Tracks transition status */ }; #define CPUFREQ_ADJUST (0)