MLK-17074-2 PM / Domains: choose the deepest state to enter if no devices using it
authorDong Aisheng <aisheng.dong@nxp.com>
Mon, 27 Nov 2017 09:33:47 +0000 (17:33 +0800)
committerNitin Garg <nitin.garg@nxp.com>
Tue, 20 Mar 2018 19:49:54 +0000 (14:49 -0500)
For a domain belongs to no devices anymore, let's choose the deepest state
to enter to save power.

Reviewed-by: Frank Li <frank.li@nxp.com>
Reviewed-by: Ranjani Vaidyanathan <Ranjani.Vaidyanathan@nxp.com>
Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
drivers/base/power/domain.c

index 6915ce8..4b885e5 100644 (file)
@@ -327,6 +327,10 @@ static int genpd_poweroff(struct generic_pm_domain *genpd, bool is_async)
                if (atomic_read(&genpd->sd_count) > 0)
                        return -EBUSY;
 
+               if (!genpd->device_count)
+                       /* Choose the deepest state if no devices using this domain */
+                       genpd->state_idx = genpd->state_count - 1;
+
                /*
                 * If sd_count > 0 at this point, one of the subdomains hasn't
                 * managed to call genpd_poweron() for the master yet after