From patchwork Mon Jun 24 13:08:17 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 18068 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f72.google.com (mail-yh0-f72.google.com [209.85.213.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id BB0EC25CFE for ; Mon, 24 Jun 2013 13:08:20 +0000 (UTC) Received: by mail-yh0-f72.google.com with SMTP id z20sf16018070yhz.11 for ; Mon, 24 Jun 2013 06:08:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-beenthere:x-forwarded-to:x-forwarded-for:delivered-to :mime-version:in-reply-to:references:date:message-id:subject:from:to :cc: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 :content-type; bh=sv38DjlRywiL4n7mJ11+XLlnpQQT8+141KIFScU5YZQ=; b=Yen/UMOEtrptJf0h6oxmU39tKfyAeEAkLItVUVLT5PpY3/E42bIwrIki6OUGvTdizD yf4MVOBHafrbx39MPH063VPk8C6IU9SXxiFbd2jbc9GsHnHjaStx45Wv2Sql7odM2hu3 zbVWVz3m8+FFO5DVC0msNKV8wZG/AjXwbFr4lvzkOjvB3EnwC8gi9vYz2hKL7ia70b8Z MDNhqB8coDjspxdCAL9yrQG1PK6LVAgmTrgoqs7AWPEP+4PJEK7jevLLaQUi+dUL3v4U rdTDI51iZsbCM/ebzvYzG88r+Al+6V8r7ghdqknG3PZtu/Rgpcsa8gdEH1CMy4D7wgkD 5GSQ== X-Received: by 10.236.74.169 with SMTP id x29mr13686862yhd.34.1372079300224; Mon, 24 Jun 2013 06:08:20 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.108.98 with SMTP id hj2ls1979739qeb.16.gmail; Mon, 24 Jun 2013 06:08:20 -0700 (PDT) X-Received: by 10.58.227.198 with SMTP id sc6mr7613692vec.59.1372079300067; Mon, 24 Jun 2013 06:08:20 -0700 (PDT) Received: from mail-vb0-x229.google.com (mail-vb0-x229.google.com [2607:f8b0:400c:c02::229]) by mx.google.com with ESMTPS id ex7si4528190vdb.135.2013.06.24.06.08.20 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 24 Jun 2013 06:08:20 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c02::229 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c02::229; Received: by mail-vb0-f41.google.com with SMTP id p13so8166721vbe.28 for ; Mon, 24 Jun 2013 06:08:20 -0700 (PDT) X-Received: by 10.52.77.5 with SMTP id o5mr6189937vdw.46.1372079299926; Mon, 24 Jun 2013 06:08:19 -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 yu8csp26810veb; Mon, 24 Jun 2013 06:08:18 -0700 (PDT) X-Received: by 10.182.61.73 with SMTP id n9mr8104573obr.86.1372079298535; Mon, 24 Jun 2013 06:08:18 -0700 (PDT) Received: from mail-oa0-x22f.google.com (mail-oa0-x22f.google.com [2607:f8b0:4003:c02::22f]) by mx.google.com with ESMTPS id nq7si6654137obc.83.2013.06.24.06.08.18 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 24 Jun 2013 06:08:18 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:4003:c02::22f is neither permitted nor denied by best guess record for domain of viresh.kumar@linaro.org) client-ip=2607:f8b0:4003:c02::22f; Received: by mail-oa0-f47.google.com with SMTP id m1so12055519oag.34 for ; Mon, 24 Jun 2013 06:08:18 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.60.93.33 with SMTP id cr1mr11219738oeb.116.1372079298122; Mon, 24 Jun 2013 06:08:18 -0700 (PDT) Received: by 10.182.96.138 with HTTP; Mon, 24 Jun 2013 06:08:17 -0700 (PDT) In-Reply-To: <1894928.On8nI7rMdZ@vostro.rjw.lan> References: <0bebf56a27f799a282cc00d0c17c187f9941f122.1371630975.git.viresh.kumar@linaro.org> <1894928.On8nI7rMdZ@vostro.rjw.lan> Date: Mon, 24 Jun 2013 18:38:17 +0530 Message-ID: Subject: Re: [PATCH 13/13] cpufreq: make sure frequency transitions are serialized From: Viresh Kumar To: "Rafael J. Wysocki" 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, dave.martin@arm.com X-Gm-Message-State: ALoCoQnS7qnR2mZxblbQPkKxhlNDkh1h8++o86NPxnOZwUNnkqyutl3TxZHXmhE55cOUfjRacIzf X-Original-Sender: viresh.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c02::229 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: , On 24 June 2013 17:13, Rafael J. Wysocki wrote: > On Wednesday, June 19, 2013 02:23:07 PM Viresh Kumar wrote: >> case CPUFREQ_POSTCHANGE: >> + WARN_ON(!transition_ongoing--); > > Shouldn't we try to avoid going into the negative range here? What about this patch? Find it attached to apply. * "old frequency". @@ -283,6 +293,13 @@ void __cpufreq_notify_transition(struct cpufreq_policy *policy, break; case CPUFREQ_POSTCHANGE: + if (!transition_ongoing) { + WARN(1, "No frequency transition in progress\n"); + return; + } + + transition_ongoing--; + adjust_jiffies(CPUFREQ_POSTCHANGE, freqs); pr_debug("FREQ: %lu - CPU: %lu", (unsigned long)freqs->new, (unsigned long)freqs->cpu); @@ -1458,6 +1475,8 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy, if (cpufreq_disabled()) return -ENODEV; + if (transition_ongoing) + return -EBUSY; /* Make sure that target_freq is within supported range */ if (target_freq > policy->max) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 2d53f47..6624694 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -107,6 +107,9 @@ static void handle_update(struct work_struct *work); static BLOCKING_NOTIFIER_HEAD(cpufreq_policy_notifier_list); static struct srcu_notifier_head cpufreq_transition_notifier_list; +/* Tracks status of transition */ +static int transition_ongoing; + static bool init_cpufreq_transition_notifier_list_called; static int __init init_cpufreq_transition_notifier_list(void) { @@ -264,6 +267,13 @@ void __cpufreq_notify_transition(struct cpufreq_policy *policy, switch (state) { case CPUFREQ_PRECHANGE: + if (transition_ongoing) { + WARN(1, "In middle of another frequency transition\n"); + return; + } + + transition_ongoing++; + /* detect if the driver reported a value as "old frequency" * which is not equal to what the cpufreq core thinks is