PM / Domains: Keep the pd status during system PM phases
authorElaine Zhang <zhangqing@rock-chips.com>
Thu, 12 Jan 2017 08:12:31 +0000 (16:12 +0800)
committerHuang, Tao <huangtao@rock-chips.com>
Wed, 15 Feb 2017 08:53:36 +0000 (16:53 +0800)
If a PM domain is powered off before system suspend,
we hope do nothing in system runtime suspend noirq phase
and system runtime resume noirq phase.

Change-Id: Id72b1f92e10449c48006aced0d49612637402210
Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com>
drivers/base/power/domain.c
include/linux/pm_domain.h

index e6c2a128401914a56ccd67a16b26f3c638f84890..331ecf0b5fbf663dd8d1ce3592930e5e1638108c 100644 (file)
@@ -692,8 +692,10 @@ static int pm_genpd_prepare(struct device *dev)
 
        mutex_lock(&genpd->lock);
 
-       if (genpd->prepared_count++ == 0)
+       if (genpd->prepared_count++ == 0) {
                genpd->suspended_count = 0;
+               genpd->suspend_power_off = genpd->status == GPD_STATE_POWER_OFF;
+       }
 
        mutex_unlock(&genpd->lock);
 
@@ -726,7 +728,8 @@ static int pm_genpd_suspend_noirq(struct device *dev)
        if (IS_ERR(genpd))
                return -EINVAL;
 
-       if (dev->power.wakeup_path && genpd_dev_active_wakeup(genpd, dev))
+       if (genpd->suspend_power_off ||
+           (dev->power.wakeup_path && genpd_dev_active_wakeup(genpd, dev)))
                return 0;
 
        /*
@@ -756,7 +759,8 @@ static int pm_genpd_resume_noirq(struct device *dev)
        if (IS_ERR(genpd))
                return -EINVAL;
 
-       if (dev->power.wakeup_path && genpd_dev_active_wakeup(genpd, dev))
+       if (genpd->suspend_power_off ||
+           (dev->power.wakeup_path && genpd_dev_active_wakeup(genpd, dev)))
                return 0;
 
        /*
index d53aa8ae342f84960649d095ab1cd6650ef5c1b6..ba4ced38efae0c9249a97ea57c0cccd1ac37e7f7 100644 (file)
@@ -52,6 +52,7 @@ struct generic_pm_domain {
        unsigned int device_count;      /* Number of devices */
        unsigned int suspended_count;   /* System suspend device counter */
        unsigned int prepared_count;    /* Suspend counter of prepared devices */
+       bool suspend_power_off; /* Power status before system suspend */
        int (*power_off)(struct generic_pm_domain *domain);
        s64 power_off_latency_ns;
        int (*power_on)(struct generic_pm_domain *domain);