linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ulf Hansson <ulf.hansson@linaro.org>
To: Thara Gopinath <thara.gopinath@linaro.org>
Cc: qualcomm-lt@lists.linaro.org, Linux PM <linux-pm@vger.kernel.org>,
	Bjorn Andersson <bjorn.andersson@linaro.org>,
	Rajendra Nayak <rnayak@codeaurora.org>
Subject: Re: [PATCH 1/4] PM/Domains: Add support for retrieving genpd performance states information
Date: Mon, 9 Sep 2019 11:40:37 +0200	[thread overview]
Message-ID: <CAPDyKFqXYCK1bMFHmdNyOp1VwTopJ8gTHCBL1FajOS8LY+MoPQ@mail.gmail.com> (raw)
In-Reply-To: <5D72DC94.6040508@linaro.org>

On Sat, 7 Sep 2019 at 00:24, Thara Gopinath <thara.gopinath@linaro.org> wrote:
>
> On 08/22/2019 11:03 AM, Ulf Hansson wrote:
> > On Sat, 10 Aug 2019 at 02:58, Thara Gopinath <thara.gopinath@linaro.org> wrote:
> >>
> >> Add two new APIs in the genpd framework,
> >> dev_pm_genpd_get_performance_state to return the current performance
> >> state of a power domain and dev_pm_genpd_performance_state_count to
> >> return the total number of performance states supported by a
> >> power domain. Since the genpd framework does not maintain
> >> a count of number of performance states supported by a power domain,
> >> introduce a new callback(.get_performance_state_count) that can be used
> >> to retrieve this information from power domain drivers.
> >
> > I think some brief background to *why* this is useful needs to be
> > squeezed into the changelog. Or at least state that following changes
> > makes use of it, somehow.
> >
> >>
> >> Signed-off-by: Thara Gopinath <thara.gopinath@linaro.org>
> >> ---
> >>  drivers/base/power/domain.c | 38 ++++++++++++++++++++++++++++++++++++++
> >>  include/linux/pm_domain.h   | 18 ++++++++++++++++++
> >>  2 files changed, 56 insertions(+)
> >>
> >> diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
> >> index b063bc4..17e0375 100644
> >> --- a/drivers/base/power/domain.c
> >> +++ b/drivers/base/power/domain.c
> >> @@ -413,6 +413,44 @@ int dev_pm_genpd_set_performance_state(struct device *dev, unsigned int state)
> >>  }
> >>  EXPORT_SYMBOL_GPL(dev_pm_genpd_set_performance_state);
> >>
> >> +int dev_pm_genpd_get_performance_state(struct device *dev,
> >> +                                      unsigned int *state)
> >> +{
> >> +       struct generic_pm_domain *genpd;
> >> +
> >> +       genpd = dev_to_genpd(dev);
> >
> > We need to verify that the there is a genpd attached before doing this
> > cast. Let me post a patch in a day or so, it will give you a helper
> > function that covers this.
> >
> >> +       if (IS_ERR(genpd))
> >> +               return -ENODEV;
> >> +
> >> +       genpd_lock(genpd);
> >> +       *state = genpd->performance_state;
> >
> > Why not return the state, rather than assigning an out-parameter?
> >
> >> +       genpd_unlock(genpd);
> >> +
> >> +       return 0;
> >> +}
> >> +EXPORT_SYMBOL_GPL(dev_pm_genpd_get_performance_state);
> >> +
> >> +int dev_pm_genpd_performance_state_count(struct device *dev,
> >> +                                        unsigned int *count)
> >> +{
> >> +       struct generic_pm_domain *genpd;
> >> +       int ret;
> >> +
> >> +       genpd = dev_to_genpd(dev);
> >> +       if (IS_ERR(genpd))
> >> +               return -ENODEV;
> >> +
> >> +       if (unlikely(!genpd->get_performance_state_count))
> >> +               return -EINVAL;
> >> +
> >> +       genpd_lock(genpd);
> >> +       ret = genpd->get_performance_state_count(genpd, count);
> >
> > Why not having the callback to return the state, rather than using an
> > out-parameter?
> Hi Ulf,
> I just realized that returning the state instead of using a parameter
> will prevent me from access under lock. Is that okay ?

Not sure I understand. Why can't you just assign a local variable and
return that?

Like this:

genpd_lock();
count = genpd->get_performance_state_count();
genpd_unlock();

return count;

[...]

Kind regards
Uffe

  reply	other threads:[~2019-09-09  9:41 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-10  0:58 [PATCH 0/4] qcom: Model RPMH power domains as thermal cooling devices Thara Gopinath
2019-08-10  0:58 ` [PATCH 1/4] PM/Domains: Add support for retrieving genpd performance states information Thara Gopinath
2019-08-11  3:25   ` kbuild test robot
2019-08-11  4:03   ` kbuild test robot
2019-08-22 15:03   ` Ulf Hansson
2019-08-23 17:39     ` Thara Gopinath
2019-09-06 22:24     ` Thara Gopinath
2019-09-09  9:40       ` Ulf Hansson [this message]
2019-08-10  0:58 ` [PATCH 2/4] soc: qcom: rpmhpd: Introduce function to retrieve power domain performance state count Thara Gopinath
2019-08-10  0:58 ` [PATCH 3/4] thermal: qcom: Add RPMHPD cooling device driver Thara Gopinath
2019-08-22 15:19   ` Ulf Hansson
2019-08-23 17:51     ` Thara Gopinath
2019-08-24  6:10   ` Bjorn Andersson
2019-08-27 10:42     ` Thara Gopinath
2019-08-28 19:22       ` Bjorn Andersson
2019-08-28 12:23   ` Zhang Rui
2019-09-06 15:05     ` Thara Gopinath
2019-08-10  0:58 ` [PATCH 4/4] arm64: dts: qcom: Extend AOSS RPMHPD node Thara Gopinath
2019-08-14 10:52 ` [PATCH 0/4] qcom: Model RPMH power domains as thermal cooling devices Daniel Lezcano
2019-08-15 13:09   ` Thara Gopinath
2019-08-24  6:00   ` Bjorn Andersson

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=CAPDyKFqXYCK1bMFHmdNyOp1VwTopJ8gTHCBL1FajOS8LY+MoPQ@mail.gmail.com \
    --to=ulf.hansson@linaro.org \
    --cc=bjorn.andersson@linaro.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=qualcomm-lt@lists.linaro.org \
    --cc=rnayak@codeaurora.org \
    --cc=thara.gopinath@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).