From: Stephan Gerhold <stephan@gerhold.net>
To: Viresh Kumar <viresh.kumar@linaro.org>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>,
Kevin Hilman <khilman@kernel.org>,
Ulf Hansson <ulf.hansson@linaro.org>, Nishanth Menon <nm@ti.com>,
Stephen Boyd <sboyd@kernel.org>,
linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
Niklas Cassel <nks@flawful.org>
Subject: Re: [RFC PATCH 1/3] opp: Reduce code duplication in _set_required_opps()
Date: Mon, 24 Aug 2020 13:30:16 +0200 [thread overview]
Message-ID: <20200824113016.GA131681@gerhold.net> (raw)
In-Reply-To: <20200824111820.rcaingohxw3wozgd@vireshk-i7>
On Mon, Aug 24, 2020 at 04:48:20PM +0530, Viresh Kumar wrote:
> On 30-07-20, 10:01, Stephan Gerhold wrote:
> > Move call to dev_pm_genpd_set_performance_state() to a separate
> > function so we can avoid duplicating the code for the single and
> > multiple genpd case.
> >
> > Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
> > ---
> > drivers/opp/core.c | 40 +++++++++++++++++++++-------------------
> > 1 file changed, 21 insertions(+), 19 deletions(-)
> >
> > diff --git a/drivers/opp/core.c b/drivers/opp/core.c
> > index 9d7fb45b1786..f7a476b55069 100644
> > --- a/drivers/opp/core.c
> > +++ b/drivers/opp/core.c
> > @@ -781,6 +781,21 @@ static int _set_opp_custom(const struct opp_table *opp_table,
> > return opp_table->set_opp(data);
> > }
> >
> > +static int _set_required_opp(struct device *dev, struct device *pd_dev,
> > + struct dev_pm_opp *opp, int i)
> > +{
> > + unsigned int pstate = likely(opp) ? opp->required_opps[i]->pstate : 0;
> > + int ret;
> > +
> > + ret = dev_pm_genpd_set_performance_state(pd_dev, pstate);
> > + if (ret) {
> > + dev_err(dev, "Failed to set performance rate of %s: %d (%d)\n",
> > + dev_name(pd_dev), pstate, ret);
> > + }
> > +
> > + return ret;
> > +}
> > +
> > /* This is only called for PM domain for now */
> > static int _set_required_opps(struct device *dev,
> > struct opp_table *opp_table,
> > @@ -788,22 +803,15 @@ static int _set_required_opps(struct device *dev,
> > {
> > struct opp_table **required_opp_tables = opp_table->required_opp_tables;
> > struct device **genpd_virt_devs = opp_table->genpd_virt_devs;
> > - unsigned int pstate;
> > + struct device *pd_dev;
> > int i, ret = 0;
> >
> > if (!required_opp_tables)
> > return 0;
> >
> > /* Single genpd case */
> > - if (!genpd_virt_devs) {
> > - pstate = likely(opp) ? opp->required_opps[0]->pstate : 0;
> > - ret = dev_pm_genpd_set_performance_state(dev, pstate);
> > - if (ret) {
> > - dev_err(dev, "Failed to set performance state of %s: %d (%d)\n",
> > - dev_name(dev), pstate, ret);
> > - }
> > - return ret;
> > - }
> > + if (!genpd_virt_devs)
> > + return _set_required_opp(dev, dev, opp, 0);
> >
> > /* Multiple genpd case */
> >
> > @@ -814,17 +822,11 @@ static int _set_required_opps(struct device *dev,
> > mutex_lock(&opp_table->genpd_virt_dev_lock);
> >
> > for (i = 0; i < opp_table->required_opp_count; i++) {
> > - pstate = likely(opp) ? opp->required_opps[i]->pstate : 0;
> > -
> > - if (!genpd_virt_devs[i])
> > - continue;
>
> Don't we need this check anymore ?
>
You're right. Not sure why I removed it.
I suspect I had it in _set_required_opp() at some point, but I moved
code around several times until I was happy with the result.
We should just add it back.
Should I send a v2 with it fixed or would you like to handle it?
Thanks,
Stephan
> > + pd_dev = genpd_virt_devs[i];
> >
> > - ret = dev_pm_genpd_set_performance_state(genpd_virt_devs[i], pstate);
> > - if (ret) {
> > - dev_err(dev, "Failed to set performance rate of %s: %d (%d)\n",
> > - dev_name(genpd_virt_devs[i]), pstate, ret);
> > + ret = _set_required_opp(dev, pd_dev, opp, i);
> > + if (ret)
> > break;
> > - }
> > }
> > mutex_unlock(&opp_table->genpd_virt_dev_lock);
> >
> > --
> > 2.27.0
next prev parent reply other threads:[~2020-08-24 11:32 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-30 8:01 [RFC PATCH 0/3] opp: required_opps: Power on genpd, scale down in reverse order Stephan Gerhold
2020-07-30 8:01 ` [RFC PATCH 1/3] opp: Reduce code duplication in _set_required_opps() Stephan Gerhold
2020-08-24 11:18 ` Viresh Kumar
2020-08-24 11:30 ` Stephan Gerhold [this message]
2020-08-24 12:10 ` Viresh Kumar
2020-08-24 12:23 ` Stephan Gerhold
2020-07-30 8:01 ` [RFC PATCH 2/3] opp: Set required OPPs in reverse order when scaling down Stephan Gerhold
2020-08-21 16:31 ` Stephan Gerhold
2020-08-24 11:30 ` Viresh Kumar
2020-08-24 11:42 ` Stephan Gerhold
2020-07-30 8:01 ` [RFC PATCH 3/3] opp: Power on (virtual) power domains managed by the OPP core Stephan Gerhold
2020-08-24 11:27 ` Viresh Kumar
2020-08-24 11:55 ` Stephan Gerhold
2020-08-24 14:36 ` Ulf Hansson
2020-08-24 15:08 ` Stephan Gerhold
2020-08-25 4:43 ` Viresh Kumar
2020-08-25 6:43 ` Ulf Hansson
2020-08-25 7:33 ` Stephan Gerhold
2020-08-25 12:42 ` Ulf Hansson
2020-08-26 8:31 ` Stephan Gerhold
2020-08-12 8:53 ` [RFC PATCH 0/3] opp: required_opps: Power on genpd, scale down in reverse order Ulf Hansson
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=20200824113016.GA131681@gerhold.net \
--to=stephan@gerhold.net \
--cc=khilman@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=nks@flawful.org \
--cc=nm@ti.com \
--cc=rjw@rjwysocki.net \
--cc=sboyd@kernel.org \
--cc=ulf.hansson@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).