linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bjorn Andersson <quic_bjorande@quicinc.com>
To: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Bjorn Andersson <andersson@kernel.org>,
	Viresh Kumar <vireshk@kernel.org>, Nishanth Menon <nm@ti.com>,
	Stephen Boyd <sboyd@kernel.org>, <linux-pm@vger.kernel.org>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Ulf Hansson <ulf.hansson@linaro.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/2] OPP: pstate is only valid for genpd OPP tables
Date: Fri, 16 Jun 2023 07:31:41 -0700	[thread overview]
Message-ID: <20230616143141.GA4034918@hu-bjorande-lv.qualcomm.com> (raw)
In-Reply-To: <20230616061830.fysc7l7jxymmhb3m@vireshk-i7>

On Fri, Jun 16, 2023 at 11:48:30AM +0530, Viresh Kumar wrote:
> On 15-06-23, 18:35, Bjorn Andersson wrote:
> > On Wed, Jun 14, 2023 at 04:07:25PM +0530, Viresh Kumar wrote:
> > > It is not very clear right now that the `pstate` field is only valid for
> > > genpd OPP tables and not consumer tables. And there is no checking for
> > > the same at various places.
> > > 
> > > Add checks in place to verify that and make it clear to the reader.
> > > 
> > > Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> > > ---
> > >  drivers/opp/core.c    | 18 ++++++++++++++++--
> > >  drivers/opp/debugfs.c |  4 +++-
> > >  drivers/opp/of.c      |  6 ++++++
> > >  3 files changed, 25 insertions(+), 3 deletions(-)
> > > 
> > > diff --git a/drivers/opp/core.c b/drivers/opp/core.c
> > [..]
> > > @@ -2686,6 +2694,12 @@ int dev_pm_opp_xlate_performance_state(struct opp_table *src_table,
> > >  	int dest_pstate = -EINVAL;
> > >  	int i;
> > >  
> > > +	/* Both OPP tables must belong to genpds */
> > > +	if (unlikely(!src_table->is_genpd || !dst_table->is_genpd)) {
> > 
> > I have a platform_device, with a required-opps and with an associated
> > genpd which does not implement set_performance_state(), but its parent
> > genpd does.
> > 
> > This results in me arriving here with src_table of NULL, and boom...
> > 
> > 
> > Looking at the very next statement in this function, it seems arriving
> > here without src_table was valid up until this change.
> 
> Fixed as:
> 
> diff --git a/drivers/opp/core.c b/drivers/opp/core.c
> index 48ddd72d2c71..3f46e499d615 100644
> --- a/drivers/opp/core.c
> +++ b/drivers/opp/core.c
> @@ -2694,12 +2694,6 @@ int dev_pm_opp_xlate_performance_state(struct opp_table *src_table,
>         int dest_pstate = -EINVAL;
>         int i;
> 
> -       /* Both OPP tables must belong to genpds */
> -       if (unlikely(!src_table->is_genpd || !dst_table->is_genpd)) {
> -               pr_err("%s: Performance state is only valid for genpds.\n", __func__);
> -               return -EINVAL;
> -       }
> -
>         /*
>          * Normally the src_table will have the "required_opps" property set to
>          * point to one of the OPPs in the dst_table, but in some cases the
> @@ -2710,6 +2704,12 @@ int dev_pm_opp_xlate_performance_state(struct opp_table *src_table,
>         if (!src_table || !src_table->required_opp_count)
>                 return pstate;
> 
> +       /* Both OPP tables must belong to genpds */
> +       if (unlikely(!src_table->is_genpd || !dst_table->is_genpd)) {
> +               pr_err("%s: Performance state is only valid for genpds.\n", __func__);
> +               return -EINVAL;
> +       }
> +
>         /* required-opps not fully initialized yet */
>         if (lazy_linking_pending(src_table))
>                 return -EBUSY;
> 
> Thanks.
> 

Looks good, thanks for the quick response.

Reviewed-by: Bjorn Andersson <quic_bjorande@quicinc.com>
Tested-by: Bjorn Andersson <quic_bjorande@quicinc.com>

Regards,
Bjorn

      reply	other threads:[~2023-06-16 14:31 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-14 10:37 [PATCH 1/2] OPP: pstate is only valid for genpd OPP tables Viresh Kumar
2023-06-14 10:37 ` [PATCH 2/2] OPP: Simplify the over-designed pstate <-> level dance Viresh Kumar
2023-06-14 12:37   ` Ulf Hansson
2023-06-16  6:20     ` Viresh Kumar
2023-06-14 12:33 ` [PATCH 1/2] OPP: pstate is only valid for genpd OPP tables Ulf Hansson
2023-06-15 23:35 ` Bjorn Andersson
2023-06-16  6:18   ` Viresh Kumar
2023-06-16 14:31     ` Bjorn Andersson [this message]

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=20230616143141.GA4034918@hu-bjorande-lv.qualcomm.com \
    --to=quic_bjorande@quicinc.com \
    --cc=andersson@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=nm@ti.com \
    --cc=rafael@kernel.org \
    --cc=sboyd@kernel.org \
    --cc=ulf.hansson@linaro.org \
    --cc=vincent.guittot@linaro.org \
    --cc=viresh.kumar@linaro.org \
    --cc=vireshk@kernel.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).