linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michael Turquette <mturquette@baylibre.com>
To: peterz@infradead.org, mingo@kernel.org
Cc: linux-kernel@vger.kernel.org, preeti@linux.vnet.ibm.com,
	Morten.Rasmussen@arm.com, riel@redhat.com, efault@gmx.de,
	nicolas.pitre@linaro.org, daniel.lezcano@linaro.org,
	dietmar.eggemann@arm.com, vincent.guittot@linaro.org,
	amit.kucheria@linaro.org, juri.lelli@arm.com, rjw@rjwysocki.net,
	viresh.kumar@linaro.org, ashwin.chaugule@linaro.org,
	alex.shi@linaro.org, linux-pm@vger.kernel.org,
	abelvesa@gmail.com, pebolle@tiscali.nl,
	Michael Turquette <mturquette@baylibre.com>,
	"Rafael J. Wysocki" <rafael@kernel.org>
Subject: [PATCH v3 2/4] cpufreq: introduce cpufreq_driver_might_sleep
Date: Fri, 26 Jun 2015 16:53:42 -0700	[thread overview]
Message-ID: <1435362824-26734-3-git-send-email-mturquette@linaro.org> (raw)
In-Reply-To: <1435362824-26734-1-git-send-email-mturquette@linaro.org>

From: Michael Turquette <mturquette@baylibre.com>

Some architectures and platforms perform CPU frequency transitions
through a non-blocking method, while some might block or sleep. This
distinction is important when trying to change frequency from interrupt
context or in any other non-interruptable context, such as from the
Linux scheduler.

Describe this distinction with a cpufreq driver flag,
CPUFREQ_DRIVER_WILL_NOT_SLEEP. The default is to not have this flag set,
thus erring on the side of caution.

cpufreq_driver_might_sleep() is also introduced in this patch. Setting
the above flag will allow this function to return false.

Cc: Rafael J. Wysocki <rafael@kernel.org>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Michael Turquette <mturquette@baylibre.com>
---
 drivers/cpufreq/cpufreq.c | 6 ++++++
 include/linux/cpufreq.h   | 9 +++++++++
 2 files changed, 15 insertions(+)

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 28e59a4..e5296c0 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -112,6 +112,12 @@ bool have_governor_per_policy(void)
 }
 EXPORT_SYMBOL_GPL(have_governor_per_policy);
 
+bool cpufreq_driver_might_sleep(void)
+{
+	return !(cpufreq_driver->flags & CPUFREQ_DRIVER_WILL_NOT_SLEEP);
+}
+EXPORT_SYMBOL_GPL(cpufreq_driver_might_sleep);
+
 struct kobject *get_governor_parent_kobj(struct cpufreq_policy *policy)
 {
 	if (have_governor_per_policy())
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index 2ee4888..1f2c9a1 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -157,6 +157,7 @@ u64 get_cpu_idle_time(unsigned int cpu, u64 *wall, int io_busy);
 int cpufreq_get_policy(struct cpufreq_policy *policy, unsigned int cpu);
 int cpufreq_update_policy(unsigned int cpu);
 bool have_governor_per_policy(void);
+bool cpufreq_driver_might_sleep(void);
 struct kobject *get_governor_parent_kobj(struct cpufreq_policy *policy);
 #else
 static inline unsigned int cpufreq_get(unsigned int cpu)
@@ -314,6 +315,14 @@ struct cpufreq_driver {
  */
 #define CPUFREQ_NEED_INITIAL_FREQ_CHECK	(1 << 5)
 
+/*
+ * Set by drivers that will never block or sleep during their frequency
+ * transition. Used to indicate when it is safe to call cpufreq_driver_target
+ * from non-interruptable context. Drivers must opt-in to this flag, as the
+ * safe default is that they might sleep.
+ */
+#define CPUFREQ_DRIVER_WILL_NOT_SLEEP	(1 << 6)
+
 int cpufreq_register_driver(struct cpufreq_driver *driver_data);
 int cpufreq_unregister_driver(struct cpufreq_driver *driver_data);
 
-- 
1.9.1


  parent reply	other threads:[~2015-06-26 23:54 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-26 23:53 [PATCH v3 0/4] scheduler-driven cpu frequency selection Michael Turquette
2015-06-26 23:53 ` [PATCH v3 1/4] arm: Frequency invariant scheduler load-tracking support Michael Turquette
2015-06-26 23:53 ` Michael Turquette [this message]
2015-06-27  0:48   ` [PATCH v3 2/4] cpufreq: introduce cpufreq_driver_might_sleep Felipe Balbi
     [not found]     ` <20150629162621.9112.4040@quantum>
2015-06-29 16:39       ` Felipe Balbi
2015-06-29 16:56         ` Michael Turquette
2015-06-29 17:03           ` Felipe Balbi
2015-06-29 17:10             ` Michael Turquette
2015-06-26 23:53 ` [PATCH v3 3/4] sched: scheduler-driven cpu frequency selection Michael Turquette
2015-06-27  0:47   ` Felipe Balbi
     [not found]     ` <20150629164943.9112.4253@quantum>
2015-06-29 16:55       ` Felipe Balbi
2015-07-06 20:06   ` Dietmar Eggemann
2015-06-26 23:53 ` [PATCH v3 4/4] [RFC] sched: cfs: cpu frequency scaling policy Michael Turquette
2015-07-03  9:57 ` [PATCH v3 0/4] scheduler-driven cpu frequency selection Vincent Guittot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1435362824-26734-3-git-send-email-mturquette@linaro.org \
    --to=mturquette@baylibre.com \
    --cc=Morten.Rasmussen@arm.com \
    --cc=abelvesa@gmail.com \
    --cc=alex.shi@linaro.org \
    --cc=amit.kucheria@linaro.org \
    --cc=ashwin.chaugule@linaro.org \
    --cc=daniel.lezcano@linaro.org \
    --cc=dietmar.eggemann@arm.com \
    --cc=efault@gmx.de \
    --cc=juri.lelli@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=nicolas.pitre@linaro.org \
    --cc=pebolle@tiscali.nl \
    --cc=peterz@infradead.org \
    --cc=preeti@linux.vnet.ibm.com \
    --cc=rafael@kernel.org \
    --cc=riel@redhat.com \
    --cc=rjw@rjwysocki.net \
    --cc=vincent.guittot@linaro.org \
    --cc=viresh.kumar@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).