mbox series

[RESEND,v2,0/7] clk: qcom: use power-domain for sm8250's clock controllers

Message ID 20210709043136.533205-1-dmitry.baryshkov@linaro.org
Headers show
Series clk: qcom: use power-domain for sm8250's clock controllers | expand

Message

Dmitry Baryshkov July 9, 2021, 4:31 a.m. UTC
On SM8250 both the display and video clock controllers are powered up by
the MMCX power domain. Handle this by linking clock controllers to the
proper power domain, and using runtime power management to enable and
disable the MMCX power domain.

Dependencies:
- https://lore.kernel.org/linux-pm/20210603093438.138705-1-ulf.hansson@linaro.org/ (merged in 5.14)
- https://lore.kernel.org/linux-arm-msm/20210703005416.2668319-1-bjorn.andersson@linaro.org/
  (pending)

Patches resent because I missed one hunk in the PM domains patch, which
got stuck in the git index. Now the patch is fixed.

Changes since v1:
 - Rebase on top of Bjorn's patches, removing the need for setting
   performance state directly.
 - Move runtime PM calls from GDSC code to generic genpd code.
 - Always call pm_runtime_enable in the Qualcomm generic clock
   controller code.
 - Register GDSC power domains as subdomains of the domain powering the
   clock controller if there is one.

----------------------------------------------------------------
Dmitry Baryshkov (7):
      dt-bindings: clock: qcom,dispcc-sm8x50: add mmcx power domain
      dt-bindings: clock: qcom,videocc: add mmcx power domain
      PM: domains: Add support for runtime PM
      clk: qcom: gdsc: enable optional power domain support
      arm64: dts: qcom: sm8250: remove mmcx regulator
      clk: qcom: dispcc-sm8250: stop using mmcx regulator
      clk: qcom: videocc-sm8250: stop using mmcx regulator

 .../bindings/clock/qcom,dispcc-sm8x50.yaml         |  7 ++++
 .../devicetree/bindings/clock/qcom,videocc.yaml    |  7 ++++
 arch/arm64/boot/dts/qcom/sm8250.dtsi               | 11 ++-----
 drivers/base/power/domain.c                        | 33 +++++++++++++++++++
 drivers/clk/qcom/common.c                          | 37 ++++++++++++++++++----
 drivers/clk/qcom/dispcc-sm8250.c                   |  1 -
 drivers/clk/qcom/gdsc.c                            |  5 +++
 drivers/clk/qcom/videocc-sm8250.c                  |  4 ---
 include/linux/pm_domain.h                          |  6 ++++
 9 files changed, 91 insertions(+), 20 deletions(-)

Comments

Ulf Hansson July 9, 2021, 8:24 a.m. UTC | #1
On Fri, 9 Jul 2021 at 06:32, Dmitry Baryshkov
<dmitry.baryshkov@linaro.org> wrote:
>

> Registers for some genpds can be located in the SoC area, powered up by

> another power domain. To enabled access to those registers, respective

> domain should be turned on.

>

> This patch adds basic infrastructure to the genpd code to allow

> implementing drivers for such genpd. PM domain can provide the parent

> device through the genpd->dev.parent pointer. If its provided at the

> pm_genpd_init() call time and if it is pm-enabled, genpd power_on and

> power_off operations will call pm_runtime_get_sync() before powering up

> the domain and pm_runtime_put_sync() after powering it down.

>

> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>


Hi Dmitry,

Using runtime PM for the genpd provider device, is not the correct
approach. If the provider domain needs another domain to be powered on
to work correctly, that per definition means that it has a parent
domain.

I suggest you try to build the correct PM domain topology, via using
pm_genpd_add_subdomain() or of_genpd_add_subdomain(), then genpd will
manages the power on/off for parent/child domain internally.

Kind regards
Uffe

> ---

>  drivers/base/power/domain.c | 33 +++++++++++++++++++++++++++++++++

>  include/linux/pm_domain.h   |  6 ++++++

>  2 files changed, 39 insertions(+)

>

> diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c

> index e5d97174c254..7d49531c9731 100644

> --- a/drivers/base/power/domain.c

> +++ b/drivers/base/power/domain.c

> @@ -482,6 +482,30 @@ void dev_pm_genpd_set_next_wakeup(struct device *dev, ktime_t next)

>  }

>  EXPORT_SYMBOL_GPL(dev_pm_genpd_set_next_wakeup);

>

> +static int _genpd_pm_runtime_get(struct generic_pm_domain *genpd)

> +{

> +       int ret;

> +

> +       if (!(genpd->flags & _GENPD_FLAG_RPM_ENABLED))

> +               return 0;

> +

> +       ret = pm_runtime_get_sync(genpd->dev.parent);

> +       if (ret < 0) {

> +               pm_runtime_put_noidle(genpd->dev.parent);

> +               return ret;

> +       }

> +

> +       return 0;

> +}

> +

> +static void _genpd_pm_runtime_put(struct generic_pm_domain *genpd)

> +{

> +       if (!(genpd->flags & _GENPD_FLAG_RPM_ENABLED))

> +               return;

> +

> +       pm_runtime_put_sync(genpd->dev.parent);

> +}

> +

>  static int _genpd_power_on(struct generic_pm_domain *genpd, bool timed)

>  {

>         unsigned int state_idx = genpd->state_idx;

> @@ -497,6 +521,10 @@ static int _genpd_power_on(struct generic_pm_domain *genpd, bool timed)

>         if (ret)

>                 return ret;

>

> +       ret = _genpd_pm_runtime_get(genpd);

> +       if (ret)

> +               return ret;

> +

>         if (!genpd->power_on)

>                 goto out;

>

> @@ -526,6 +554,7 @@ static int _genpd_power_on(struct generic_pm_domain *genpd, bool timed)

>         raw_notifier_call_chain(&genpd->power_notifiers, GENPD_NOTIFY_ON, NULL);

>         return 0;

>  err:

> +       _genpd_pm_runtime_put(genpd);

>         raw_notifier_call_chain(&genpd->power_notifiers, GENPD_NOTIFY_OFF,

>                                 NULL);

>         return ret;

> @@ -572,6 +601,7 @@ static int _genpd_power_off(struct generic_pm_domain *genpd, bool timed)

>                  genpd->name, "off", elapsed_ns);

>

>  out:

> +       _genpd_pm_runtime_put(genpd);

>         raw_notifier_call_chain(&genpd->power_notifiers, GENPD_NOTIFY_OFF,

>                                 NULL);

>         return 0;

> @@ -1986,6 +2016,9 @@ int pm_genpd_init(struct generic_pm_domain *genpd,

>         genpd->domain.ops.complete = genpd_complete;

>         genpd->domain.start = genpd_dev_pm_start;

>

> +       if (genpd->dev.parent && pm_runtime_enabled(genpd->dev.parent))

> +               genpd->flags |= _GENPD_FLAG_RPM_ENABLED;

> +

>         if (genpd->flags & GENPD_FLAG_PM_CLK) {

>                 genpd->dev_ops.stop = pm_clk_suspend;

>                 genpd->dev_ops.start = pm_clk_resume;

> diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h

> index 21a0577305ef..e86cd7cfc9ec 100644

> --- a/include/linux/pm_domain.h

> +++ b/include/linux/pm_domain.h

> @@ -60,6 +60,10 @@

>   * GENPD_FLAG_MIN_RESIDENCY:   Enable the genpd governor to consider its

>   *                             components' next wakeup when determining the

>   *                             optimal idle state.

> + *

> + * _GENPD_FLAG_RPM_ENABLED:    Use genpd's parent dev for runtime power

> + *                             management. There is no need to set this flag,

> + *                             it will be detected automatically.

>   */

>  #define GENPD_FLAG_PM_CLK       (1U << 0)

>  #define GENPD_FLAG_IRQ_SAFE     (1U << 1)

> @@ -69,6 +73,8 @@

>  #define GENPD_FLAG_RPM_ALWAYS_ON (1U << 5)

>  #define GENPD_FLAG_MIN_RESIDENCY (1U << 6)

>

> +#define _GENPD_FLAG_RPM_ENABLED         (1U << 31)

> +

>  enum gpd_status {

>         GENPD_STATE_ON = 0,     /* PM domain is on */

>         GENPD_STATE_OFF,        /* PM domain is off */

> --

> 2.30.2

>
Ulf Hansson July 9, 2021, 9:32 a.m. UTC | #2
On Fri, 9 Jul 2021 at 06:32, Dmitry Baryshkov
<dmitry.baryshkov@linaro.org> wrote:
>

> On sm8250 dispcc and videocc registers are powered up by the MMCX power

> domain. Currently we used a regulator to enable this domain on demand,

> however this has some consequences, as genpd code is not reentrant.

>

> Teach Qualcomm clock controller code about setting up power domains and

> using them for gdsc control.

>

> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>


[...]

> diff --git a/drivers/clk/qcom/gdsc.c b/drivers/clk/qcom/gdsc.c

> index 51ed640e527b..9401d01533c8 100644

> --- a/drivers/clk/qcom/gdsc.c

> +++ b/drivers/clk/qcom/gdsc.c

> @@ -427,6 +427,7 @@ int gdsc_register(struct gdsc_desc *desc,

>                         continue;

>                 scs[i]->regmap = regmap;

>                 scs[i]->rcdev = rcdev;

> +               scs[i]->pd.dev.parent = desc->dev;

>                 ret = gdsc_init(scs[i]);

>                 if (ret)

>                         return ret;

> @@ -439,6 +440,8 @@ int gdsc_register(struct gdsc_desc *desc,

>                         continue;

>                 if (scs[i]->parent)

>                         pm_genpd_add_subdomain(scs[i]->parent, &scs[i]->pd);

> +               else if (!IS_ERR_OR_NULL(dev->pm_domain))


So dev_pm_domain_attach() (which calls genpd_dev_pm_attach() is being
called for gdsc platform device from the platform bus', to try to
attach the device to its corresponding PM domain.

Looking a bit closer to genpd_dev_pm_attach(), I realize that we
shouldn't really try to attach a device to its PM domain, when its OF
node (dev->of_node) contains a "#power-domain-cells" specifier. This
is because it indicates that the device belongs to a genpd provider
itself. In this case, a "power-domains" specifier tells that it has a
parent domain.

I will post a patch that fixes this asap.

> +                       pm_genpd_add_subdomain(pd_to_genpd(dev->pm_domain), &scs[i]->pd);

>         }

>

>         return of_genpd_add_provider_onecell(dev->of_node, data);

> @@ -457,6 +460,8 @@ void gdsc_unregister(struct gdsc_desc *desc)

>                         continue;

>                 if (scs[i]->parent)

>                         pm_genpd_remove_subdomain(scs[i]->parent, &scs[i]->pd);

> +               else if (!IS_ERR_OR_NULL(dev->pm_domain))


Ditto.

> +                       pm_genpd_remove_subdomain(pd_to_genpd(dev->pm_domain), &scs[i]->pd);

>         }

>         of_genpd_del_provider(dev->of_node);

>  }

> --

> 2.30.2

>


Kind regards
Uffe
Dmitry Baryshkov July 9, 2021, 11:39 a.m. UTC | #3
Hi,

On Fri, 9 Jul 2021 at 11:25, Ulf Hansson <ulf.hansson@linaro.org> wrote:
>
> On Fri, 9 Jul 2021 at 06:32, Dmitry Baryshkov
> <dmitry.baryshkov@linaro.org> wrote:
> >
> > Registers for some genpds can be located in the SoC area, powered up by
> > another power domain. To enabled access to those registers, respective
> > domain should be turned on.
> >
> > This patch adds basic infrastructure to the genpd code to allow
> > implementing drivers for such genpd. PM domain can provide the parent
> > device through the genpd->dev.parent pointer. If its provided at the
> > pm_genpd_init() call time and if it is pm-enabled, genpd power_on and
> > power_off operations will call pm_runtime_get_sync() before powering up
> > the domain and pm_runtime_put_sync() after powering it down.
> >
> > Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
>
> Hi Dmitry,
>
> Using runtime PM for the genpd provider device, is not the correct
> approach. If the provider domain needs another domain to be powered on
> to work correctly, that per definition means that it has a parent
> domain.
>
> I suggest you try to build the correct PM domain topology, via using
> pm_genpd_add_subdomain() or of_genpd_add_subdomain(), then genpd will
> manages the power on/off for parent/child domain internally.

Indeed, this patch seems redundant now, with the
pm_genpd_add_subdomain call in place.
Would you like me to resend a v3 just dropping this patch?

>
> Kind regards
> Uffe
>
> > ---
> >  drivers/base/power/domain.c | 33 +++++++++++++++++++++++++++++++++
> >  include/linux/pm_domain.h   |  6 ++++++
> >  2 files changed, 39 insertions(+)
> >
> > diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
> > index e5d97174c254..7d49531c9731 100644
> > --- a/drivers/base/power/domain.c
> > +++ b/drivers/base/power/domain.c
> > @@ -482,6 +482,30 @@ void dev_pm_genpd_set_next_wakeup(struct device *dev, ktime_t next)
> >  }
> >  EXPORT_SYMBOL_GPL(dev_pm_genpd_set_next_wakeup);
> >
> > +static int _genpd_pm_runtime_get(struct generic_pm_domain *genpd)
> > +{
> > +       int ret;
> > +
> > +       if (!(genpd->flags & _GENPD_FLAG_RPM_ENABLED))
> > +               return 0;
> > +
> > +       ret = pm_runtime_get_sync(genpd->dev.parent);
> > +       if (ret < 0) {
> > +               pm_runtime_put_noidle(genpd->dev.parent);
> > +               return ret;
> > +       }
> > +
> > +       return 0;
> > +}
> > +
> > +static void _genpd_pm_runtime_put(struct generic_pm_domain *genpd)
> > +{
> > +       if (!(genpd->flags & _GENPD_FLAG_RPM_ENABLED))
> > +               return;
> > +
> > +       pm_runtime_put_sync(genpd->dev.parent);
> > +}
> > +
> >  static int _genpd_power_on(struct generic_pm_domain *genpd, bool timed)
> >  {
> >         unsigned int state_idx = genpd->state_idx;
> > @@ -497,6 +521,10 @@ static int _genpd_power_on(struct generic_pm_domain *genpd, bool timed)
> >         if (ret)
> >                 return ret;
> >
> > +       ret = _genpd_pm_runtime_get(genpd);
> > +       if (ret)
> > +               return ret;
> > +
> >         if (!genpd->power_on)
> >                 goto out;
> >
> > @@ -526,6 +554,7 @@ static int _genpd_power_on(struct generic_pm_domain *genpd, bool timed)
> >         raw_notifier_call_chain(&genpd->power_notifiers, GENPD_NOTIFY_ON, NULL);
> >         return 0;
> >  err:
> > +       _genpd_pm_runtime_put(genpd);
> >         raw_notifier_call_chain(&genpd->power_notifiers, GENPD_NOTIFY_OFF,
> >                                 NULL);
> >         return ret;
> > @@ -572,6 +601,7 @@ static int _genpd_power_off(struct generic_pm_domain *genpd, bool timed)
> >                  genpd->name, "off", elapsed_ns);
> >
> >  out:
> > +       _genpd_pm_runtime_put(genpd);
> >         raw_notifier_call_chain(&genpd->power_notifiers, GENPD_NOTIFY_OFF,
> >                                 NULL);
> >         return 0;
> > @@ -1986,6 +2016,9 @@ int pm_genpd_init(struct generic_pm_domain *genpd,
> >         genpd->domain.ops.complete = genpd_complete;
> >         genpd->domain.start = genpd_dev_pm_start;
> >
> > +       if (genpd->dev.parent && pm_runtime_enabled(genpd->dev.parent))
> > +               genpd->flags |= _GENPD_FLAG_RPM_ENABLED;
> > +
> >         if (genpd->flags & GENPD_FLAG_PM_CLK) {
> >                 genpd->dev_ops.stop = pm_clk_suspend;
> >                 genpd->dev_ops.start = pm_clk_resume;
> > diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
> > index 21a0577305ef..e86cd7cfc9ec 100644
> > --- a/include/linux/pm_domain.h
> > +++ b/include/linux/pm_domain.h
> > @@ -60,6 +60,10 @@
> >   * GENPD_FLAG_MIN_RESIDENCY:   Enable the genpd governor to consider its
> >   *                             components' next wakeup when determining the
> >   *                             optimal idle state.
> > + *
> > + * _GENPD_FLAG_RPM_ENABLED:    Use genpd's parent dev for runtime power
> > + *                             management. There is no need to set this flag,
> > + *                             it will be detected automatically.
> >   */
> >  #define GENPD_FLAG_PM_CLK       (1U << 0)
> >  #define GENPD_FLAG_IRQ_SAFE     (1U << 1)
> > @@ -69,6 +73,8 @@
> >  #define GENPD_FLAG_RPM_ALWAYS_ON (1U << 5)
> >  #define GENPD_FLAG_MIN_RESIDENCY (1U << 6)
> >
> > +#define _GENPD_FLAG_RPM_ENABLED         (1U << 31)
> > +
> >  enum gpd_status {
> >         GENPD_STATE_ON = 0,     /* PM domain is on */
> >         GENPD_STATE_OFF,        /* PM domain is off */
> > --
> > 2.30.2
> >
Dmitry Baryshkov July 9, 2021, 11:46 a.m. UTC | #4
On Fri, 9 Jul 2021 at 12:33, Ulf Hansson <ulf.hansson@linaro.org> wrote:
>

> On Fri, 9 Jul 2021 at 06:32, Dmitry Baryshkov

> <dmitry.baryshkov@linaro.org> wrote:

> >

> > On sm8250 dispcc and videocc registers are powered up by the MMCX power

> > domain. Currently we used a regulator to enable this domain on demand,

> > however this has some consequences, as genpd code is not reentrant.

> >

> > Teach Qualcomm clock controller code about setting up power domains and

> > using them for gdsc control.

> >

> > Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>

>

> [...]

>

> > diff --git a/drivers/clk/qcom/gdsc.c b/drivers/clk/qcom/gdsc.c

> > index 51ed640e527b..9401d01533c8 100644

> > --- a/drivers/clk/qcom/gdsc.c

> > +++ b/drivers/clk/qcom/gdsc.c

> > @@ -427,6 +427,7 @@ int gdsc_register(struct gdsc_desc *desc,

> >                         continue;

> >                 scs[i]->regmap = regmap;

> >                 scs[i]->rcdev = rcdev;

> > +               scs[i]->pd.dev.parent = desc->dev;

> >                 ret = gdsc_init(scs[i]);

> >                 if (ret)

> >                         return ret;

> > @@ -439,6 +440,8 @@ int gdsc_register(struct gdsc_desc *desc,

> >                         continue;

> >                 if (scs[i]->parent)

> >                         pm_genpd_add_subdomain(scs[i]->parent, &scs[i]->pd);

> > +               else if (!IS_ERR_OR_NULL(dev->pm_domain))

>

> So dev_pm_domain_attach() (which calls genpd_dev_pm_attach() is being

> called for gdsc platform device from the platform bus', to try to

> attach the device to its corresponding PM domain.

>

> Looking a bit closer to genpd_dev_pm_attach(), I realize that we

> shouldn't really try to attach a device to its PM domain, when its OF

> node (dev->of_node) contains a "#power-domain-cells" specifier. This

> is because it indicates that the device belongs to a genpd provider

> itself. In this case, a "power-domains" specifier tells that it has a

> parent domain.

>

> I will post a patch that fixes this asap.


I think there is nothing to fix here. The dispcc/videocc drivers
provide clocks in addition to the gdsc power domain. And provided
clocks would definitely benefit from having the dispcc device being
attached to the power domain which governs clock registers (MMCX in
our case). Thus I think it is perfectly valid to have:

rpmhpd device:
 - provides MMCX domain.

dispcc device:
 - is attached to the MMCX domain,
 - provides MDSS_GDSC
 - provides clocks

>

> > +                       pm_genpd_add_subdomain(pd_to_genpd(dev->pm_domain), &scs[i]->pd);

> >         }

> >

> >         return of_genpd_add_provider_onecell(dev->of_node, data);

> > @@ -457,6 +460,8 @@ void gdsc_unregister(struct gdsc_desc *desc)

> >                         continue;

> >                 if (scs[i]->parent)

> >                         pm_genpd_remove_subdomain(scs[i]->parent, &scs[i]->pd);

> > +               else if (!IS_ERR_OR_NULL(dev->pm_domain))

>

> Ditto.

>

> > +                       pm_genpd_remove_subdomain(pd_to_genpd(dev->pm_domain), &scs[i]->pd);

> >         }

> >         of_genpd_del_provider(dev->of_node);

> >  }

> > --

> > 2.30.2

> >

>

> Kind regards

> Uffe




-- 
With best wishes
Dmitry
Ulf Hansson July 9, 2021, 12:18 p.m. UTC | #5
On Fri, 9 Jul 2021 at 13:46, Dmitry Baryshkov
<dmitry.baryshkov@linaro.org> wrote:
>

> On Fri, 9 Jul 2021 at 12:33, Ulf Hansson <ulf.hansson@linaro.org> wrote:

> >

> > On Fri, 9 Jul 2021 at 06:32, Dmitry Baryshkov

> > <dmitry.baryshkov@linaro.org> wrote:

> > >

> > > On sm8250 dispcc and videocc registers are powered up by the MMCX power

> > > domain. Currently we used a regulator to enable this domain on demand,

> > > however this has some consequences, as genpd code is not reentrant.

> > >

> > > Teach Qualcomm clock controller code about setting up power domains and

> > > using them for gdsc control.

> > >

> > > Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>

> >

> > [...]

> >

> > > diff --git a/drivers/clk/qcom/gdsc.c b/drivers/clk/qcom/gdsc.c

> > > index 51ed640e527b..9401d01533c8 100644

> > > --- a/drivers/clk/qcom/gdsc.c

> > > +++ b/drivers/clk/qcom/gdsc.c

> > > @@ -427,6 +427,7 @@ int gdsc_register(struct gdsc_desc *desc,

> > >                         continue;

> > >                 scs[i]->regmap = regmap;

> > >                 scs[i]->rcdev = rcdev;

> > > +               scs[i]->pd.dev.parent = desc->dev;

> > >                 ret = gdsc_init(scs[i]);

> > >                 if (ret)

> > >                         return ret;

> > > @@ -439,6 +440,8 @@ int gdsc_register(struct gdsc_desc *desc,

> > >                         continue;

> > >                 if (scs[i]->parent)

> > >                         pm_genpd_add_subdomain(scs[i]->parent, &scs[i]->pd);

> > > +               else if (!IS_ERR_OR_NULL(dev->pm_domain))

> >

> > So dev_pm_domain_attach() (which calls genpd_dev_pm_attach() is being

> > called for gdsc platform device from the platform bus', to try to

> > attach the device to its corresponding PM domain.

> >

> > Looking a bit closer to genpd_dev_pm_attach(), I realize that we

> > shouldn't really try to attach a device to its PM domain, when its OF

> > node (dev->of_node) contains a "#power-domain-cells" specifier. This

> > is because it indicates that the device belongs to a genpd provider

> > itself. In this case, a "power-domains" specifier tells that it has a

> > parent domain.

> >

> > I will post a patch that fixes this asap.

>

> I think there is nothing to fix here. The dispcc/videocc drivers

> provide clocks in addition to the gdsc power domain. And provided

> clocks would definitely benefit from having the dispcc device being

> attached to the power domain which governs clock registers (MMCX in

> our case). Thus I think it is perfectly valid to have:

>

> rpmhpd device:

>  - provides MMCX domain.

>

> dispcc device:

>  - is attached to the MMCX domain,


We don't need this, it's redundant and weird to me.

Also I am kind of worried that you will hit another new path in genpd,
causing locking issues etc, as it has not been designed to work like
this (a provider device and a child domain sharing the same "parent").

>  - provides MDSS_GDSC


It's perfectly fine that dispcc acts as a genpd provider. In this
case, the corresponding PM domain should be assigned as a child for
the parent MMCX domain. That should make this work, I think.

>  - provides clocks


That sounds reasonable as well.

>

> >

> > > +                       pm_genpd_add_subdomain(pd_to_genpd(dev->pm_domain), &scs[i]->pd);

> > >         }

> > >

> > >         return of_genpd_add_provider_onecell(dev->of_node, data);

> > > @@ -457,6 +460,8 @@ void gdsc_unregister(struct gdsc_desc *desc)

> > >                         continue;

> > >                 if (scs[i]->parent)

> > >                         pm_genpd_remove_subdomain(scs[i]->parent, &scs[i]->pd);

> > > +               else if (!IS_ERR_OR_NULL(dev->pm_domain))

> >

> > Ditto.

> >

> > > +                       pm_genpd_remove_subdomain(pd_to_genpd(dev->pm_domain), &scs[i]->pd);

> > >         }

> > >         of_genpd_del_provider(dev->of_node);

> > >  }

> > > --

> > > 2.30.2

> > >

> >


Kind regards
Uffe
Ulf Hansson July 9, 2021, 12:20 p.m. UTC | #6
On Fri, 9 Jul 2021 at 13:39, Dmitry Baryshkov
<dmitry.baryshkov@linaro.org> wrote:
>
> Hi,
>
> On Fri, 9 Jul 2021 at 11:25, Ulf Hansson <ulf.hansson@linaro.org> wrote:
> >
> > On Fri, 9 Jul 2021 at 06:32, Dmitry Baryshkov
> > <dmitry.baryshkov@linaro.org> wrote:
> > >
> > > Registers for some genpds can be located in the SoC area, powered up by
> > > another power domain. To enabled access to those registers, respective
> > > domain should be turned on.
> > >
> > > This patch adds basic infrastructure to the genpd code to allow
> > > implementing drivers for such genpd. PM domain can provide the parent
> > > device through the genpd->dev.parent pointer. If its provided at the
> > > pm_genpd_init() call time and if it is pm-enabled, genpd power_on and
> > > power_off operations will call pm_runtime_get_sync() before powering up
> > > the domain and pm_runtime_put_sync() after powering it down.
> > >
> > > Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> >
> > Hi Dmitry,
> >
> > Using runtime PM for the genpd provider device, is not the correct
> > approach. If the provider domain needs another domain to be powered on
> > to work correctly, that per definition means that it has a parent
> > domain.
> >
> > I suggest you try to build the correct PM domain topology, via using
> > pm_genpd_add_subdomain() or of_genpd_add_subdomain(), then genpd will
> > manages the power on/off for parent/child domain internally.
>
> Indeed, this patch seems redundant now, with the
> pm_genpd_add_subdomain call in place.
> Would you like me to resend a v3 just dropping this patch?

Yes, $subject patch isn't the way to go.

Let's continue discussing things on patch3/7 to conclude on the way forward.

[...]

Kind regards
Uffe
Dmitry Baryshkov July 9, 2021, 12:59 p.m. UTC | #7
On Fri, 9 Jul 2021 at 15:18, Ulf Hansson <ulf.hansson@linaro.org> wrote:
>
> On Fri, 9 Jul 2021 at 13:46, Dmitry Baryshkov
> <dmitry.baryshkov@linaro.org> wrote:
> >
> > On Fri, 9 Jul 2021 at 12:33, Ulf Hansson <ulf.hansson@linaro.org> wrote:
> > >
> > > On Fri, 9 Jul 2021 at 06:32, Dmitry Baryshkov
> > > <dmitry.baryshkov@linaro.org> wrote:
> > > >
> > > > On sm8250 dispcc and videocc registers are powered up by the MMCX power
> > > > domain. Currently we used a regulator to enable this domain on demand,
> > > > however this has some consequences, as genpd code is not reentrant.
> > > >
> > > > Teach Qualcomm clock controller code about setting up power domains and
> > > > using them for gdsc control.
> > > >
> > > > Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> > >
> > > [...]
> > >
> > > > diff --git a/drivers/clk/qcom/gdsc.c b/drivers/clk/qcom/gdsc.c
> > > > index 51ed640e527b..9401d01533c8 100644
> > > > --- a/drivers/clk/qcom/gdsc.c
> > > > +++ b/drivers/clk/qcom/gdsc.c
> > > > @@ -427,6 +427,7 @@ int gdsc_register(struct gdsc_desc *desc,
> > > >                         continue;
> > > >                 scs[i]->regmap = regmap;
> > > >                 scs[i]->rcdev = rcdev;
> > > > +               scs[i]->pd.dev.parent = desc->dev;
> > > >                 ret = gdsc_init(scs[i]);
> > > >                 if (ret)
> > > >                         return ret;
> > > > @@ -439,6 +440,8 @@ int gdsc_register(struct gdsc_desc *desc,
> > > >                         continue;
> > > >                 if (scs[i]->parent)
> > > >                         pm_genpd_add_subdomain(scs[i]->parent, &scs[i]->pd);
> > > > +               else if (!IS_ERR_OR_NULL(dev->pm_domain))
> > >
> > > So dev_pm_domain_attach() (which calls genpd_dev_pm_attach() is being
> > > called for gdsc platform device from the platform bus', to try to
> > > attach the device to its corresponding PM domain.
> > >
> > > Looking a bit closer to genpd_dev_pm_attach(), I realize that we
> > > shouldn't really try to attach a device to its PM domain, when its OF
> > > node (dev->of_node) contains a "#power-domain-cells" specifier. This
> > > is because it indicates that the device belongs to a genpd provider
> > > itself. In this case, a "power-domains" specifier tells that it has a
> > > parent domain.
> > >
> > > I will post a patch that fixes this asap.
> >
> > I think there is nothing to fix here. The dispcc/videocc drivers
> > provide clocks in addition to the gdsc power domain. And provided
> > clocks would definitely benefit from having the dispcc device being
> > attached to the power domain which governs clock registers (MMCX in
> > our case). Thus I think it is perfectly valid to have:
> >
> > rpmhpd device:
> >  - provides MMCX domain.
> >
> > dispcc device:
> >  - is attached to the MMCX domain,
>
> We don't need this, it's redundant and weird to me.
>
> Also I am kind of worried that you will hit another new path in genpd,
> causing locking issues etc, as it has not been designed to work like
> this (a provider device and a child domain sharing the same "parent").

So, which domain should the dispcc device belong to? It's registers
are powered by the MMCX domain. I can not attach it to the child
(GDSC) domain either: in the case of videocc there are 4 child
domains.
An alternative would be to request that all users of the provided
clocks power on one of the child domains. However this is also not
perfect. If some generic code (e.g. clock framework) calls into
provided clocks (e.g. because of assigned-clock-rates), this can
happen w/o proper power domain being powered up yet.

>
> >  - provides MDSS_GDSC
>
> It's perfectly fine that dispcc acts as a genpd provider. In this
> case, the corresponding PM domain should be assigned as a child for
> the parent MMCX domain. That should make this work, I think.
>
> >  - provides clocks
>
> That sounds reasonable as well.
>
> >
> > >
> > > > +                       pm_genpd_add_subdomain(pd_to_genpd(dev->pm_domain), &scs[i]->pd);
> > > >         }
> > > >
> > > >         return of_genpd_add_provider_onecell(dev->of_node, data);
> > > > @@ -457,6 +460,8 @@ void gdsc_unregister(struct gdsc_desc *desc)
> > > >                         continue;
> > > >                 if (scs[i]->parent)
> > > >                         pm_genpd_remove_subdomain(scs[i]->parent, &scs[i]->pd);
> > > > +               else if (!IS_ERR_OR_NULL(dev->pm_domain))
> > >
> > > Ditto.
> > >
> > > > +                       pm_genpd_remove_subdomain(pd_to_genpd(dev->pm_domain), &scs[i]->pd);
> > > >         }
> > > >         of_genpd_del_provider(dev->of_node);
> > > >  }
> > > > --
> > > > 2.30.2
> > > >
> > >
>
> Kind regards
> Uffe
Ulf Hansson July 9, 2021, 1:14 p.m. UTC | #8
On Fri, 9 Jul 2021 at 14:59, Dmitry Baryshkov
<dmitry.baryshkov@linaro.org> wrote:
>
> On Fri, 9 Jul 2021 at 15:18, Ulf Hansson <ulf.hansson@linaro.org> wrote:
> >
> > On Fri, 9 Jul 2021 at 13:46, Dmitry Baryshkov
> > <dmitry.baryshkov@linaro.org> wrote:
> > >
> > > On Fri, 9 Jul 2021 at 12:33, Ulf Hansson <ulf.hansson@linaro.org> wrote:
> > > >
> > > > On Fri, 9 Jul 2021 at 06:32, Dmitry Baryshkov
> > > > <dmitry.baryshkov@linaro.org> wrote:
> > > > >
> > > > > On sm8250 dispcc and videocc registers are powered up by the MMCX power
> > > > > domain. Currently we used a regulator to enable this domain on demand,
> > > > > however this has some consequences, as genpd code is not reentrant.
> > > > >
> > > > > Teach Qualcomm clock controller code about setting up power domains and
> > > > > using them for gdsc control.
> > > > >
> > > > > Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> > > >
> > > > [...]
> > > >
> > > > > diff --git a/drivers/clk/qcom/gdsc.c b/drivers/clk/qcom/gdsc.c
> > > > > index 51ed640e527b..9401d01533c8 100644
> > > > > --- a/drivers/clk/qcom/gdsc.c
> > > > > +++ b/drivers/clk/qcom/gdsc.c
> > > > > @@ -427,6 +427,7 @@ int gdsc_register(struct gdsc_desc *desc,
> > > > >                         continue;
> > > > >                 scs[i]->regmap = regmap;
> > > > >                 scs[i]->rcdev = rcdev;
> > > > > +               scs[i]->pd.dev.parent = desc->dev;
> > > > >                 ret = gdsc_init(scs[i]);
> > > > >                 if (ret)
> > > > >                         return ret;
> > > > > @@ -439,6 +440,8 @@ int gdsc_register(struct gdsc_desc *desc,
> > > > >                         continue;
> > > > >                 if (scs[i]->parent)
> > > > >                         pm_genpd_add_subdomain(scs[i]->parent, &scs[i]->pd);
> > > > > +               else if (!IS_ERR_OR_NULL(dev->pm_domain))
> > > >
> > > > So dev_pm_domain_attach() (which calls genpd_dev_pm_attach() is being
> > > > called for gdsc platform device from the platform bus', to try to
> > > > attach the device to its corresponding PM domain.
> > > >
> > > > Looking a bit closer to genpd_dev_pm_attach(), I realize that we
> > > > shouldn't really try to attach a device to its PM domain, when its OF
> > > > node (dev->of_node) contains a "#power-domain-cells" specifier. This
> > > > is because it indicates that the device belongs to a genpd provider
> > > > itself. In this case, a "power-domains" specifier tells that it has a
> > > > parent domain.
> > > >
> > > > I will post a patch that fixes this asap.
> > >
> > > I think there is nothing to fix here. The dispcc/videocc drivers
> > > provide clocks in addition to the gdsc power domain. And provided
> > > clocks would definitely benefit from having the dispcc device being
> > > attached to the power domain which governs clock registers (MMCX in
> > > our case). Thus I think it is perfectly valid to have:
> > >
> > > rpmhpd device:
> > >  - provides MMCX domain.
> > >
> > > dispcc device:
> > >  - is attached to the MMCX domain,
> >
> > We don't need this, it's redundant and weird to me.
> >
> > Also I am kind of worried that you will hit another new path in genpd,
> > causing locking issues etc, as it has not been designed to work like
> > this (a provider device and a child domain sharing the same "parent").
>
> So, which domain should the dispcc device belong to? It's registers
> are powered by the MMCX domain. I can not attach it to the child
> (GDSC) domain either: in the case of videocc there are 4 child
> domains.

The dispcc device should *not* be attached to a PM domain.

Instead it should be registered as a genpd provider and the
corresponding PM domains it provides, should be assigned as child
domains to the MMCX domain.

This is exactly what the child/parent domain support in genpd is there
to help with.

> An alternative would be to request that all users of the provided
> clocks power on one of the child domains. However this is also not
> perfect. If some generic code (e.g. clock framework) calls into
> provided clocks (e.g. because of assigned-clock-rates), this can
> happen w/o proper power domain being powered up yet.

Issues with power on/off synchronization during genpd initializations
and genpd provider registration, certainly need to be fixed and I am
happy to help. However, my point is that I think it's a bad idea to
fix it through modelling the PM domain hierarchy in an incorrect way.

[...]

Kind regards
Uffe
Dmitry Baryshkov July 9, 2021, 1:22 p.m. UTC | #9
On Fri, 9 Jul 2021 at 16:14, Ulf Hansson <ulf.hansson@linaro.org> wrote:
>
> On Fri, 9 Jul 2021 at 14:59, Dmitry Baryshkov
> <dmitry.baryshkov@linaro.org> wrote:
> >
> > On Fri, 9 Jul 2021 at 15:18, Ulf Hansson <ulf.hansson@linaro.org> wrote:
> > >
> > > On Fri, 9 Jul 2021 at 13:46, Dmitry Baryshkov
> > > <dmitry.baryshkov@linaro.org> wrote:
> > > >
> > > > On Fri, 9 Jul 2021 at 12:33, Ulf Hansson <ulf.hansson@linaro.org> wrote:
> > > > >
> > > > > On Fri, 9 Jul 2021 at 06:32, Dmitry Baryshkov
> > > > > <dmitry.baryshkov@linaro.org> wrote:
> > > > > >
> > > > > > On sm8250 dispcc and videocc registers are powered up by the MMCX power
> > > > > > domain. Currently we used a regulator to enable this domain on demand,
> > > > > > however this has some consequences, as genpd code is not reentrant.
> > > > > >
> > > > > > Teach Qualcomm clock controller code about setting up power domains and
> > > > > > using them for gdsc control.
> > > > > >
> > > > > > Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> > > > >
> > > > > [...]
> > > > >
> > > > > > diff --git a/drivers/clk/qcom/gdsc.c b/drivers/clk/qcom/gdsc.c
> > > > > > index 51ed640e527b..9401d01533c8 100644
> > > > > > --- a/drivers/clk/qcom/gdsc.c
> > > > > > +++ b/drivers/clk/qcom/gdsc.c
> > > > > > @@ -427,6 +427,7 @@ int gdsc_register(struct gdsc_desc *desc,
> > > > > >                         continue;
> > > > > >                 scs[i]->regmap = regmap;
> > > > > >                 scs[i]->rcdev = rcdev;
> > > > > > +               scs[i]->pd.dev.parent = desc->dev;
> > > > > >                 ret = gdsc_init(scs[i]);
> > > > > >                 if (ret)
> > > > > >                         return ret;
> > > > > > @@ -439,6 +440,8 @@ int gdsc_register(struct gdsc_desc *desc,
> > > > > >                         continue;
> > > > > >                 if (scs[i]->parent)
> > > > > >                         pm_genpd_add_subdomain(scs[i]->parent, &scs[i]->pd);
> > > > > > +               else if (!IS_ERR_OR_NULL(dev->pm_domain))
> > > > >
> > > > > So dev_pm_domain_attach() (which calls genpd_dev_pm_attach() is being
> > > > > called for gdsc platform device from the platform bus', to try to
> > > > > attach the device to its corresponding PM domain.
> > > > >
> > > > > Looking a bit closer to genpd_dev_pm_attach(), I realize that we
> > > > > shouldn't really try to attach a device to its PM domain, when its OF
> > > > > node (dev->of_node) contains a "#power-domain-cells" specifier. This
> > > > > is because it indicates that the device belongs to a genpd provider
> > > > > itself. In this case, a "power-domains" specifier tells that it has a
> > > > > parent domain.
> > > > >
> > > > > I will post a patch that fixes this asap.
> > > >
> > > > I think there is nothing to fix here. The dispcc/videocc drivers
> > > > provide clocks in addition to the gdsc power domain. And provided
> > > > clocks would definitely benefit from having the dispcc device being
> > > > attached to the power domain which governs clock registers (MMCX in
> > > > our case). Thus I think it is perfectly valid to have:
> > > >
> > > > rpmhpd device:
> > > >  - provides MMCX domain.
> > > >
> > > > dispcc device:
> > > >  - is attached to the MMCX domain,
> > >
> > > We don't need this, it's redundant and weird to me.
> > >
> > > Also I am kind of worried that you will hit another new path in genpd,
> > > causing locking issues etc, as it has not been designed to work like
> > > this (a provider device and a child domain sharing the same "parent").
> >
> > So, which domain should the dispcc device belong to? It's registers
> > are powered by the MMCX domain. I can not attach it to the child
> > (GDSC) domain either: in the case of videocc there are 4 child
> > domains.
>
> The dispcc device should *not* be attached to a PM domain.
>
> Instead it should be registered as a genpd provider and the
> corresponding PM domains it provides, should be assigned as child
> domains to the MMCX domain.
>
> This is exactly what the child/parent domain support in genpd is there
> to help with.

This is done in this patchset. If we stop attaching dispcc to the MMCX
genpd, I'll have to locate it in a different way, but the idea is
implemented here.

> > An alternative would be to request that all users of the provided
> > clocks power on one of the child domains. However this is also not
> > perfect. If some generic code (e.g. clock framework) calls into
> > provided clocks (e.g. because of assigned-clock-rates), this can
> > happen w/o proper power domain being powered up yet.
>
> Issues with power on/off synchronization during genpd initializations
> and genpd provider registration, certainly need to be fixed and I am
> happy to help. However, my point is that I think it's a bad idea to
> fix it through modelling the PM domain hierarchy in an incorrect way.

So, which device should I pass to clk_register to handle runtime PM
for the provided clocks? dispcc, should I not?
Then if the dispcc is not attached, we will have to manually handle
MMCX from dispcc's runtime pm callbacks. Correct?

Could you please be more specific, why is it so wrong to attach dispcc
to the MMCX genpd?
Bjorn Andersson July 9, 2021, 2:04 p.m. UTC | #10
On Fri 09 Jul 08:14 CDT 2021, Ulf Hansson wrote:

> On Fri, 9 Jul 2021 at 14:59, Dmitry Baryshkov

> <dmitry.baryshkov@linaro.org> wrote:

> >

> > On Fri, 9 Jul 2021 at 15:18, Ulf Hansson <ulf.hansson@linaro.org> wrote:

> > >

> > > On Fri, 9 Jul 2021 at 13:46, Dmitry Baryshkov

> > > <dmitry.baryshkov@linaro.org> wrote:

> > > >

> > > > On Fri, 9 Jul 2021 at 12:33, Ulf Hansson <ulf.hansson@linaro.org> wrote:

> > > > >

> > > > > On Fri, 9 Jul 2021 at 06:32, Dmitry Baryshkov

> > > > > <dmitry.baryshkov@linaro.org> wrote:

> > > > > >

> > > > > > On sm8250 dispcc and videocc registers are powered up by the MMCX power

> > > > > > domain. Currently we used a regulator to enable this domain on demand,

> > > > > > however this has some consequences, as genpd code is not reentrant.

> > > > > >

> > > > > > Teach Qualcomm clock controller code about setting up power domains and

> > > > > > using them for gdsc control.

> > > > > >

> > > > > > Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>

> > > > >

> > > > > [...]

> > > > >

> > > > > > diff --git a/drivers/clk/qcom/gdsc.c b/drivers/clk/qcom/gdsc.c

> > > > > > index 51ed640e527b..9401d01533c8 100644

> > > > > > --- a/drivers/clk/qcom/gdsc.c

> > > > > > +++ b/drivers/clk/qcom/gdsc.c

> > > > > > @@ -427,6 +427,7 @@ int gdsc_register(struct gdsc_desc *desc,

> > > > > >                         continue;

> > > > > >                 scs[i]->regmap = regmap;

> > > > > >                 scs[i]->rcdev = rcdev;

> > > > > > +               scs[i]->pd.dev.parent = desc->dev;

> > > > > >                 ret = gdsc_init(scs[i]);

> > > > > >                 if (ret)

> > > > > >                         return ret;

> > > > > > @@ -439,6 +440,8 @@ int gdsc_register(struct gdsc_desc *desc,

> > > > > >                         continue;

> > > > > >                 if (scs[i]->parent)

> > > > > >                         pm_genpd_add_subdomain(scs[i]->parent, &scs[i]->pd);

> > > > > > +               else if (!IS_ERR_OR_NULL(dev->pm_domain))

> > > > >

> > > > > So dev_pm_domain_attach() (which calls genpd_dev_pm_attach() is being

> > > > > called for gdsc platform device from the platform bus', to try to

> > > > > attach the device to its corresponding PM domain.

> > > > >

> > > > > Looking a bit closer to genpd_dev_pm_attach(), I realize that we

> > > > > shouldn't really try to attach a device to its PM domain, when its OF

> > > > > node (dev->of_node) contains a "#power-domain-cells" specifier. This

> > > > > is because it indicates that the device belongs to a genpd provider

> > > > > itself. In this case, a "power-domains" specifier tells that it has a

> > > > > parent domain.

> > > > >

> > > > > I will post a patch that fixes this asap.

> > > >

> > > > I think there is nothing to fix here. The dispcc/videocc drivers

> > > > provide clocks in addition to the gdsc power domain. And provided

> > > > clocks would definitely benefit from having the dispcc device being

> > > > attached to the power domain which governs clock registers (MMCX in

> > > > our case). Thus I think it is perfectly valid to have:

> > > >

> > > > rpmhpd device:

> > > >  - provides MMCX domain.

> > > >

> > > > dispcc device:

> > > >  - is attached to the MMCX domain,

> > >

> > > We don't need this, it's redundant and weird to me.

> > >

> > > Also I am kind of worried that you will hit another new path in genpd,

> > > causing locking issues etc, as it has not been designed to work like

> > > this (a provider device and a child domain sharing the same "parent").

> >

> > So, which domain should the dispcc device belong to? It's registers

> > are powered by the MMCX domain. I can not attach it to the child

> > (GDSC) domain either: in the case of videocc there are 4 child

> > domains.

> 

> The dispcc device should *not* be attached to a PM domain.

> 


dispcc is powered by the MMCX power domain, so it needs to be on if you
want to touch the registers.

I presume that for genpd this might not be a problem as long as all the
exposed power domains are parented by the genpd provider's parent, as
the core would turn the parent on before and turn off after performing
those operations. But without attaching to the domain we don't have
power to get through probe/registration.

Further more, dispcc is also a clock driver and there's certainly
operations where the genpd framework won't save us.

> Instead it should be registered as a genpd provider and the

> corresponding PM domains it provides, should be assigned as child

> domains to the MMCX domain.

> 


Right, this relationship is today missing and is what Dmitry needs to
add - so that the parent domains stays powered even when we're not
keeping the parent domain enabled to poke the dispcc.

> This is exactly what the child/parent domain support in genpd is there

> to help with.

> 

> > An alternative would be to request that all users of the provided

> > clocks power on one of the child domains. However this is also not

> > perfect. If some generic code (e.g. clock framework) calls into

> > provided clocks (e.g. because of assigned-clock-rates), this can

> > happen w/o proper power domain being powered up yet.

> 

> Issues with power on/off synchronization during genpd initializations

> and genpd provider registration, certainly need to be fixed and I am

> happy to help. However, my point is that I think it's a bad idea to

> fix it through modelling the PM domain hierarchy in an incorrect way.

> 


This was my initial feeling to the patch as well and I think it might be
better to push the pm_runtime_get/put operations into gdsc.c - in
particular if you're saying that the general case is not for the genpd
provider itself to be powered by the specified parent domain.

At least we could start by doing it manually in gdsc.c and possibly move
it into the framework if we're confident that it's a good idea.

Regards,
Bjorn
Ulf Hansson July 9, 2021, 2:11 p.m. UTC | #11
On Fri, 9 Jul 2021 at 15:22, Dmitry Baryshkov
<dmitry.baryshkov@linaro.org> wrote:
>
> On Fri, 9 Jul 2021 at 16:14, Ulf Hansson <ulf.hansson@linaro.org> wrote:
> >
> > On Fri, 9 Jul 2021 at 14:59, Dmitry Baryshkov
> > <dmitry.baryshkov@linaro.org> wrote:
> > >
> > > On Fri, 9 Jul 2021 at 15:18, Ulf Hansson <ulf.hansson@linaro.org> wrote:
> > > >
> > > > On Fri, 9 Jul 2021 at 13:46, Dmitry Baryshkov
> > > > <dmitry.baryshkov@linaro.org> wrote:
> > > > >
> > > > > On Fri, 9 Jul 2021 at 12:33, Ulf Hansson <ulf.hansson@linaro.org> wrote:
> > > > > >
> > > > > > On Fri, 9 Jul 2021 at 06:32, Dmitry Baryshkov
> > > > > > <dmitry.baryshkov@linaro.org> wrote:
> > > > > > >
> > > > > > > On sm8250 dispcc and videocc registers are powered up by the MMCX power
> > > > > > > domain. Currently we used a regulator to enable this domain on demand,
> > > > > > > however this has some consequences, as genpd code is not reentrant.
> > > > > > >
> > > > > > > Teach Qualcomm clock controller code about setting up power domains and
> > > > > > > using them for gdsc control.
> > > > > > >
> > > > > > > Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> > > > > >
> > > > > > [...]
> > > > > >
> > > > > > > diff --git a/drivers/clk/qcom/gdsc.c b/drivers/clk/qcom/gdsc.c
> > > > > > > index 51ed640e527b..9401d01533c8 100644
> > > > > > > --- a/drivers/clk/qcom/gdsc.c
> > > > > > > +++ b/drivers/clk/qcom/gdsc.c
> > > > > > > @@ -427,6 +427,7 @@ int gdsc_register(struct gdsc_desc *desc,
> > > > > > >                         continue;
> > > > > > >                 scs[i]->regmap = regmap;
> > > > > > >                 scs[i]->rcdev = rcdev;
> > > > > > > +               scs[i]->pd.dev.parent = desc->dev;
> > > > > > >                 ret = gdsc_init(scs[i]);
> > > > > > >                 if (ret)
> > > > > > >                         return ret;
> > > > > > > @@ -439,6 +440,8 @@ int gdsc_register(struct gdsc_desc *desc,
> > > > > > >                         continue;
> > > > > > >                 if (scs[i]->parent)
> > > > > > >                         pm_genpd_add_subdomain(scs[i]->parent, &scs[i]->pd);
> > > > > > > +               else if (!IS_ERR_OR_NULL(dev->pm_domain))
> > > > > >
> > > > > > So dev_pm_domain_attach() (which calls genpd_dev_pm_attach() is being
> > > > > > called for gdsc platform device from the platform bus', to try to
> > > > > > attach the device to its corresponding PM domain.
> > > > > >
> > > > > > Looking a bit closer to genpd_dev_pm_attach(), I realize that we
> > > > > > shouldn't really try to attach a device to its PM domain, when its OF
> > > > > > node (dev->of_node) contains a "#power-domain-cells" specifier. This
> > > > > > is because it indicates that the device belongs to a genpd provider
> > > > > > itself. In this case, a "power-domains" specifier tells that it has a
> > > > > > parent domain.
> > > > > >
> > > > > > I will post a patch that fixes this asap.
> > > > >
> > > > > I think there is nothing to fix here. The dispcc/videocc drivers
> > > > > provide clocks in addition to the gdsc power domain. And provided
> > > > > clocks would definitely benefit from having the dispcc device being
> > > > > attached to the power domain which governs clock registers (MMCX in
> > > > > our case). Thus I think it is perfectly valid to have:
> > > > >
> > > > > rpmhpd device:
> > > > >  - provides MMCX domain.
> > > > >
> > > > > dispcc device:
> > > > >  - is attached to the MMCX domain,
> > > >
> > > > We don't need this, it's redundant and weird to me.
> > > >
> > > > Also I am kind of worried that you will hit another new path in genpd,
> > > > causing locking issues etc, as it has not been designed to work like
> > > > this (a provider device and a child domain sharing the same "parent").
> > >
> > > So, which domain should the dispcc device belong to? It's registers
> > > are powered by the MMCX domain. I can not attach it to the child
> > > (GDSC) domain either: in the case of videocc there are 4 child
> > > domains.
> >
> > The dispcc device should *not* be attached to a PM domain.
> >
> > Instead it should be registered as a genpd provider and the
> > corresponding PM domains it provides, should be assigned as child
> > domains to the MMCX domain.
> >
> > This is exactly what the child/parent domain support in genpd is there
> > to help with.
>
> This is done in this patchset. If we stop attaching dispcc to the MMCX
> genpd, I'll have to locate it in a different way, but the idea is
> implemented here.

Right. Perhaps it's not such a bad idea after all as it gives you two things:

1) The handle to the MMCX PM domain, which makes sure it has been
registered too before dispcc gets probed.
2) The possibility to control power for the MMCX PM domain via runtime
PM for the dispcc device. This seems useful for your use case.

>
> > > An alternative would be to request that all users of the provided
> > > clocks power on one of the child domains. However this is also not
> > > perfect. If some generic code (e.g. clock framework) calls into
> > > provided clocks (e.g. because of assigned-clock-rates), this can
> > > happen w/o proper power domain being powered up yet.
> >
> > Issues with power on/off synchronization during genpd initializations
> > and genpd provider registration, certainly need to be fixed and I am
> > happy to help. However, my point is that I think it's a bad idea to
> > fix it through modelling the PM domain hierarchy in an incorrect way.
>
> So, which device should I pass to clk_register to handle runtime PM
> for the provided clocks? dispcc, should I not?

Right, anything but dispcc seems wrong.

> Then if the dispcc is not attached, we will have to manually handle
> MMCX from dispcc's runtime pm callbacks. Correct?

Yep - and we don't want that either.

>
> Could you please be more specific, why is it so wrong to attach dispcc
> to the MMCX genpd?

In the end it seems like I just needed to make my brain feel a little
more comfortable with the ideas that you put forward.

It should work fine, I think! My apologies for all the noise.

KInd regards
Uffe
Ulf Hansson July 9, 2021, 2:13 p.m. UTC | #12
On Fri, 9 Jul 2021 at 16:04, Bjorn Andersson <bjorn.andersson@linaro.org> wrote:
>
> On Fri 09 Jul 08:14 CDT 2021, Ulf Hansson wrote:
>
> > On Fri, 9 Jul 2021 at 14:59, Dmitry Baryshkov
> > <dmitry.baryshkov@linaro.org> wrote:
> > >
> > > On Fri, 9 Jul 2021 at 15:18, Ulf Hansson <ulf.hansson@linaro.org> wrote:
> > > >
> > > > On Fri, 9 Jul 2021 at 13:46, Dmitry Baryshkov
> > > > <dmitry.baryshkov@linaro.org> wrote:
> > > > >
> > > > > On Fri, 9 Jul 2021 at 12:33, Ulf Hansson <ulf.hansson@linaro.org> wrote:
> > > > > >
> > > > > > On Fri, 9 Jul 2021 at 06:32, Dmitry Baryshkov
> > > > > > <dmitry.baryshkov@linaro.org> wrote:
> > > > > > >
> > > > > > > On sm8250 dispcc and videocc registers are powered up by the MMCX power
> > > > > > > domain. Currently we used a regulator to enable this domain on demand,
> > > > > > > however this has some consequences, as genpd code is not reentrant.
> > > > > > >
> > > > > > > Teach Qualcomm clock controller code about setting up power domains and
> > > > > > > using them for gdsc control.
> > > > > > >
> > > > > > > Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> > > > > >
> > > > > > [...]
> > > > > >
> > > > > > > diff --git a/drivers/clk/qcom/gdsc.c b/drivers/clk/qcom/gdsc.c
> > > > > > > index 51ed640e527b..9401d01533c8 100644
> > > > > > > --- a/drivers/clk/qcom/gdsc.c
> > > > > > > +++ b/drivers/clk/qcom/gdsc.c
> > > > > > > @@ -427,6 +427,7 @@ int gdsc_register(struct gdsc_desc *desc,
> > > > > > >                         continue;
> > > > > > >                 scs[i]->regmap = regmap;
> > > > > > >                 scs[i]->rcdev = rcdev;
> > > > > > > +               scs[i]->pd.dev.parent = desc->dev;
> > > > > > >                 ret = gdsc_init(scs[i]);
> > > > > > >                 if (ret)
> > > > > > >                         return ret;
> > > > > > > @@ -439,6 +440,8 @@ int gdsc_register(struct gdsc_desc *desc,
> > > > > > >                         continue;
> > > > > > >                 if (scs[i]->parent)
> > > > > > >                         pm_genpd_add_subdomain(scs[i]->parent, &scs[i]->pd);
> > > > > > > +               else if (!IS_ERR_OR_NULL(dev->pm_domain))
> > > > > >
> > > > > > So dev_pm_domain_attach() (which calls genpd_dev_pm_attach() is being
> > > > > > called for gdsc platform device from the platform bus', to try to
> > > > > > attach the device to its corresponding PM domain.
> > > > > >
> > > > > > Looking a bit closer to genpd_dev_pm_attach(), I realize that we
> > > > > > shouldn't really try to attach a device to its PM domain, when its OF
> > > > > > node (dev->of_node) contains a "#power-domain-cells" specifier. This
> > > > > > is because it indicates that the device belongs to a genpd provider
> > > > > > itself. In this case, a "power-domains" specifier tells that it has a
> > > > > > parent domain.
> > > > > >
> > > > > > I will post a patch that fixes this asap.
> > > > >
> > > > > I think there is nothing to fix here. The dispcc/videocc drivers
> > > > > provide clocks in addition to the gdsc power domain. And provided
> > > > > clocks would definitely benefit from having the dispcc device being
> > > > > attached to the power domain which governs clock registers (MMCX in
> > > > > our case). Thus I think it is perfectly valid to have:
> > > > >
> > > > > rpmhpd device:
> > > > >  - provides MMCX domain.
> > > > >
> > > > > dispcc device:
> > > > >  - is attached to the MMCX domain,
> > > >
> > > > We don't need this, it's redundant and weird to me.
> > > >
> > > > Also I am kind of worried that you will hit another new path in genpd,
> > > > causing locking issues etc, as it has not been designed to work like
> > > > this (a provider device and a child domain sharing the same "parent").
> > >
> > > So, which domain should the dispcc device belong to? It's registers
> > > are powered by the MMCX domain. I can not attach it to the child
> > > (GDSC) domain either: in the case of videocc there are 4 child
> > > domains.
> >
> > The dispcc device should *not* be attached to a PM domain.
> >
>
> dispcc is powered by the MMCX power domain, so it needs to be on if you
> want to touch the registers.
>
> I presume that for genpd this might not be a problem as long as all the
> exposed power domains are parented by the genpd provider's parent, as
> the core would turn the parent on before and turn off after performing
> those operations. But without attaching to the domain we don't have
> power to get through probe/registration.
>
> Further more, dispcc is also a clock driver and there's certainly
> operations where the genpd framework won't save us.
>
> > Instead it should be registered as a genpd provider and the
> > corresponding PM domains it provides, should be assigned as child
> > domains to the MMCX domain.
> >
>
> Right, this relationship is today missing and is what Dmitry needs to
> add - so that the parent domains stays powered even when we're not
> keeping the parent domain enabled to poke the dispcc.
>
> > This is exactly what the child/parent domain support in genpd is there
> > to help with.
> >
> > > An alternative would be to request that all users of the provided
> > > clocks power on one of the child domains. However this is also not
> > > perfect. If some generic code (e.g. clock framework) calls into
> > > provided clocks (e.g. because of assigned-clock-rates), this can
> > > happen w/o proper power domain being powered up yet.
> >
> > Issues with power on/off synchronization during genpd initializations
> > and genpd provider registration, certainly need to be fixed and I am
> > happy to help. However, my point is that I think it's a bad idea to
> > fix it through modelling the PM domain hierarchy in an incorrect way.
> >
>
> This was my initial feeling to the patch as well and I think it might be
> better to push the pm_runtime_get/put operations into gdsc.c - in
> particular if you're saying that the general case is not for the genpd
> provider itself to be powered by the specified parent domain.
>
> At least we could start by doing it manually in gdsc.c and possibly move
> it into the framework if we're confident that it's a good idea.

Yes, better to start making this Qcom specific, then we can take it from there.

Kind regards
Uffe
Dmitry Baryshkov July 9, 2021, 2:14 p.m. UTC | #13
On Fri, 9 Jul 2021 at 17:11, Ulf Hansson <ulf.hansson@linaro.org> wrote:
>

> On Fri, 9 Jul 2021 at 15:22, Dmitry Baryshkov

> <dmitry.baryshkov@linaro.org> wrote:

> >

> > On Fri, 9 Jul 2021 at 16:14, Ulf Hansson <ulf.hansson@linaro.org> wrote:

> > >

> > > On Fri, 9 Jul 2021 at 14:59, Dmitry Baryshkov

> > > <dmitry.baryshkov@linaro.org> wrote:

> > > >

> > > > On Fri, 9 Jul 2021 at 15:18, Ulf Hansson <ulf.hansson@linaro.org> wrote:

> > > > >

> > > > > On Fri, 9 Jul 2021 at 13:46, Dmitry Baryshkov

> > > > > <dmitry.baryshkov@linaro.org> wrote:

> > > > > >

> > > > > > On Fri, 9 Jul 2021 at 12:33, Ulf Hansson <ulf.hansson@linaro.org> wrote:

> > > > > > >

> > > > > > > On Fri, 9 Jul 2021 at 06:32, Dmitry Baryshkov

> > > > > > > <dmitry.baryshkov@linaro.org> wrote:

> > > > > > > >

> > > > > > > > On sm8250 dispcc and videocc registers are powered up by the MMCX power

> > > > > > > > domain. Currently we used a regulator to enable this domain on demand,

> > > > > > > > however this has some consequences, as genpd code is not reentrant.

> > > > > > > >

> > > > > > > > Teach Qualcomm clock controller code about setting up power domains and

> > > > > > > > using them for gdsc control.

> > > > > > > >

> > > > > > > > Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>

> > > > > > >

> > > > > > > [...]

> > > > > > >

> > > > > > > > diff --git a/drivers/clk/qcom/gdsc.c b/drivers/clk/qcom/gdsc.c

> > > > > > > > index 51ed640e527b..9401d01533c8 100644

> > > > > > > > --- a/drivers/clk/qcom/gdsc.c

> > > > > > > > +++ b/drivers/clk/qcom/gdsc.c

> > > > > > > > @@ -427,6 +427,7 @@ int gdsc_register(struct gdsc_desc *desc,

> > > > > > > >                         continue;

> > > > > > > >                 scs[i]->regmap = regmap;

> > > > > > > >                 scs[i]->rcdev = rcdev;

> > > > > > > > +               scs[i]->pd.dev.parent = desc->dev;

> > > > > > > >                 ret = gdsc_init(scs[i]);

> > > > > > > >                 if (ret)

> > > > > > > >                         return ret;

> > > > > > > > @@ -439,6 +440,8 @@ int gdsc_register(struct gdsc_desc *desc,

> > > > > > > >                         continue;

> > > > > > > >                 if (scs[i]->parent)

> > > > > > > >                         pm_genpd_add_subdomain(scs[i]->parent, &scs[i]->pd);

> > > > > > > > +               else if (!IS_ERR_OR_NULL(dev->pm_domain))

> > > > > > >

> > > > > > > So dev_pm_domain_attach() (which calls genpd_dev_pm_attach() is being

> > > > > > > called for gdsc platform device from the platform bus', to try to

> > > > > > > attach the device to its corresponding PM domain.

> > > > > > >

> > > > > > > Looking a bit closer to genpd_dev_pm_attach(), I realize that we

> > > > > > > shouldn't really try to attach a device to its PM domain, when its OF

> > > > > > > node (dev->of_node) contains a "#power-domain-cells" specifier. This

> > > > > > > is because it indicates that the device belongs to a genpd provider

> > > > > > > itself. In this case, a "power-domains" specifier tells that it has a

> > > > > > > parent domain.

> > > > > > >

> > > > > > > I will post a patch that fixes this asap.

> > > > > >

> > > > > > I think there is nothing to fix here. The dispcc/videocc drivers

> > > > > > provide clocks in addition to the gdsc power domain. And provided

> > > > > > clocks would definitely benefit from having the dispcc device being

> > > > > > attached to the power domain which governs clock registers (MMCX in

> > > > > > our case). Thus I think it is perfectly valid to have:

> > > > > >

> > > > > > rpmhpd device:

> > > > > >  - provides MMCX domain.

> > > > > >

> > > > > > dispcc device:

> > > > > >  - is attached to the MMCX domain,

> > > > >

> > > > > We don't need this, it's redundant and weird to me.

> > > > >

> > > > > Also I am kind of worried that you will hit another new path in genpd,

> > > > > causing locking issues etc, as it has not been designed to work like

> > > > > this (a provider device and a child domain sharing the same "parent").

> > > >

> > > > So, which domain should the dispcc device belong to? It's registers

> > > > are powered by the MMCX domain. I can not attach it to the child

> > > > (GDSC) domain either: in the case of videocc there are 4 child

> > > > domains.

> > >

> > > The dispcc device should *not* be attached to a PM domain.

> > >

> > > Instead it should be registered as a genpd provider and the

> > > corresponding PM domains it provides, should be assigned as child

> > > domains to the MMCX domain.

> > >

> > > This is exactly what the child/parent domain support in genpd is there

> > > to help with.

> >

> > This is done in this patchset. If we stop attaching dispcc to the MMCX

> > genpd, I'll have to locate it in a different way, but the idea is

> > implemented here.

>

> Right. Perhaps it's not such a bad idea after all as it gives you two things:

>

> 1) The handle to the MMCX PM domain, which makes sure it has been

> registered too before dispcc gets probed.

> 2) The possibility to control power for the MMCX PM domain via runtime

> PM for the dispcc device. This seems useful for your use case.

>

> >

> > > > An alternative would be to request that all users of the provided

> > > > clocks power on one of the child domains. However this is also not

> > > > perfect. If some generic code (e.g. clock framework) calls into

> > > > provided clocks (e.g. because of assigned-clock-rates), this can

> > > > happen w/o proper power domain being powered up yet.

> > >

> > > Issues with power on/off synchronization during genpd initializations

> > > and genpd provider registration, certainly need to be fixed and I am

> > > happy to help. However, my point is that I think it's a bad idea to

> > > fix it through modelling the PM domain hierarchy in an incorrect way.

> >

> > So, which device should I pass to clk_register to handle runtime PM

> > for the provided clocks? dispcc, should I not?

>

> Right, anything but dispcc seems wrong.

>

> > Then if the dispcc is not attached, we will have to manually handle

> > MMCX from dispcc's runtime pm callbacks. Correct?

>

> Yep - and we don't want that either.

>

> >

> > Could you please be more specific, why is it so wrong to attach dispcc

> > to the MMCX genpd?

>

> In the end it seems like I just needed to make my brain feel a little

> more comfortable with the ideas that you put forward.

>

> It should work fine, I think! My apologies for all the noise.


No problem, it is always better to have a discussion (and a
conclusion) rather than not to have it.

Thank you for your comments!


-- 
With best wishes
Dmitry
Dmitry Baryshkov July 9, 2021, 2:15 p.m. UTC | #14
On Fri, 9 Jul 2021 at 17:13, Ulf Hansson <ulf.hansson@linaro.org> wrote:
>
> On Fri, 9 Jul 2021 at 16:04, Bjorn Andersson <bjorn.andersson@linaro.org> wrote:
> >
> > On Fri 09 Jul 08:14 CDT 2021, Ulf Hansson wrote:
> >
> > > On Fri, 9 Jul 2021 at 14:59, Dmitry Baryshkov
> > > <dmitry.baryshkov@linaro.org> wrote:
> > > >
> > > > On Fri, 9 Jul 2021 at 15:18, Ulf Hansson <ulf.hansson@linaro.org> wrote:
> > > > >
> > > > > On Fri, 9 Jul 2021 at 13:46, Dmitry Baryshkov
> > > > > <dmitry.baryshkov@linaro.org> wrote:
> > > > > >
> > > > > > On Fri, 9 Jul 2021 at 12:33, Ulf Hansson <ulf.hansson@linaro.org> wrote:
> > > > > > >
> > > > > > > On Fri, 9 Jul 2021 at 06:32, Dmitry Baryshkov
> > > > > > > <dmitry.baryshkov@linaro.org> wrote:
> > > > > > > >
> > > > > > > > On sm8250 dispcc and videocc registers are powered up by the MMCX power
> > > > > > > > domain. Currently we used a regulator to enable this domain on demand,
> > > > > > > > however this has some consequences, as genpd code is not reentrant.
> > > > > > > >
> > > > > > > > Teach Qualcomm clock controller code about setting up power domains and
> > > > > > > > using them for gdsc control.
> > > > > > > >
> > > > > > > > Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> > > > > > >
> > > > > > > [...]
> > > > > > >
> > > > > > > > diff --git a/drivers/clk/qcom/gdsc.c b/drivers/clk/qcom/gdsc.c
> > > > > > > > index 51ed640e527b..9401d01533c8 100644
> > > > > > > > --- a/drivers/clk/qcom/gdsc.c
> > > > > > > > +++ b/drivers/clk/qcom/gdsc.c
> > > > > > > > @@ -427,6 +427,7 @@ int gdsc_register(struct gdsc_desc *desc,
> > > > > > > >                         continue;
> > > > > > > >                 scs[i]->regmap = regmap;
> > > > > > > >                 scs[i]->rcdev = rcdev;
> > > > > > > > +               scs[i]->pd.dev.parent = desc->dev;
> > > > > > > >                 ret = gdsc_init(scs[i]);
> > > > > > > >                 if (ret)
> > > > > > > >                         return ret;
> > > > > > > > @@ -439,6 +440,8 @@ int gdsc_register(struct gdsc_desc *desc,
> > > > > > > >                         continue;
> > > > > > > >                 if (scs[i]->parent)
> > > > > > > >                         pm_genpd_add_subdomain(scs[i]->parent, &scs[i]->pd);
> > > > > > > > +               else if (!IS_ERR_OR_NULL(dev->pm_domain))
> > > > > > >
> > > > > > > So dev_pm_domain_attach() (which calls genpd_dev_pm_attach() is being
> > > > > > > called for gdsc platform device from the platform bus', to try to
> > > > > > > attach the device to its corresponding PM domain.
> > > > > > >
> > > > > > > Looking a bit closer to genpd_dev_pm_attach(), I realize that we
> > > > > > > shouldn't really try to attach a device to its PM domain, when its OF
> > > > > > > node (dev->of_node) contains a "#power-domain-cells" specifier. This
> > > > > > > is because it indicates that the device belongs to a genpd provider
> > > > > > > itself. In this case, a "power-domains" specifier tells that it has a
> > > > > > > parent domain.
> > > > > > >
> > > > > > > I will post a patch that fixes this asap.
> > > > > >
> > > > > > I think there is nothing to fix here. The dispcc/videocc drivers
> > > > > > provide clocks in addition to the gdsc power domain. And provided
> > > > > > clocks would definitely benefit from having the dispcc device being
> > > > > > attached to the power domain which governs clock registers (MMCX in
> > > > > > our case). Thus I think it is perfectly valid to have:
> > > > > >
> > > > > > rpmhpd device:
> > > > > >  - provides MMCX domain.
> > > > > >
> > > > > > dispcc device:
> > > > > >  - is attached to the MMCX domain,
> > > > >
> > > > > We don't need this, it's redundant and weird to me.
> > > > >
> > > > > Also I am kind of worried that you will hit another new path in genpd,
> > > > > causing locking issues etc, as it has not been designed to work like
> > > > > this (a provider device and a child domain sharing the same "parent").
> > > >
> > > > So, which domain should the dispcc device belong to? It's registers
> > > > are powered by the MMCX domain. I can not attach it to the child
> > > > (GDSC) domain either: in the case of videocc there are 4 child
> > > > domains.
> > >
> > > The dispcc device should *not* be attached to a PM domain.
> > >
> >
> > dispcc is powered by the MMCX power domain, so it needs to be on if you
> > want to touch the registers.
> >
> > I presume that for genpd this might not be a problem as long as all the
> > exposed power domains are parented by the genpd provider's parent, as
> > the core would turn the parent on before and turn off after performing
> > those operations. But without attaching to the domain we don't have
> > power to get through probe/registration.
> >
> > Further more, dispcc is also a clock driver and there's certainly
> > operations where the genpd framework won't save us.
> >
> > > Instead it should be registered as a genpd provider and the
> > > corresponding PM domains it provides, should be assigned as child
> > > domains to the MMCX domain.
> > >
> >
> > Right, this relationship is today missing and is what Dmitry needs to
> > add - so that the parent domains stays powered even when we're not
> > keeping the parent domain enabled to poke the dispcc.
> >
> > > This is exactly what the child/parent domain support in genpd is there
> > > to help with.
> > >
> > > > An alternative would be to request that all users of the provided
> > > > clocks power on one of the child domains. However this is also not
> > > > perfect. If some generic code (e.g. clock framework) calls into
> > > > provided clocks (e.g. because of assigned-clock-rates), this can
> > > > happen w/o proper power domain being powered up yet.
> > >
> > > Issues with power on/off synchronization during genpd initializations
> > > and genpd provider registration, certainly need to be fixed and I am
> > > happy to help. However, my point is that I think it's a bad idea to
> > > fix it through modelling the PM domain hierarchy in an incorrect way.
> > >
> >
> > This was my initial feeling to the patch as well and I think it might be
> > better to push the pm_runtime_get/put operations into gdsc.c - in
> > particular if you're saying that the general case is not for the genpd
> > provider itself to be powered by the specified parent domain.
> >
> > At least we could start by doing it manually in gdsc.c and possibly move
> > it into the framework if we're confident that it's a good idea.
>
> Yes, better to start making this Qcom specific, then we can take it from there.

I will re-add pm_runtime calls to gdsc.c and send a v3.