From: Steve Muckle <steve.muckle@linaro.org>
To: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Viresh Kumar <viresh.kumar@linaro.org>
Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org,
Vincent Guittot <vincent.guittot@linaro.org>,
Morten Rasmussen <morten.rasmussen@arm.com>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
Juri Lelli <Juri.Lelli@arm.com>,
Patrick Bellasi <patrick.bellasi@arm.com>,
Michael Turquette <mturquette@baylibre.com>
Subject: [PATCH v2 1/3] cpufreq: add resolve_freq driver callback
Date: Wed, 25 May 2016 19:52:59 -0700 [thread overview]
Message-ID: <1464231181-30741-2-git-send-email-smuckle@linaro.org> (raw)
In-Reply-To: <1464231181-30741-1-git-send-email-smuckle@linaro.org>
Cpufreq governors may need to know what a particular target frequency
maps to in the driver without necessarily wanting to set the frequency.
Support this operation via a new cpufreq API,
cpufreq_driver_resolve_freq().
The above API will call a new cpufreq driver callback, resolve_freq(),
if it has been registered by the driver. If that callback has not been
registered and a frequency table is available then the frequency table
is walked using cpufreq_frequency_table_target().
UINT_MAX is returned if no driver callback or frequency table is
available.
Suggested-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Steve Muckle <smuckle@linaro.org>
---
drivers/cpufreq/cpufreq.c | 25 +++++++++++++++++++++++++
include/linux/cpufreq.h | 11 +++++++++++
2 files changed, 36 insertions(+)
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 77d77a4e3b74..3b44f4bdc071 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1849,6 +1849,31 @@ unsigned int cpufreq_driver_fast_switch(struct cpufreq_policy *policy,
}
EXPORT_SYMBOL_GPL(cpufreq_driver_fast_switch);
+unsigned int cpufreq_driver_resolve_freq(struct cpufreq_policy *policy,
+ unsigned int target_freq)
+{
+ struct cpufreq_frequency_table *freq_table;
+ int index, retval;
+
+ clamp_val(target_freq, policy->min, policy->max);
+
+ if (cpufreq_driver->resolve_freq)
+ return cpufreq_driver->resolve_freq(policy, target_freq);
+
+ freq_table = cpufreq_frequency_get_table(policy->cpu);
+ if (!freq_table)
+ return UINT_MAX;
+
+ retval = cpufreq_frequency_table_target(policy, freq_table,
+ target_freq, CPUFREQ_RELATION_L,
+ &index);
+ if (retval)
+ return UINT_MAX;
+
+ return freq_table[index].frequency;
+}
+EXPORT_SYMBOL_GPL(cpufreq_driver_resolve_freq);
+
/* Must set freqs->new to intermediate frequency */
static int __target_intermediate(struct cpufreq_policy *policy,
struct cpufreq_freqs *freqs, int index)
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index 4e81e08db752..675f17f98e75 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -271,6 +271,13 @@ struct cpufreq_driver {
int (*target_intermediate)(struct cpufreq_policy *policy,
unsigned int index);
+ /*
+ * Return the driver-supported frequency that a particular target
+ * frequency maps to (does not set the new frequency).
+ */
+ unsigned int (*resolve_freq)(struct cpufreq_policy *policy,
+ unsigned int target_freq);
+
/* should be defined, if possible */
unsigned int (*get)(unsigned int cpu);
@@ -487,6 +494,10 @@ int cpufreq_driver_target(struct cpufreq_policy *policy,
int __cpufreq_driver_target(struct cpufreq_policy *policy,
unsigned int target_freq,
unsigned int relation);
+
+unsigned int cpufreq_driver_resolve_freq(struct cpufreq_policy *policy,
+ unsigned int target_freq);
+
int cpufreq_register_governor(struct cpufreq_governor *governor);
void cpufreq_unregister_governor(struct cpufreq_governor *governor);
--
2.4.10
next prev parent reply other threads:[~2016-05-26 2:52 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-26 2:52 [PATCH v2 0/3] cpufreq: avoid redundant driver calls in schedutil Steve Muckle
2016-05-26 2:52 ` Steve Muckle [this message]
2016-05-26 6:25 ` [PATCH v2 1/3] cpufreq: add resolve_freq driver callback Viresh Kumar
2016-05-30 15:31 ` Steve Muckle
2016-05-31 5:30 ` Viresh Kumar
2016-05-31 18:48 ` Steve Muckle
2016-05-31 11:14 ` Viresh Kumar
2016-05-31 18:12 ` Steve Muckle
2016-05-26 2:53 ` [PATCH v2 2/3] cpufreq: acpi-cpufreq: add resolve_freq callback Steve Muckle
2016-05-26 6:43 ` Viresh Kumar
2016-05-30 16:20 ` Steve Muckle
2016-05-31 11:38 ` Viresh Kumar
2016-05-26 2:53 ` [PATCH v2 3/3] cpufreq: schedutil: map raw required frequency to driver frequency Steve Muckle
2016-05-26 7:16 ` Viresh Kumar
2016-05-29 0:40 ` Rafael J. Wysocki
2016-05-30 10:18 ` Viresh Kumar
2016-05-30 14:25 ` Rafael J. Wysocki
2016-05-30 15:32 ` Viresh Kumar
2016-05-30 19:08 ` Rafael J. Wysocki
2016-05-31 9:02 ` Peter Zijlstra
2016-05-31 1:49 ` Wanpeng Li
2016-05-30 16:35 ` Steve Muckle
2016-06-01 10:50 ` Viresh Kumar
2016-05-27 5:41 ` Wanpeng Li
2016-05-30 16:48 ` Steve Muckle
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=1464231181-30741-2-git-send-email-smuckle@linaro.org \
--to=steve.muckle@linaro.org \
--cc=Juri.Lelli@arm.com \
--cc=dietmar.eggemann@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=morten.rasmussen@arm.com \
--cc=mturquette@baylibre.com \
--cc=patrick.bellasi@arm.com \
--cc=peterz@infradead.org \
--cc=rafael@kernel.org \
--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).