From: Elaine Zhang Date: Thu, 12 Jan 2017 08:12:31 +0000 (+0800) Subject: PM / Domains: Keep the pd status during system PM phases X-Git-Tag: firefly_0821_release~644 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=0b02304feeb1a85ca9c45a50206dab05994f2c57;p=firefly-linux-kernel-4.4.55.git PM / Domains: Keep the pd status during system PM phases 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 --- diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index e6c2a1284019..331ecf0b5fbf 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -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; /* diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index d53aa8ae342f..ba4ced38efae 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -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);