diff mbox

[v1] PM / Domains: Keep the pd status during system PM phases

Message ID 1484794273-30103-1-git-send-email-zhangqing@rock-chips.com (mailing list archive)
State New, archived
Headers show

Commit Message

Elaine Zhang Jan. 19, 2017, 2:51 a.m. UTC
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.

This modify is to slove system resume issue for RK3399.
RK3399 SOC pd_gpu have voltage domain vdd_gpu,
so we must follow open vdd_gpu and power on pd_gpu,
power off pd_gpu and disable vdd_gpu.
Fix up in runtime resume noirq phase power on all PDs.

Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com>
---
 drivers/base/power/domain.c | 10 +++++++---
 include/linux/pm_domain.h   |  1 +
 2 files changed, 8 insertions(+), 3 deletions(-)

Comments

kernel test robot Jan. 20, 2017, 2:11 a.m. UTC | #1
Hi Elaine,

[auto build test WARNING on pm/linux-next]
[also build test WARNING on v4.10-rc4 next-20170119]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Elaine-Zhang/PM-Domains-Keep-the-pd-status-during-system-PM-phases/20170120-091738
base:   https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next
config: x86_64-randconfig-x017-201703 (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All warnings (new ones prefixed by >>):

   drivers/base/power/domain.c: In function 'pm_genpd_suspend_noirq':
>> drivers/base/power/domain.c:885:29: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
         dev->power.wakeup_path && genpd_dev_active_wakeup(genpd, dev))
         ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/base/power/domain.c: In function 'pm_genpd_resume_noirq':
   drivers/base/power/domain.c:923:29: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
         dev->power.wakeup_path && genpd_dev_active_wakeup(genpd, dev))
         ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

vim +885 drivers/base/power/domain.c

   869	 *
   870	 * Stop the device and remove power from the domain if all devices in it have
   871	 * been stopped.
   872	 */
   873	static int pm_genpd_suspend_noirq(struct device *dev)
   874	{
   875		struct generic_pm_domain *genpd;
   876		int ret;
   877	
   878		dev_dbg(dev, "%s()\n", __func__);
   879	
   880		genpd = dev_to_genpd(dev);
   881		if (IS_ERR(genpd))
   882			return -EINVAL;
   883	
   884		if (genpd->suspend_power_off ||
 > 885		    dev->power.wakeup_path && genpd_dev_active_wakeup(genpd, dev))
   886			return 0;
   887	
   888		if (genpd->dev_ops.stop && genpd->dev_ops.start) {
   889			ret = pm_runtime_force_suspend(dev);
   890			if (ret)
   891				return ret;
   892		}
   893	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
kernel test robot Jan. 20, 2017, 2:15 a.m. UTC | #2
Hi Elaine,

[auto build test WARNING on pm/linux-next]
[also build test WARNING on v4.10-rc4 next-20170119]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Elaine-Zhang/PM-Domains-Keep-the-pd-status-during-system-PM-phases/20170120-091738
base:   https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next
config: x86_64-randconfig-x016-201703 (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All warnings (new ones prefixed by >>):

   In file included from include/linux/linkage.h:4:0,
                    from include/linux/kernel.h:6,
                    from include/linux/delay.h:10,
                    from drivers/base/power/domain.c:9:
   drivers/base/power/domain.c: In function 'pm_genpd_suspend_noirq':
   drivers/base/power/domain.c:885:29: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
         dev->power.wakeup_path && genpd_dev_active_wakeup(genpd, dev))
         ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/compiler.h:149:30: note: in definition of macro '__trace_if'
     if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
                                 ^~~~
>> drivers/base/power/domain.c:884:2: note: in expansion of macro 'if'
     if (genpd->suspend_power_off ||
     ^~
   drivers/base/power/domain.c:885:29: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
         dev->power.wakeup_path && genpd_dev_active_wakeup(genpd, dev))
         ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/compiler.h:149:42: note: in definition of macro '__trace_if'
     if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
                                             ^~~~
>> drivers/base/power/domain.c:884:2: note: in expansion of macro 'if'
     if (genpd->suspend_power_off ||
     ^~
   drivers/base/power/domain.c:885:29: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
         dev->power.wakeup_path && genpd_dev_active_wakeup(genpd, dev))
         ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/compiler.h:160:16: note: in definition of macro '__trace_if'
      ______r = !!(cond);     \
                   ^~~~
>> drivers/base/power/domain.c:884:2: note: in expansion of macro 'if'
     if (genpd->suspend_power_off ||
     ^~
   drivers/base/power/domain.c: In function 'pm_genpd_resume_noirq':
   drivers/base/power/domain.c:923:29: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
         dev->power.wakeup_path && genpd_dev_active_wakeup(genpd, dev))
         ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/compiler.h:149:30: note: in definition of macro '__trace_if'
     if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
                                 ^~~~
   drivers/base/power/domain.c:922:2: note: in expansion of macro 'if'
     if (genpd->suspend_power_off ||
     ^~
   drivers/base/power/domain.c:923:29: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
         dev->power.wakeup_path && genpd_dev_active_wakeup(genpd, dev))
         ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/compiler.h:149:42: note: in definition of macro '__trace_if'
     if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
                                             ^~~~
   drivers/base/power/domain.c:922:2: note: in expansion of macro 'if'
     if (genpd->suspend_power_off ||
     ^~
   drivers/base/power/domain.c:923:29: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
         dev->power.wakeup_path && genpd_dev_active_wakeup(genpd, dev))
         ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/compiler.h:160:16: note: in definition of macro '__trace_if'
      ______r = !!(cond);     \
                   ^~~~
   drivers/base/power/domain.c:922:2: note: in expansion of macro 'if'
     if (genpd->suspend_power_off ||
     ^~

vim +/if +884 drivers/base/power/domain.c

   868	 * @dev: Device to suspend.
   869	 *
   870	 * Stop the device and remove power from the domain if all devices in it have
   871	 * been stopped.
   872	 */
   873	static int pm_genpd_suspend_noirq(struct device *dev)
   874	{
   875		struct generic_pm_domain *genpd;
   876		int ret;
   877	
   878		dev_dbg(dev, "%s()\n", __func__);
   879	
   880		genpd = dev_to_genpd(dev);
   881		if (IS_ERR(genpd))
   882			return -EINVAL;
   883	
 > 884		if (genpd->suspend_power_off ||
   885		    dev->power.wakeup_path && genpd_dev_active_wakeup(genpd, dev))
   886			return 0;
   887	
   888		if (genpd->dev_ops.stop && genpd->dev_ops.start) {
   889			ret = pm_runtime_force_suspend(dev);
   890			if (ret)
   891				return ret;
   892		}

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
diff mbox

Patch

diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
index 5711708532db..d1ee63e9ee23 100644
--- a/drivers/base/power/domain.c
+++ b/drivers/base/power/domain.c
@@ -842,8 +842,10 @@  static int pm_genpd_prepare(struct device *dev)
 
 	genpd_lock(genpd);
 
-	if (genpd->prepared_count++ == 0)
+	if (genpd->prepared_count++ == 0) {
 		genpd->suspended_count = 0;
+		genpd->suspend_power_off = genpd->status == GPD_STATE_POWER_OFF;
+	}
 
 	genpd_unlock(genpd);
 
@@ -877,7 +879,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;
 
 	if (genpd->dev_ops.stop && genpd->dev_ops.start) {
@@ -914,7 +917,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 81ece61075df..9c0dc364f089 100644
--- a/include/linux/pm_domain.h
+++ b/include/linux/pm_domain.h
@@ -62,6 +62,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);
 	int (*power_on)(struct generic_pm_domain *domain);
 	struct gpd_dev_ops dev_ops;