From: Ulf Hansson <ulf.hansson@linaro.org>
To: Stephan Gerhold <stephan@gerhold.net>
Cc: Viresh Kumar <viresh.kumar@linaro.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>,
Stephan Gerhold <stephan.gerhold@kernkonzept.com>,
Konrad Dybcio <konrad.dybcio@linaro.org>,
Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] OPP: Use _set_opp_level() for single genpd case
Date: Thu, 26 Oct 2023 11:53:53 +0200 [thread overview]
Message-ID: <CAPDyKFq+zsoeF-4h5TfT4Z+S46a501_pUq8y2c1x==Tt6EKBGA@mail.gmail.com> (raw)
In-Reply-To: <ZTkciw5AwufxQYnB@gerhold.net>
On Wed, 25 Oct 2023 at 15:49, Stephan Gerhold <stephan@gerhold.net> wrote:
>
> On Wed, Oct 25, 2023 at 12:40:26PM +0200, Ulf Hansson wrote:
> > On Wed, 25 Oct 2023 at 08:55, Viresh Kumar <viresh.kumar@linaro.org> wrote:
> > >
> > > On 19-10-23, 13:16, Ulf Hansson wrote:
> > > > On Thu, 19 Oct 2023 at 12:22, Viresh Kumar <viresh.kumar@linaro.org> wrote:
> > > > > +static int _link_required_opps(struct dev_pm_opp *opp, struct opp_table *opp_table,
> > > > > struct opp_table *required_table, int index)
> > > > > {
> > > > > struct device_node *np;
> > > > > @@ -314,6 +314,25 @@ static int _link_required_opps(struct dev_pm_opp *opp,
> > > > > return -ENODEV;
> > > > > }
> > > > >
> > > > > + /*
> > > > > + * There are two genpd (as required-opp) cases that we need to handle,
> > > > > + * devices with a single genpd and ones with multiple genpds.
> > > > > + *
> > > > > + * The single genpd case requires special handling as we need to use the
> > > > > + * same `dev` structure (instead of a virtual one provided by genpd
> > > > > + * core) for setting the performance state. Lets treat this as a case
> > > > > + * where the OPP's level is directly available without required genpd
> > > > > + * link in the DT.
> > > > > + *
> > > > > + * Just update the `level` with the right value, which
> > > > > + * dev_pm_opp_set_opp() will take care of in the normal path itself.
> > > > > + */
> > > > > + if (required_table->is_genpd && opp_table->required_opp_count == 1 &&
> > > > > + !opp_table->genpd_virt_devs) {
> > > > > + if (!WARN_ON(opp->level))
> > > >
> > > > Hmm. Doesn't this introduce an unnecessary limitation?
> > > >
> > > > An opp node that has a required-opps phande, may have "opp-hz",
> > > > "opp-microvolt", etc. Why would we not allow the "opp-level" to be
> > > > used too?
> > >
> > > Coming back to this, why would we ever want a device to have "opp-level" and
> > > "required-opp" (set to genpd's table) ? That would mean we will call:
> > >
> > > dev_pm_domain_set_performance_state() twice to set different level values.
> >
> > Yes - and that would be weird, especially since the PM domain (genpd)
> > is already managing the aggregation and propagation to parent domains.
> >
>
> FWIW I'm hitting this WARNing when trying to set up the parent domain
> setup for CPR->RPMPD(MX) on MSM8916 that I discussed with Uffe recently
> [1]. I know, me and all my weird OPP setups. :'D
>
> Basically, I have cpufreq voting for performance states of the CPR genpd
> (via required-opps). CPR is supposed to have <&rpmpd MSM8916_VDDMX_AO>
> as parent genpd and translates to the parent performance state using the
> "required-opps" in the *CPR* OPP table:
>
> cpr: power-controller@b018000 {
> compatible = "qcom,msm8916-cpr", "qcom,cpr";
> reg = <0x0b018000 0x1000>;
> /* ... */
> #power-domain-cells = <0>;
> operating-points-v2 = <&cpr_opp_table>;
> /* Supposed to be parent domain, not consumer */
> power-domains = <&rpmpd MSM8916_VDDMX_AO>;
>
> cpr_opp_table: opp-table {
> compatible = "operating-points-v2-qcom-level";
>
> cpr_opp1: opp1 {
> opp-level = <1>;
> qcom,opp-fuse-level = <1>;
> required-opps = <&rpmpd_opp_svs_soc>;
> };
> cpr_opp2: opp2 {
> opp-level = <2>;
> qcom,opp-fuse-level = <2>;
> required-opps = <&rpmpd_opp_nom>;
> };
> cpr_opp3: opp3 {
> opp-level = <3>;
> qcom,opp-fuse-level = <3>;
> required-opps = <&rpmpd_opp_super_turbo>;
> };
> };
> };
>
> There are two problems with this:
>
> 1. (Unrelated to $subject patch)
> Since there is only a single entry in "power-domains", the genpd
> core code automatically attaches the CPR platform device as consumer
> of the VDDMX_AO power domain. I don't want this, I want it to become
> child of the VDDMX_AO genpd.
>
> I added some hacky code to workaround this. One option that works is
> to add a second dummy entry to "power-domains", which will prevent
> the genpd core from attaching the power domain:
>
> power-domains = <&rpmpd MSM8916_VDDMX_AO>, <0>;
Hmm, looks a bit hackish to me.
>
> The other option is detaching the power domain again in probe(),
> after setting it up as parent domain:
Yes, if needed.
>
> struct of_phandle_args parent, child;
>
> child.np = dev->of_node;
> child.args_count = 0;
>
> of_parse_phandle_with_args(dev->of_node, "power-domains",
> "#power-domain-cells", 0, &parent));
> of_genpd_add_subdomain(&parent, &child);
>
> /* Detach power domain since it's managed via the subdomain */
> dev_pm_domain_detach(dev, false);
>
> Is there a cleaner way to handle this? Mainly a question for Uffe.
At the moment, I don't think so. In fact, we have situations when the
attachment is really useful.
For example, during ->probe(), one can do a pm_runtime_get_sync() to
power-on the "parent" domain. This may be needed to synchronize the
power-states between the child/parent-domains, before calling
of_genpd_add_subdomain().
>
> 2. The OPP WARNing triggers with both variants because it just checks
> if "required-opps" has a single entry. I guess we need extra checks
> to exclude the "parent genpd" case compared to the "OPP" case.
>
> [ 1.116244] WARNING: CPU: 2 PID: 36 at drivers/opp/of.c:331 _link_required_opps+0x180/0x1cc
> [ 1.125897] Hardware name: Qualcomm Technologies, Inc. APQ 8016 SBC (DT)
> [ 1.146887] pc : _link_required_opps+0x180/0x1cc
> [ 1.146902] lr : _link_required_opps+0xdc/0x1cc
> [ 1.276408] Call trace:
> [ 1.283519] _link_required_opps+0x180/0x1cc
> [ 1.285779] _of_add_table_indexed+0x61c/0xd40
> [ 1.290292] dev_pm_opp_of_add_table+0x10/0x18
> [ 1.294546] of_genpd_add_provider_simple+0x80/0x160
> [ 1.298974] cpr_probe+0x6a0/0x97c
> [ 1.304092] platform_probe+0x64/0xbc
>
> It does seem to work correctly, with and without this patch. So I guess
> another option might be to simply silence this WARN_ON(). :')
Oh, thanks for pointing this out! This case haven't crossed my mind yet!
Allow me to think a bit more about it. I will get back to you again
with a suggestion soon, unless Viresh comes back first. :-)
[...]
Kind regards
Uffe
next prev parent reply other threads:[~2023-10-26 9:54 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-19 10:21 [RFT PATCH 0/2] OPP: Simplify required-opp handling Viresh Kumar
2023-10-19 10:22 ` [PATCH 1/2] OPP: Use _set_opp_level() for single genpd case Viresh Kumar
2023-10-19 11:16 ` Ulf Hansson
2023-10-20 3:45 ` Viresh Kumar
2023-10-20 10:02 ` Ulf Hansson
2023-10-20 10:56 ` Viresh Kumar
2023-10-20 11:09 ` Ulf Hansson
2023-10-25 6:54 ` Viresh Kumar
2023-10-25 10:40 ` Ulf Hansson
2023-10-25 10:48 ` Viresh Kumar
2023-10-25 13:47 ` Stephan Gerhold
2023-10-25 15:24 ` Viresh Kumar
2023-10-25 16:16 ` Stephan Gerhold
2023-10-26 9:53 ` Ulf Hansson [this message]
2023-10-30 10:29 ` Viresh Kumar
2023-11-03 11:58 ` Ulf Hansson
2023-11-06 7:08 ` Viresh Kumar
2023-11-10 13:50 ` Ulf Hansson
2023-11-15 5:32 ` Viresh Kumar
2023-11-16 10:44 ` Viresh Kumar
2023-10-19 10:22 ` [PATCH 2/2] OPP: Call dev_pm_opp_set_opp() for required OPPs Viresh Kumar
2023-10-24 11:18 ` Stephan Gerhold
2023-10-25 7:36 ` Viresh Kumar
2023-10-25 12:17 ` Stephan Gerhold
2023-10-25 15:20 ` Viresh Kumar
2023-10-25 16:03 ` Ulf Hansson
2023-10-26 7:44 ` Viresh Kumar
2023-10-25 13:51 ` Ulf Hansson
2023-10-25 15:09 ` 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='CAPDyKFq+zsoeF-4h5TfT4Z+S46a501_pUq8y2c1x==Tt6EKBGA@mail.gmail.com' \
--to=ulf.hansson@linaro.org \
--cc=konrad.dybcio@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=manivannan.sadhasivam@linaro.org \
--cc=nm@ti.com \
--cc=rafael@kernel.org \
--cc=sboyd@kernel.org \
--cc=stephan.gerhold@kernkonzept.com \
--cc=stephan@gerhold.net \
--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).