Patchwork [2/2] PM / Domains: Choose the deepest state to enter if no devices using it

login
register
mail settings
Submitter Dong Aisheng
Date March 6, 2019, 1:35 p.m.
Message ID <1551878926-8455-3-git-send-email-aisheng.dong@nxp.com>
Download mbox | patch
Permalink /patch/742537/
State New
Headers show

Comments

Dong Aisheng - March 6, 2019, 1:35 p.m.
For a domain has no working devices anymore, let's choose the deepest state
to enter to save power. e.g. driver probe failure.

Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
---
 drivers/base/power/domain.c | 4 ++++
 1 file changed, 4 insertions(+)
Ulf Hansson - March 6, 2019, 3:10 p.m.
On Wed, 6 Mar 2019 at 14:35, Aisheng Dong <aisheng.dong@nxp.com> wrote:
>
> For a domain has no working devices anymore, let's choose the deepest state
> to enter to save power. e.g. driver probe failure.
>
> Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
> ---
>  drivers/base/power/domain.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
> index 847a69e..d3f57c2 100644
> --- a/drivers/base/power/domain.c
> +++ b/drivers/base/power/domain.c
> @@ -550,6 +550,10 @@ static int genpd_power_off(struct generic_pm_domain *genpd, bool one_dev_on,
>         if (!genpd->gov)
>                 genpd->state_idx = 0;
>
> +       /* Choose the deepest state if no devices using this domain */
> +       if (!genpd->device_count)
> +               genpd->state_idx = genpd->state_count - 1;
> +

This doesn't work, sorry.

For example, there may be a sub-domain with devices in it and which
have constraints applicable also for the master (current) domain.

>         /*
>          * If sd_count > 0 at this point, one of the subdomains hasn't
>          * managed to call genpd_power_on() for the master yet after
> --
> 2.7.4
>

Kind regards
Uffe
Dong Aisheng - March 6, 2019, 3:46 p.m.
> From: Ulf Hansson [mailto:ulf.hansson@linaro.org]

> Sent: Wednesday, March 6, 2019 11:11 PM

> On Wed, 6 Mar 2019 at 14:35, Aisheng Dong <aisheng.dong@nxp.com>

> wrote:

> >

> > For a domain has no working devices anymore, let's choose the deepest

> > state to enter to save power. e.g. driver probe failure.

> >

> > Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>

> > ---

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

> >  1 file changed, 4 insertions(+)

> >

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

> > index 847a69e..d3f57c2 100644

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

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

> > @@ -550,6 +550,10 @@ static int genpd_power_off(struct

> generic_pm_domain *genpd, bool one_dev_on,

> >         if (!genpd->gov)

> >                 genpd->state_idx = 0;

> >

> > +       /* Choose the deepest state if no devices using this domain */

> > +       if (!genpd->device_count)

> > +               genpd->state_idx = genpd->state_count - 1;

> > +

> 

> This doesn't work, sorry.

> 

> For example, there may be a sub-domain with devices in it and which have

> constraints applicable also for the master (current) domain.


Okay, got your point.
Then how about make it for no governor case only?

Regards
Dong Aisheng

> 

> >         /*

> >          * If sd_count > 0 at this point, one of the subdomains hasn't

> >          * managed to call genpd_power_on() for the master yet after

> > --

> > 2.7.4

> >

> 

> Kind regards

> Uffe

Patch

diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
index 847a69e..d3f57c2 100644
--- a/drivers/base/power/domain.c
+++ b/drivers/base/power/domain.c
@@ -550,6 +550,10 @@  static int genpd_power_off(struct generic_pm_domain *genpd, bool one_dev_on,
 	if (!genpd->gov)
 		genpd->state_idx = 0;
 
+	/* Choose the deepest state if no devices using this domain */
+	if (!genpd->device_count)
+		genpd->state_idx = genpd->state_count - 1;
+
 	/*
 	 * If sd_count > 0 at this point, one of the subdomains hasn't
 	 * managed to call genpd_power_on() for the master yet after