[PATCH/RFC] pmdomain: core: Support pd_ignore_unused with sync_state

Geert Uytterhoeven posted 1 patch 2 weeks, 2 days ago
drivers/pmdomain/core.c | 20 +++++++++++++++++---
1 file changed, 17 insertions(+), 3 deletions(-)
[PATCH/RFC] pmdomain: core: Support pd_ignore_unused with sync_state
Posted by Geert Uytterhoeven 2 weeks, 2 days ago
Since the introduction of the sync_state mechanism, the
"pd_ignore_unused" kernel command line option doesn't really work
anymore.  While genpd_power_off_unused() still checks for that flag
before powering down unused domains, the new sync_state callbacks lack
such checks, thus powering down unused domains regardless.

Fix this by adding checks to the sync_state helpers and callbacks.
Factor out the printing of the warning message, to make sure it is
printed only once.

Fixes: 002ebddd695a5399 ("pmdomain: core: Restore behaviour for disabling unused PM domains")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
RFC as I have no need for this in upstream.
---
 drivers/pmdomain/core.c | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/drivers/pmdomain/core.c b/drivers/pmdomain/core.c
index 7b563757935071dd..1f7d90bcc30d12e5 100644
--- a/drivers/pmdomain/core.c
+++ b/drivers/pmdomain/core.c
@@ -1366,6 +1366,16 @@ static int __init pd_ignore_unused_setup(char *__unused)
 }
 __setup("pd_ignore_unused", pd_ignore_unused_setup);
 
+static bool genpd_ignore_unused(void)
+{
+	if (pd_ignore_unused) {
+		pr_warn_once("genpd: Not disabling unused power domains\n");
+		return true;
+	}
+
+	return false;
+}
+
 /**
  * genpd_power_off_unused - Power off all PM domains with no devices in use.
  */
@@ -1373,10 +1383,8 @@ static int __init genpd_power_off_unused(void)
 {
 	struct generic_pm_domain *genpd;
 
-	if (pd_ignore_unused) {
-		pr_warn("genpd: Not disabling unused power domains\n");
+	if (genpd_ignore_unused())
 		return 0;
-	}
 
 	pr_info("genpd: Disabling unused power domains\n");
 	mutex_lock(&gpd_list_lock);
@@ -3510,6 +3518,9 @@ void of_genpd_sync_state(struct device_node *np)
 {
 	struct generic_pm_domain *genpd;
 
+	if (genpd_ignore_unused())
+		return;
+
 	if (!np)
 		return;
 
@@ -3544,6 +3555,9 @@ static void genpd_provider_sync_state(struct device *dev)
 		break;
 
 	case GENPD_SYNC_STATE_SIMPLE:
+		if (genpd_ignore_unused())
+			return;
+
 		genpd_lock(genpd);
 		genpd->stay_on = false;
 		genpd_power_off(genpd, false, 0);
-- 
2.43.0
Re: [PATCH/RFC] pmdomain: core: Support pd_ignore_unused with sync_state
Posted by Ulf Hansson 17 hours ago
On Mon, 16 Feb 2026 at 19:47, Geert Uytterhoeven
<geert+renesas@glider.be> wrote:
>
> Since the introduction of the sync_state mechanism, the
> "pd_ignore_unused" kernel command line option doesn't really work
> anymore.  While genpd_power_off_unused() still checks for that flag
> before powering down unused domains, the new sync_state callbacks lack
> such checks, thus powering down unused domains regardless.
>
> Fix this by adding checks to the sync_state helpers and callbacks.
> Factor out the printing of the warning message, to make sure it is
> printed only once.
>
> Fixes: 002ebddd695a5399 ("pmdomain: core: Restore behaviour for disabling unused PM domains")
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
> RFC as I have no need for this in upstream.

I am trying to understand the use case and whether we should consider
to land this upstream.

Would you mind elaborating on how this is useful for you?

Kind regards
Uffe

> ---
>  drivers/pmdomain/core.c | 20 +++++++++++++++++---
>  1 file changed, 17 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/pmdomain/core.c b/drivers/pmdomain/core.c
> index 7b563757935071dd..1f7d90bcc30d12e5 100644
> --- a/drivers/pmdomain/core.c
> +++ b/drivers/pmdomain/core.c
> @@ -1366,6 +1366,16 @@ static int __init pd_ignore_unused_setup(char *__unused)
>  }
>  __setup("pd_ignore_unused", pd_ignore_unused_setup);
>
> +static bool genpd_ignore_unused(void)
> +{
> +       if (pd_ignore_unused) {
> +               pr_warn_once("genpd: Not disabling unused power domains\n");
> +               return true;
> +       }
> +
> +       return false;
> +}
> +
>  /**
>   * genpd_power_off_unused - Power off all PM domains with no devices in use.
>   */
> @@ -1373,10 +1383,8 @@ static int __init genpd_power_off_unused(void)
>  {
>         struct generic_pm_domain *genpd;
>
> -       if (pd_ignore_unused) {
> -               pr_warn("genpd: Not disabling unused power domains\n");
> +       if (genpd_ignore_unused())
>                 return 0;
> -       }
>
>         pr_info("genpd: Disabling unused power domains\n");
>         mutex_lock(&gpd_list_lock);
> @@ -3510,6 +3518,9 @@ void of_genpd_sync_state(struct device_node *np)
>  {
>         struct generic_pm_domain *genpd;
>
> +       if (genpd_ignore_unused())
> +               return;
> +
>         if (!np)
>                 return;
>
> @@ -3544,6 +3555,9 @@ static void genpd_provider_sync_state(struct device *dev)
>                 break;
>
>         case GENPD_SYNC_STATE_SIMPLE:
> +               if (genpd_ignore_unused())
> +                       return;
> +
>                 genpd_lock(genpd);
>                 genpd->stay_on = false;
>                 genpd_power_off(genpd, false, 0);
> --
> 2.43.0
>
Re: [PATCH/RFC] pmdomain: core: Support pd_ignore_unused with sync_state
Posted by Geert Uytterhoeven 17 hours ago
Hi Ulf,

On Wed, 4 Mar 2026 at 11:56, Ulf Hansson <ulf.hansson@linaro.org> wrote:
> On Mon, 16 Feb 2026 at 19:47, Geert Uytterhoeven
> <geert+renesas@glider.be> wrote:
> > Since the introduction of the sync_state mechanism, the
> > "pd_ignore_unused" kernel command line option doesn't really work
> > anymore.  While genpd_power_off_unused() still checks for that flag
> > before powering down unused domains, the new sync_state callbacks lack
> > such checks, thus powering down unused domains regardless.
> >
> > Fix this by adding checks to the sync_state helpers and callbacks.
> > Factor out the printing of the warning message, to make sure it is
> > printed only once.
> >
> > Fixes: 002ebddd695a5399 ("pmdomain: core: Restore behaviour for disabling unused PM domains")
> > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> > ---
> > RFC as I have no need for this in upstream.
>
> I am trying to understand the use case and whether we should consider
> to land this upstream.
>
> Would you mind elaborating on how this is useful for you?

It is (currently) not useful for me, but it may be useful for others.
During work on a new SoC, someone had hardcoded "pd_ignore_unused"
in the kernel command line.  After adding support for PM Domains on
that SoC, I noticed PM Domains were still powered down.

The issue is that pd_ignore_unused no longer does what it claims to do:

        pd_ignore_unused
                        [PM]
                        Keep all power-domains already enabled by bootloader on,
                        even if no driver has claimed them. This is useful
                        for debug and development, but should not be
                        needed on a platform with proper driver support.

So IMO that should either be fixed, or the option should be removed.
Do you agree?
Thanks!

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
Re: [PATCH/RFC] pmdomain: core: Support pd_ignore_unused with sync_state
Posted by Ulf Hansson 16 hours ago
On Wed, 4 Mar 2026 at 12:06, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
>
> Hi Ulf,
>
> On Wed, 4 Mar 2026 at 11:56, Ulf Hansson <ulf.hansson@linaro.org> wrote:
> > On Mon, 16 Feb 2026 at 19:47, Geert Uytterhoeven
> > <geert+renesas@glider.be> wrote:
> > > Since the introduction of the sync_state mechanism, the
> > > "pd_ignore_unused" kernel command line option doesn't really work
> > > anymore.  While genpd_power_off_unused() still checks for that flag
> > > before powering down unused domains, the new sync_state callbacks lack
> > > such checks, thus powering down unused domains regardless.
> > >
> > > Fix this by adding checks to the sync_state helpers and callbacks.
> > > Factor out the printing of the warning message, to make sure it is
> > > printed only once.
> > >
> > > Fixes: 002ebddd695a5399 ("pmdomain: core: Restore behaviour for disabling unused PM domains")
> > > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> > > ---
> > > RFC as I have no need for this in upstream.
> >
> > I am trying to understand the use case and whether we should consider
> > to land this upstream.
> >
> > Would you mind elaborating on how this is useful for you?
>
> It is (currently) not useful for me, but it may be useful for others.
> During work on a new SoC, someone had hardcoded "pd_ignore_unused"
> in the kernel command line.  After adding support for PM Domains on
> that SoC, I noticed PM Domains were still powered down.
>
> The issue is that pd_ignore_unused no longer does what it claims to do:
>
>         pd_ignore_unused
>                         [PM]
>                         Keep all power-domains already enabled by bootloader on,
>                         even if no driver has claimed them. This is useful
>                         for debug and development, but should not be
>                         needed on a platform with proper driver support.
>

Well, this is exactly what the sync_state mechanism intends to
address, but in a more correct way compared to pd_ignore_unused.

If a consumer device that belongs to a power domain, lacks a driver
(or it never probes) then that power domain will not be powered-off by
genpd (if it was on a boot). For the pd_ignore_unused case, we may end
up powering off the genpd anyway, becuase child-domains being
powered-off, for example.

For incomplete drivers, the assumption is that the device attaches to
its genpd but runtime PM remains disabled for the device. In these
cases, genpd will not power-off the corresponding power domain.

> So IMO that should either be fixed, or the option should be removed.
> Do you agree?

Right, I think it's time to consider removing it, unless people still
find it useful ofcourse.

Do you want to send a patch that we can test/review or you prefer me
to handle it?

Kind regards
Uffe
Re: [PATCH/RFC] pmdomain: core: Support pd_ignore_unused with sync_state
Posted by Geert Uytterhoeven 16 hours ago
Hi Ulf,

On Wed, 4 Mar 2026 at 12:52, Ulf Hansson <ulf.hansson@linaro.org> wrote:
> On Wed, 4 Mar 2026 at 12:06, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> > On Wed, 4 Mar 2026 at 11:56, Ulf Hansson <ulf.hansson@linaro.org> wrote:
> > > On Mon, 16 Feb 2026 at 19:47, Geert Uytterhoeven
> > > <geert+renesas@glider.be> wrote:
> > > > Since the introduction of the sync_state mechanism, the
> > > > "pd_ignore_unused" kernel command line option doesn't really work
> > > > anymore.  While genpd_power_off_unused() still checks for that flag
> > > > before powering down unused domains, the new sync_state callbacks lack
> > > > such checks, thus powering down unused domains regardless.
> > > >
> > > > Fix this by adding checks to the sync_state helpers and callbacks.
> > > > Factor out the printing of the warning message, to make sure it is
> > > > printed only once.
> > > >
> > > > Fixes: 002ebddd695a5399 ("pmdomain: core: Restore behaviour for disabling unused PM domains")
> > > > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> > > > ---
> > > > RFC as I have no need for this in upstream.
> > >
> > > I am trying to understand the use case and whether we should consider
> > > to land this upstream.
> > >
> > > Would you mind elaborating on how this is useful for you?
> >
> > It is (currently) not useful for me, but it may be useful for others.
> > During work on a new SoC, someone had hardcoded "pd_ignore_unused"
> > in the kernel command line.  After adding support for PM Domains on
> > that SoC, I noticed PM Domains were still powered down.
> >
> > The issue is that pd_ignore_unused no longer does what it claims to do:
> >
> >         pd_ignore_unused
> >                         [PM]
> >                         Keep all power-domains already enabled by bootloader on,
> >                         even if no driver has claimed them. This is useful
> >                         for debug and development, but should not be
> >                         needed on a platform with proper driver support.
> >

[...]

> > So IMO that should either be fixed, or the option should be removed.
> > Do you agree?
>
> Right, I think it's time to consider removing it, unless people still
> find it useful ofcourse.
>
> Do you want to send a patch that we can test/review or you prefer me
> to handle it?

Feel free to handle it.
Thanks!

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds