public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] pmdomain:rockchip: Fix init genpd as GENPD_STATE_ON before regulator ready
@ 2025-12-16  5:52 Frank Zhang
  2025-12-30 14:07 ` Ulf Hansson
  0 siblings, 1 reply; 4+ messages in thread
From: Frank Zhang @ 2025-12-16  5:52 UTC (permalink / raw)
  To: heiko, ulf.hansson
  Cc: linux-rockchip, linux-pm, chaoyi.chen, sebastian.reichel,
	quentin.schulz, Frank Zhang

RK3588_PD_NPU initialize as GENPD_STATE_ON before regulator ready.
rknn_iommu initlized success and suspend RK3588_PD_NPU. When rocket
driver register, it will resume rknn_iommu.

If regulator is still not ready at this point, rknn_iommu resume fail,
pm runtime status will be error: -EPROBE_DEFER.

This patch set pmdomain to off if it need regulator during probe,
consumer device can power on pmdomain after regulator ready.

Signed-off-by: Frank Zhang <rmxpzlb@gmail.com>
Tested-by: Chaoyi Chen <chaoyi.chen@rock-chips.com>
Tested-by: Quentin Schulz <quentin.schulz@cherry.de>
---
Changes in v2:
- Simplified the regulator check logic, trun off pmdomain if need
  regulator.
---
 drivers/pmdomain/rockchip/pm-domains.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/pmdomain/rockchip/pm-domains.c b/drivers/pmdomain/rockchip/pm-domains.c
index 4f1336a0f49a..997e93c12951 100644
--- a/drivers/pmdomain/rockchip/pm-domains.c
+++ b/drivers/pmdomain/rockchip/pm-domains.c
@@ -879,6 +879,16 @@ static int rockchip_pm_add_one_domain(struct rockchip_pmu *pmu,
 		pd->genpd.name = pd->info->name;
 	else
 		pd->genpd.name = kbasename(node->full_name);
+
+	/*
+	 * power domain's needing a regulator should default to off, since
+	 * the regulator state is unknown at probe time. Also the regulator
+	 * state cannot be checked, since that usually requires IP needing
+	 * (a different) power domain.
+	 */
+	if (pd->info->need_regulator)
+		rockchip_pd_power(pd, false);
+
 	pd->genpd.power_off = rockchip_pd_power_off;
 	pd->genpd.power_on = rockchip_pd_power_on;
 	pd->genpd.attach_dev = rockchip_pd_attach_dev;

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] pmdomain:rockchip: Fix init genpd as GENPD_STATE_ON before regulator ready
  2025-12-16  5:52 [PATCH v2] pmdomain:rockchip: Fix init genpd as GENPD_STATE_ON before regulator ready Frank Zhang
@ 2025-12-30 14:07 ` Ulf Hansson
  2026-01-12  1:10   ` Sebastian Reichel
  0 siblings, 1 reply; 4+ messages in thread
From: Ulf Hansson @ 2025-12-30 14:07 UTC (permalink / raw)
  To: Frank Zhang
  Cc: heiko, linux-rockchip, linux-pm, chaoyi.chen, sebastian.reichel,
	quentin.schulz, Nicolas Frattaroli

+ Nicolas

On Tue, 16 Dec 2025 at 06:53, Frank Zhang <rmxpzlb@gmail.com> wrote:
>
> RK3588_PD_NPU initialize as GENPD_STATE_ON before regulator ready.
> rknn_iommu initlized success and suspend RK3588_PD_NPU. When rocket
> driver register, it will resume rknn_iommu.
>
> If regulator is still not ready at this point, rknn_iommu resume fail,
> pm runtime status will be error: -EPROBE_DEFER.
>
> This patch set pmdomain to off if it need regulator during probe,
> consumer device can power on pmdomain after regulator ready.
>
> Signed-off-by: Frank Zhang <rmxpzlb@gmail.com>
> Tested-by: Chaoyi Chen <chaoyi.chen@rock-chips.com>
> Tested-by: Quentin Schulz <quentin.schulz@cherry.de>

The problem with the child-domain using a regulator has been discussed
before [1] between Nicolas, Heiko and me. That said, I have looped in
Nicolas to allow him to share his opinion about this too.

My view on is that I would prefer that we try to address/fix the root
cause, rather than trying to paper over the problem as what seems to
be suggested in the $subject patch. Or at least I need Nicolas/Heiko
to confirm that they are fine with the $subject patch, before I pick
it up.

Kind regards
Uffe

> ---
> Changes in v2:
> - Simplified the regulator check logic, trun off pmdomain if need
>   regulator.
> ---
>  drivers/pmdomain/rockchip/pm-domains.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
>
> diff --git a/drivers/pmdomain/rockchip/pm-domains.c b/drivers/pmdomain/rockchip/pm-domains.c
> index 4f1336a0f49a..997e93c12951 100644
> --- a/drivers/pmdomain/rockchip/pm-domains.c
> +++ b/drivers/pmdomain/rockchip/pm-domains.c
> @@ -879,6 +879,16 @@ static int rockchip_pm_add_one_domain(struct rockchip_pmu *pmu,
>                 pd->genpd.name = pd->info->name;
>         else
>                 pd->genpd.name = kbasename(node->full_name);
> +
> +       /*
> +        * power domain's needing a regulator should default to off, since
> +        * the regulator state is unknown at probe time. Also the regulator
> +        * state cannot be checked, since that usually requires IP needing
> +        * (a different) power domain.
> +        */
> +       if (pd->info->need_regulator)
> +               rockchip_pd_power(pd, false);
> +
>         pd->genpd.power_off = rockchip_pd_power_off;
>         pd->genpd.power_on = rockchip_pd_power_on;
>         pd->genpd.attach_dev = rockchip_pd_attach_dev;

[1]
https://lore.kernel.org/all/CAPDyKFr=GwJ+cO3cW4Ed_LsS=q_JtuuQPDweDpLgDO4hBLFXUA@mail.gmail.com/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] pmdomain:rockchip: Fix init genpd as GENPD_STATE_ON before regulator ready
  2025-12-30 14:07 ` Ulf Hansson
@ 2026-01-12  1:10   ` Sebastian Reichel
  2026-01-15 16:23     ` Ulf Hansson
  0 siblings, 1 reply; 4+ messages in thread
From: Sebastian Reichel @ 2026-01-12  1:10 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Frank Zhang, heiko, linux-rockchip, linux-pm, chaoyi.chen,
	quentin.schulz, Nicolas Frattaroli

[-- Attachment #1: Type: text/plain, Size: 3448 bytes --]

Hi,

On Tue, Dec 30, 2025 at 03:07:37PM +0100, Ulf Hansson wrote:
> + Nicolas
> 
> On Tue, 16 Dec 2025 at 06:53, Frank Zhang <rmxpzlb@gmail.com> wrote:
> >
> > RK3588_PD_NPU initialize as GENPD_STATE_ON before regulator ready.
> > rknn_iommu initlized success and suspend RK3588_PD_NPU. When rocket
> > driver register, it will resume rknn_iommu.
> >
> > If regulator is still not ready at this point, rknn_iommu resume fail,
> > pm runtime status will be error: -EPROBE_DEFER.
> >
> > This patch set pmdomain to off if it need regulator during probe,
> > consumer device can power on pmdomain after regulator ready.
> >
> > Signed-off-by: Frank Zhang <rmxpzlb@gmail.com>
> > Tested-by: Chaoyi Chen <chaoyi.chen@rock-chips.com>
> > Tested-by: Quentin Schulz <quentin.schulz@cherry.de>
> 
> The problem with the child-domain using a regulator has been discussed
> before [1] between Nicolas, Heiko and me. That said, I have looped in
> Nicolas to allow him to share his opinion about this too.
> fauxbus
> My view on is that I would prefer that we try to address/fix the root
> cause, rather than trying to paper over the problem as what seems to
> be suggested in the $subject patch. Or at least I need Nicolas/Heiko
> to confirm that they are fine with the $subject patch, before I pick
> it up.

FWIW my thoughts on this:

I believe the proper solution would be to acquire the regulator at
probe time how it is usually being done in other drivers. I think
this requires restructuring the driver, so that the sub-domains are
registered as sub-devices (e.g. via fauxbus) to avoid the
chicken-and-egg problem of the regulator for pmdomain1 needing
pmdomain2. As this modification is most likely too big to be
backported I think this patch should be merged for now:

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Cc: stable@vger.kernel.org
Fixes: db6df2e3fc16 ("pmdomain: rockchip: add regulator support")

Greetings,

-- Sebastian

> 
> Kind regards
> Uffe
> 
> > ---
> > Changes in v2:
> > - Simplified the regulator check logic, trun off pmdomain if need
> >   regulator.
> > ---
> >  drivers/pmdomain/rockchip/pm-domains.c | 10 ++++++++++
> >  1 file changed, 10 insertions(+)
> >
> > diff --git a/drivers/pmdomain/rockchip/pm-domains.c b/drivers/pmdomain/rockchip/pm-domains.c
> > index 4f1336a0f49a..997e93c12951 100644
> > --- a/drivers/pmdomain/rockchip/pm-domains.c
> > +++ b/drivers/pmdomain/rockchip/pm-domains.c
> > @@ -879,6 +879,16 @@ static int rockchip_pm_add_one_domain(struct rockchip_pmu *pmu,
> >                 pd->genpd.name = pd->info->name;
> >         else
> >                 pd->genpd.name = kbasename(node->full_name);
> > +
> > +       /*
> > +        * power domain's needing a regulator should default to off, since
> > +        * the regulator state is unknown at probe time. Also the regulator
> > +        * state cannot be checked, since that usually requires IP needing
> > +        * (a different) power domain.
> > +        */
> > +       if (pd->info->need_regulator)
> > +               rockchip_pd_power(pd, false);
> > +
> >         pd->genpd.power_off = rockchip_pd_power_off;
> >         pd->genpd.power_on = rockchip_pd_power_on;
> >         pd->genpd.attach_dev = rockchip_pd_attach_dev;
> 
> [1]
> https://lore.kernel.org/all/CAPDyKFr=GwJ+cO3cW4Ed_LsS=q_JtuuQPDweDpLgDO4hBLFXUA@mail.gmail.com/
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] pmdomain:rockchip: Fix init genpd as GENPD_STATE_ON before regulator ready
  2026-01-12  1:10   ` Sebastian Reichel
@ 2026-01-15 16:23     ` Ulf Hansson
  0 siblings, 0 replies; 4+ messages in thread
From: Ulf Hansson @ 2026-01-15 16:23 UTC (permalink / raw)
  To: Frank Zhang, Sebastian Reichel
  Cc: heiko, linux-rockchip, linux-pm, chaoyi.chen, quentin.schulz,
	Nicolas Frattaroli

On Mon, 12 Jan 2026 at 02:11, Sebastian Reichel
<sebastian.reichel@collabora.com> wrote:
>
> Hi,
>
> On Tue, Dec 30, 2025 at 03:07:37PM +0100, Ulf Hansson wrote:
> > + Nicolas
> >
> > On Tue, 16 Dec 2025 at 06:53, Frank Zhang <rmxpzlb@gmail.com> wrote:
> > >
> > > RK3588_PD_NPU initialize as GENPD_STATE_ON before regulator ready.
> > > rknn_iommu initlized success and suspend RK3588_PD_NPU. When rocket
> > > driver register, it will resume rknn_iommu.
> > >
> > > If regulator is still not ready at this point, rknn_iommu resume fail,
> > > pm runtime status will be error: -EPROBE_DEFER.
> > >
> > > This patch set pmdomain to off if it need regulator during probe,
> > > consumer device can power on pmdomain after regulator ready.
> > >
> > > Signed-off-by: Frank Zhang <rmxpzlb@gmail.com>
> > > Tested-by: Chaoyi Chen <chaoyi.chen@rock-chips.com>
> > > Tested-by: Quentin Schulz <quentin.schulz@cherry.de>
> >
> > The problem with the child-domain using a regulator has been discussed
> > before [1] between Nicolas, Heiko and me. That said, I have looped in
> > Nicolas to allow him to share his opinion about this too.
> > fauxbus
> > My view on is that I would prefer that we try to address/fix the root
> > cause, rather than trying to paper over the problem as what seems to
> > be suggested in the $subject patch. Or at least I need Nicolas/Heiko
> > to confirm that they are fine with the $subject patch, before I pick
> > it up.
>
> FWIW my thoughts on this:
>
> I believe the proper solution would be to acquire the regulator at
> probe time how it is usually being done in other drivers. I think
> this requires restructuring the driver, so that the sub-domains are
> registered as sub-devices (e.g. via fauxbus) to avoid the
> chicken-and-egg problem of the regulator for pmdomain1 needing
> pmdomain2. As this modification is most likely too big to be
> backported I think this patch should be merged for now:

Fair enough!

I agree with the above, while perhaps the auxiliary bus is probably a
better choice instead of the fauxbus for this case.

>
> Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>
> Cc: stable@vger.kernel.org
> Fixes: db6df2e3fc16 ("pmdomain: rockchip: add regulator support")

Applied for fixes, thanks!

Kind regards
Uffe



>
> Greetings,
>
> -- Sebastian
>
> >
> > Kind regards
> > Uffe
> >
> > > ---
> > > Changes in v2:
> > > - Simplified the regulator check logic, trun off pmdomain if need
> > >   regulator.
> > > ---
> > >  drivers/pmdomain/rockchip/pm-domains.c | 10 ++++++++++
> > >  1 file changed, 10 insertions(+)
> > >
> > > diff --git a/drivers/pmdomain/rockchip/pm-domains.c b/drivers/pmdomain/rockchip/pm-domains.c
> > > index 4f1336a0f49a..997e93c12951 100644
> > > --- a/drivers/pmdomain/rockchip/pm-domains.c
> > > +++ b/drivers/pmdomain/rockchip/pm-domains.c
> > > @@ -879,6 +879,16 @@ static int rockchip_pm_add_one_domain(struct rockchip_pmu *pmu,
> > >                 pd->genpd.name = pd->info->name;
> > >         else
> > >                 pd->genpd.name = kbasename(node->full_name);
> > > +
> > > +       /*
> > > +        * power domain's needing a regulator should default to off, since
> > > +        * the regulator state is unknown at probe time. Also the regulator
> > > +        * state cannot be checked, since that usually requires IP needing
> > > +        * (a different) power domain.
> > > +        */
> > > +       if (pd->info->need_regulator)
> > > +               rockchip_pd_power(pd, false);
> > > +
> > >         pd->genpd.power_off = rockchip_pd_power_off;
> > >         pd->genpd.power_on = rockchip_pd_power_on;
> > >         pd->genpd.attach_dev = rockchip_pd_attach_dev;
> >
> > [1]
> > https://lore.kernel.org/all/CAPDyKFr=GwJ+cO3cW4Ed_LsS=q_JtuuQPDweDpLgDO4hBLFXUA@mail.gmail.com/
> >

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-01-15 16:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-16  5:52 [PATCH v2] pmdomain:rockchip: Fix init genpd as GENPD_STATE_ON before regulator ready Frank Zhang
2025-12-30 14:07 ` Ulf Hansson
2026-01-12  1:10   ` Sebastian Reichel
2026-01-15 16:23     ` Ulf Hansson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox