linux-arm-msm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bjorn Andersson <bjorn.andersson@linaro.org>
To: Rajendra Nayak <rnayak@codeaurora.org>
Cc: Andy Gross <agross@kernel.org>,
	Ulf Hansson <ulf.hansson@linaro.org>,
	Stephen Boyd <swboyd@chromium.org>,
	Dmitry Baryshkov <dmitry.baryshkov@linaro.org>,
	linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] soc: qcom: rpmhpd: Use corner in power_off
Date: Tue, 6 Jul 2021 23:49:10 -0500	[thread overview]
Message-ID: <YOUyRrvdPLkbTqUp@yoga> (raw)
In-Reply-To: <c4440f5e-592c-b849-3ca7-57e812de2df5@codeaurora.org>

On Mon 05 Jul 00:40 CDT 2021, Rajendra Nayak wrote:
> On 7/5/2021 10:36 AM, Bjorn Andersson wrote:
> > On Sun, Jul 4, 2021 at 11:27 PM Rajendra Nayak <rnayak@codeaurora.org> wrote:
> > > 
> > > 
> > > 
> > > On 7/3/2021 6:24 AM, Bjorn Andersson wrote:
> > > > rpmhpd_aggregate_corner() takes a corner as parameter, but in
> > > > rpmhpd_power_off() the code requests the level of the first corner
> > > > instead.
> > > > 
> > > > In all (known) current cases the first corner has level 0, so this
> > > > change should be a nop, but in case that there's a power domain with a
> > > > non-zero lowest level this makes sure that rpmhpd_power_off() actually
> > > > requests the lowest level - which is the closest to "power off" we can
> > > > get.
> > > > 
> > > > While touching the code, also skip the unnecessary zero-initialization
> > > > of "ret".
> > > > 
> > > > Fixes: 279b7e8a62cc ("soc: qcom: rpmhpd: Add RPMh power domain driver")
> > > > Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
> > > > ---
> > > >    drivers/soc/qcom/rpmhpd.c | 5 ++---
> > > >    1 file changed, 2 insertions(+), 3 deletions(-)
> > > > 
> > > > diff --git a/drivers/soc/qcom/rpmhpd.c b/drivers/soc/qcom/rpmhpd.c
> > > > index 2daa17ba54a3..fa209b479ab3 100644
> > > > --- a/drivers/soc/qcom/rpmhpd.c
> > > > +++ b/drivers/soc/qcom/rpmhpd.c
> > > > @@ -403,12 +403,11 @@ static int rpmhpd_power_on(struct generic_pm_domain *domain)
> > > >    static int rpmhpd_power_off(struct generic_pm_domain *domain)
> > > >    {
> > > >        struct rpmhpd *pd = domain_to_rpmhpd(domain);
> > > > -     int ret = 0;
> > > > +     int ret;
> > > > 
> > > >        mutex_lock(&rpmhpd_lock);
> > > > 
> > > > -     ret = rpmhpd_aggregate_corner(pd, pd->level[0]);
> > > > -
> > > > +     ret = rpmhpd_aggregate_corner(pd, 0);
> > > 
> > > This won't work for cases where pd->level[0] != 0, rpmh would just ignore this and keep the
> > > resource at whatever corner it was previously at.
> > > (unless command DB tells you a 0 is 'valid' for a resource, sending a 0 is a nop)
> > > The right thing to do is to send in whatever command DB tells you is the lowest level that's valid,
> > > which is pd->level[0].
> > > 
> > 
> > I'm afraid this doesn't make sense to me.
> > 
> > In rpmh_power_on() if cmd-db tells us that we have [0, 64, ...] and we
> > request 64 we rpmhpd_aggregate_corner(pd, 1); but in power off, if
> > cmd-db would provide [64, ...] we would end up sending
> > rpmhpd_aggregate_corner(pd, 64);
> > So in power_on we request the corner (i.e. index in the array provided
> > in cmd-db) and in power-off the same function takes the level?
> 
> ah that's right, I did not read the commit log properly and got confused.

Thanks for confirming my understanding.

> Looks like this bug existed from the day this driver for merged :/, thanks
> for catching it.
> Does it make sense to also mark this fix for stable?
> 

I can certainly add a Cc: stable@ as I'm applying this.

May I have your R-b?


PS. Do you have any input on patch 2/2? That actually solves a practical
problem we're seeing. Would it perhaps aid in your need for the new
"assigned-opp-level" property?

Regards,
Bjorn

  reply	other threads:[~2021-07-07  4:49 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-03  0:54 [PATCH 0/2] soc: qcom: rpmhpd: Improve rpmhpd enable handling Bjorn Andersson
2021-07-03  0:54 ` [PATCH 1/2] soc: qcom: rpmhpd: Use corner in power_off Bjorn Andersson
2021-07-05  4:26   ` Rajendra Nayak
2021-07-05  5:06     ` Bjorn Andersson
2021-07-05  5:40       ` Rajendra Nayak
2021-07-07  4:49         ` Bjorn Andersson [this message]
2021-07-07  6:31           ` Rajendra Nayak
2021-07-07 15:48             ` Bjorn Andersson
2021-07-07 16:58               ` Dmitry Baryshkov
2021-07-08  0:21   ` Stephen Boyd
2021-07-08  4:35     ` Bjorn Andersson
2021-07-08  5:03       ` Rajendra Nayak
2021-07-08  6:51         ` Stephen Boyd
2021-07-15 10:40   ` Sibi Sankar
2021-07-03  0:54 ` [PATCH 2/2] soc: qcom: rpmhpd: Make power_on actually enable the domain Bjorn Andersson
2021-07-03  2:54   ` [RESEND PATCH " Bjorn Andersson
2021-07-08  0:23     ` Stephen Boyd
2021-07-08  0:25     ` Stephen Boyd
2021-07-14  9:22     ` Rajendra Nayak
2021-07-15 12:16     ` Sibi Sankar
2021-07-15 12:24       ` Rajendra Nayak
2021-08-12 13:21     ` Dmitry Baryshkov
2021-08-13  9:45       ` Ulf Hansson
2021-07-05 12:55 ` [PATCH 0/2] soc: qcom: rpmhpd: Improve rpmhpd enable handling 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=YOUyRrvdPLkbTqUp@yoga \
    --to=bjorn.andersson@linaro.org \
    --cc=agross@kernel.org \
    --cc=dmitry.baryshkov@linaro.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rnayak@codeaurora.org \
    --cc=swboyd@chromium.org \
    --cc=ulf.hansson@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).