From: Viresh Kumar <viresh.kumar@linaro.org>
To: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Steve Muckle <steve.muckle@linaro.org>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
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>,
Steve Muckle <smuckle@linaro.org>
Subject: Re: [PATCH v3 1/3] cpufreq: add cpufreq_driver_resolve_freq()
Date: Thu, 21 Jul 2016 13:30:41 -0700 [thread overview]
Message-ID: <20160721203041.GH3122@ubuntu> (raw)
In-Reply-To: <2012245.HQXNKhffmu@vostro.rjw.lan>
On 21-07-16, 22:31, Rafael J. Wysocki wrote:
> On Thursday, July 21, 2016 12:59:26 PM Viresh Kumar wrote:
> > On 13-07-16, 13:25, Steve Muckle wrote:
> > > 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(). This API returns the lowest driver
> > > frequency equal or greater than the target frequency
> > > (CPUFREQ_RELATION_L), subject to any policy (min/max) or driver
> > > limitations. The mapping is also cached in the policy so that a
> > > subsequent fast_switch operation can avoid repeating the same lookup.
> > >
> > > The API will call a new cpufreq driver callback, resolve_freq(), if it
> > > has been registered by the driver. Otherwise the frequency is resolved
> > > via cpufreq_frequency_table_target(). Rather than require ->target()
> > > style drivers to provide a resolve_freq() callback it is left to the
> > > caller to ensure that the driver implements this callback if necessary
> > > to use cpufreq_driver_resolve_freq().
> > >
> > > 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 | 16 ++++++++++++++++
> > > 2 files changed, 41 insertions(+)
> > >
> > > diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> > > index 118b4f30a406..b696baeb249d 100644
> > > --- a/drivers/cpufreq/cpufreq.c
> > > +++ b/drivers/cpufreq/cpufreq.c
> > > @@ -492,6 +492,29 @@ void cpufreq_disable_fast_switch(struct cpufreq_policy *policy)
> > > }
> > > EXPORT_SYMBOL_GPL(cpufreq_disable_fast_switch);
> > >
> > > +/**
> > > + * cpufreq_driver_resolve_freq - Map a target frequency to a driver-supported
> > > + * one.
> > > + * @target_freq: target frequency to resolve.
> > > + *
> > > + * The target to driver frequency mapping is cached in the policy.
> > > + *
> > > + * Return: Lowest driver-supported frequency greater than or equal to the
> > > + * given target_freq, subject to policy (min/max) and driver limitations.
> > > + */
> > > +unsigned int cpufreq_driver_resolve_freq(struct cpufreq_policy *policy,
> > > + unsigned int target_freq)
> > > +{
> > > + target_freq = clamp_val(target_freq, policy->min, policy->max);
> > > + policy->cached_target_freq = target_freq;
> > > + if (cpufreq_driver->resolve_freq)
> > > + return cpufreq_driver->resolve_freq(policy, target_freq);
> >
> > Any reason why we still have this call around ? I thought the whole
> > attempt I made was to get rid of this :)
> >
> > The core can do this pretty much now by itself, why do we still want
> > this call?
>
> In case some drivers that don't use frequency tables want to implemet
> fast switching, for example.
Okay, but in that case shouldn't we do something like this:
unsigned int cpufreq_driver_resolve_freq(struct cpufreq_policy *policy,
unsigned int target_freq)
{
target_freq = clamp_val(target_freq, policy->min, policy->max);
policy->cached_target_freq = target_freq;
if (cpufreq_driver->target_index) {
policy->cached_resolved_idx =
cpufreq_frequency_table_target(policy, target_freq,
CPUFREQ_RELATION_L);
return policy->freq_table[policy->cached_resolved_idx].frequency;
}
if (cpufreq_driver->resolve_freq)
return cpufreq_driver->resolve_freq(policy, target_freq);
}
??
--
viresh
next prev parent reply other threads:[~2016-07-21 20:30 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-13 20:25 [PATCH v3 0/3] cpufreq: avoid redundant driver calls in schedutil Steve Muckle
2016-07-13 20:25 ` [PATCH v3 1/3] cpufreq: add cpufreq_driver_resolve_freq() Steve Muckle
2016-07-21 19:59 ` Viresh Kumar
2016-07-21 20:31 ` Rafael J. Wysocki
2016-07-21 20:30 ` Viresh Kumar [this message]
2016-07-21 20:52 ` Rafael J. Wysocki
2016-07-21 20:52 ` Viresh Kumar
2016-07-21 21:19 ` Rafael J. Wysocki
2016-07-21 21:16 ` Viresh Kumar
2016-07-21 23:21 ` Steve Muckle
2016-07-21 23:29 ` Steve Muckle
2016-07-21 23:31 ` Viresh Kumar
2016-07-21 23:30 ` Viresh Kumar
2016-07-21 23:36 ` Steve Muckle
2016-07-21 23:41 ` Steve Muckle
2016-07-22 0:44 ` Steve Muckle
2016-07-22 15:16 ` Viresh Kumar
2016-07-22 17:49 ` Steve Muckle
2016-07-21 21:13 ` Viresh Kumar
2016-07-13 20:25 ` [PATCH v3 2/3] cpufreq: schedutil: map raw required frequency to driver frequency Steve Muckle
2016-07-13 20:25 ` [PATCH v3 3/3] cpufreq: acpi-cpufreq: use cached frequency mapping when possible Steve Muckle
2016-07-14 10:02 ` [PATCH v3 0/3] cpufreq: avoid redundant driver calls in schedutil Pingbo Wen
2016-07-14 18:00 ` Steve Muckle
2016-07-21 20:01 ` Viresh Kumar
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=20160721203041.GH3122@ubuntu \
--to=viresh.kumar@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=patrick.bellasi@arm.com \
--cc=peterz@infradead.org \
--cc=rjw@rjwysocki.net \
--cc=smuckle@linaro.org \
--cc=steve.muckle@linaro.org \
--cc=vincent.guittot@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).