From patchwork Fri Aug 16 02:24:58 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 19174 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ye0-f197.google.com (mail-ye0-f197.google.com [209.85.213.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9D3762486D for ; Fri, 16 Aug 2013 02:26:00 +0000 (UTC) Received: by mail-ye0-f197.google.com with SMTP id q8sf1556669yen.8 for ; Thu, 15 Aug 2013 19:26:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-gm-message-state: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=fg8KA7o/qPQzvOxetAtwbUN56rk/3HlnVJUwuiu+U3g=; b=VOnoRYRT4mhXcp0r8jZD78mn4xs4Nu5ydnhJSSGG1xU3pAck7KetPcj+qR7ccjvGNS soj9AoDY4sJf/Y9a6arSjrYOp9TaquwNJx+73OaeeLovbK9QY3ijbbT1lMeg09OkEZMZ p5364gbsWw9EvtsRQ5D1FlvT+FyuE1bq3g/y7gawarrNH5F0kx1sjrqaV1beexGB03U1 6hJRC5L9Q2IWLfp7e6An5uRgVL7Tu1niiByObxW9LQEBtFDBep/FTniLl98CCrcjlfh4 tEnp/cZryNT/MtkJh8pRfKqtSm/CLG+v2cHcnVJVGIqwO1CBgSxQ8L6S4Cz9bOd7h+Na MUWw== X-Received: by 10.224.137.137 with SMTP id w9mr697640qat.6.1376619960137; Thu, 15 Aug 2013 19:26:00 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.58.244 with SMTP id u20ls605358qeq.74.gmail; Thu, 15 Aug 2013 19:26:00 -0700 (PDT) X-Received: by 10.58.19.162 with SMTP id g2mr17380953vee.12.1376619959928; Thu, 15 Aug 2013 19:25:59 -0700 (PDT) Received: from mail-vc0-f182.google.com (mail-vc0-f182.google.com [209.85.220.182]) by mx.google.com with ESMTPS id x16si685471vcu.100.2013.08.15.19.25.59 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 15 Aug 2013 19:25:59 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.182 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.182; Received: by mail-vc0-f182.google.com with SMTP id hf12so1061394vcb.41 for ; Thu, 15 Aug 2013 19:25:59 -0700 (PDT) X-Gm-Message-State: ALoCoQmV4wFqgGaq3/noGRjg7sDRRt9n9HNpfiRqx1gZ3/uxE84LIl4roQFWUznvI1vqXoW7Y87X X-Received: by 10.52.34.74 with SMTP id x10mr14485822vdi.13.1376619959798; Thu, 15 Aug 2013 19:25:59 -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.220.174.196 with SMTP id u4csp45122vcz; Thu, 15 Aug 2013 19:25:59 -0700 (PDT) X-Received: by 10.66.219.200 with SMTP id pq8mr574622pac.123.1376619958766; Thu, 15 Aug 2013 19:25:58 -0700 (PDT) Received: from mail-pb0-f50.google.com (mail-pb0-f50.google.com [209.85.160.50]) by mx.google.com with ESMTPS id bo2si1819669pbb.74.2013.08.15.19.25.58 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 15 Aug 2013 19:25:58 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of viresh.kumar@linaro.org) client-ip=209.85.160.50; Received: by mail-pb0-f50.google.com with SMTP id uo5so1470219pbc.37 for ; Thu, 15 Aug 2013 19:25:58 -0700 (PDT) X-Received: by 10.68.219.33 with SMTP id pl1mr11594198pbc.147.1376619958264; Thu, 15 Aug 2013 19:25:58 -0700 (PDT) Received: from localhost ([122.172.193.46]) by mx.google.com with ESMTPSA id om2sm2685749pbc.30.2013.08.15.19.25.49 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 15 Aug 2013 19:25:57 -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, linux-arm-kernel@lists.infradead.org, Viresh Kumar , Andrew Lunn , "David S. Miller" , Dmitry Eremin-Solenikov , Eric Miao , Hans-Christian Egtvedt , Jesper Nilsson , John Crispin , Kukjin Kim , Linus Walleij , linux-cris-kernel@axis.com, Mikael Starvik , Russell King , Santosh Shilimkar , Sekhar Nori , Shawn Guo , sparclinux@vger.kernel.org, spear-devel@list.st.com, Stephen Warren , Steven Miao , Tony Luck Subject: [PATCH 01/34] cpufreq: move freq change notifications to cpufreq core Date: Fri, 16 Aug 2013 07:54:58 +0530 Message-Id: <8d083bb5c2d167aa0b52f48c3f17a1320b3e0249.1376619363.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.220.182 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: , Most of the drivers do following in their ->target_index() routines: struct cpufreq_freqs freqs; freqs.old = old freq... freqs.new = new freq... cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); /* Change rate here */ cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE); This is replicated over all cpufreq drivers today and there doesn't exists a good enough reason why this shouldn't be moved to cpufreq core instead. There are few special cases though, like exynos5440, which doesn't do everything on the call to ->target_index() routine and call some kind of bottom halves for doing this work, work/tasklet/etc.. They may continue doing notification from their own code and so this patch introduces another flag: CPUFREQ_NO_NOTIFICATION, which will be set by such drivers. Cc: Andrew Lunn Cc: David S. Miller Cc: Dmitry Eremin-Solenikov Cc: Eric Miao Cc: Hans-Christian Egtvedt Cc: Jesper Nilsson Cc: John Crispin Cc: Kukjin Kim Cc: Linus Walleij Cc: linux-cris-kernel@axis.com Cc: Mikael Starvik Cc: Russell King Cc: Santosh Shilimkar Cc: Sekhar Nori Cc: Shawn Guo Cc: sparclinux@vger.kernel.org Cc: spear-devel@list.st.com Cc: Stephen Warren Cc: Steven Miao Cc: Tony Luck Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq.c | 34 ++++++++++++++++++++++++++++++++++ include/linux/cpufreq.h | 6 ++++++ 2 files changed, 40 insertions(+) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index a7a1d3e..2782949 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1673,6 +1673,9 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy, retval = cpufreq_driver->target(policy, target_freq, relation); else if (cpufreq_driver->target_index) { struct cpufreq_frequency_table *freq_table; + struct cpufreq_freqs freqs; + unsigned long flags; + bool notify; int index; freq_table = cpufreq_frequency_get_table(policy->cpu); @@ -1691,7 +1694,38 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy, if (freq_table[index].frequency == policy->cur) return 0; + read_lock_irqsave(&cpufreq_driver_lock, flags); + notify = !(cpufreq_driver->flags | CPUFREQ_NO_NOTIFICATION); + read_unlock_irqrestore(&cpufreq_driver_lock, flags); + + if (notify) { + freqs.old = policy->cur; + freqs.new = freq_table[index].frequency; + + pr_debug("%s: cpu: %d, oldfreq: %u, new freq: %u\n", + __func__, policy->cpu, freqs.old, + freqs.new); + + cpufreq_notify_transition(policy, &freqs, + CPUFREQ_PRECHANGE); + } + retval = cpufreq_driver->target_index(policy, index); + if (retval) + 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); + } } return retval; diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index ff9c8df..62ce478 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -221,6 +221,12 @@ struct cpufreq_driver { * frequency transitions */ #define CPUFREQ_PM_NO_WARN 0x04 /* don't warn on suspend/resume speed * mismatches */ +/* + * Driver will call cpufreq_notify_transition() in its target_index() routine + * and so cpufreq core must not call it. Only useful for drivers that implement + * target_index(), unused otherwise. + */ +#define CPUFREQ_NO_NOTIFICATION 0x08 int cpufreq_register_driver(struct cpufreq_driver *driver_data); int cpufreq_unregister_driver(struct cpufreq_driver *driver_data);