diff mbox series

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

Message ID 1551878926-8455-3-git-send-email-aisheng.dong@nxp.com (mailing list archive)
State Changes Requested, archived
Headers show
Series PM / Domains: Support enter deepest state during suspend and probe failure | expand

Commit Message

Aisheng Dong March 6, 2019, 1:35 p.m. UTC
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(+)

Comments

Ulf Hansson March 6, 2019, 3:10 p.m. UTC | #1
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
Aisheng Dong March 6, 2019, 3:46 p.m. UTC | #2
> 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
diff mbox series

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