diff mbox

[4/6] PCI / PM: Simplify device wakeup settings code

Message ID 6082855.gb7lhtNroi@aspire.rjw.lan (mailing list archive)
State New, archived
Delegated to: Bjorn Helgaas
Headers show

Commit Message

Rafael J. Wysocki June 19, 2017, 9:35 p.m. UTC
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

After previous changes it is not necessary to distinguish between
device wakeup for run time and device wakeup from system sleep states
any more, so rework the PCI device wakeup settings code accordingly.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/pci/pci-acpi.c   |    3 +--
 drivers/pci/pci-driver.c |    2 +-
 drivers/pci/pci.c        |   36 ++++++++++--------------------------
 drivers/pci/pci.h        |    9 ++-------
 include/linux/pci.h      |    9 +--------
 5 files changed, 15 insertions(+), 44 deletions(-)

Comments

kernel test robot June 20, 2017, 2 p.m. UTC | #1
Hi Rafael,

[auto build test ERROR on pm/linux-next]
[also build test ERROR on next-20170620]
[cannot apply to v4.12-rc6]
[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/Rafael-J-Wysocki/PM-Unify-the-handling-of-device-wakeup-settings/20170620-195729
base:   https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next
config: x86_64-randconfig-s5-06202012 (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 errors (new ones prefixed by >>):

>> drivers//pci/pci-mid.c:62:2: error: unknown field 'sleep_wake' specified in initializer
     .sleep_wake = mid_pci_sleep_wake,
     ^
>> drivers//pci/pci-mid.c:63:2: error: unknown field 'run_wake' specified in initializer
     .run_wake = mid_pci_run_wake,
     ^
>> drivers//pci/pci-mid.c:63:14: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
     .run_wake = mid_pci_run_wake,
                 ^~~~~~~~~~~~~~~~
   drivers//pci/pci-mid.c:63:14: note: (near initialization for 'mid_pci_platform_pm.need_resume')
   cc1: some warnings being treated as errors

vim +/sleep_wake +62 drivers//pci/pci-mid.c

5823d0893 Andy Shevchenko 2016-06-14  56  
c93122548 Lukas Wunner    2016-12-12  57  static const struct pci_platform_pm_ops mid_pci_platform_pm = {
5823d0893 Andy Shevchenko 2016-06-14  58  	.is_manageable	= mid_pci_power_manageable,
5823d0893 Andy Shevchenko 2016-06-14  59  	.set_state	= mid_pci_set_power_state,
e8a6123e9 Lukas Wunner    2016-10-23  60  	.get_state	= mid_pci_get_power_state,
5823d0893 Andy Shevchenko 2016-06-14  61  	.choose_state	= mid_pci_choose_state,
5823d0893 Andy Shevchenko 2016-06-14 @62  	.sleep_wake	= mid_pci_sleep_wake,
5823d0893 Andy Shevchenko 2016-06-14 @63  	.run_wake	= mid_pci_run_wake,
5823d0893 Andy Shevchenko 2016-06-14  64  	.need_resume	= mid_pci_need_resume,
5823d0893 Andy Shevchenko 2016-06-14  65  };
5823d0893 Andy Shevchenko 2016-06-14  66  

:::::: The code at line 62 was first introduced by commit
:::::: 5823d0893ec284f37902e2ecd332dbb396a143d1 x86/platform/intel-mid: Add Power Management Unit driver

:::::: TO: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
:::::: CC: Ingo Molnar <mingo@kernel.org>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
kernel test robot June 20, 2017, 4:16 p.m. UTC | #2
Hi Rafael,

[auto build test WARNING on pm/linux-next]
[also build test WARNING on next-20170620]
[cannot apply to v4.12-rc6]
[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/Rafael-J-Wysocki/PM-Unify-the-handling-of-device-wakeup-settings/20170620-195729
base:   https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next
config: x86_64-randconfig-n0-06202146 (attached as .config)
compiler: gcc-4.8 (Debian 4.8.4-1) 4.8.4
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All warnings (new ones prefixed by >>):

   drivers/pci/pci-mid.c:62:2: error: unknown field 'sleep_wake' specified in initializer
     .sleep_wake = mid_pci_sleep_wake,
     ^
   drivers/pci/pci-mid.c:63:2: error: unknown field 'run_wake' specified in initializer
     .run_wake = mid_pci_run_wake,
     ^
>> drivers/pci/pci-mid.c:63:2: warning: initialization from incompatible pointer type [enabled by default]
   drivers/pci/pci-mid.c:63:2: warning: (near initialization for 'mid_pci_platform_pm.need_resume') [enabled by default]

vim +63 drivers/pci/pci-mid.c

5823d0893 Andy Shevchenko 2016-06-14  56  
c93122548 Lukas Wunner    2016-12-12  57  static const struct pci_platform_pm_ops mid_pci_platform_pm = {
5823d0893 Andy Shevchenko 2016-06-14  58  	.is_manageable	= mid_pci_power_manageable,
5823d0893 Andy Shevchenko 2016-06-14  59  	.set_state	= mid_pci_set_power_state,
e8a6123e9 Lukas Wunner    2016-10-23  60  	.get_state	= mid_pci_get_power_state,
5823d0893 Andy Shevchenko 2016-06-14  61  	.choose_state	= mid_pci_choose_state,
5823d0893 Andy Shevchenko 2016-06-14 @62  	.sleep_wake	= mid_pci_sleep_wake,
5823d0893 Andy Shevchenko 2016-06-14 @63  	.run_wake	= mid_pci_run_wake,
5823d0893 Andy Shevchenko 2016-06-14  64  	.need_resume	= mid_pci_need_resume,
5823d0893 Andy Shevchenko 2016-06-14  65  };
5823d0893 Andy Shevchenko 2016-06-14  66  

:::::: The code at line 63 was first introduced by commit
:::::: 5823d0893ec284f37902e2ecd332dbb396a143d1 x86/platform/intel-mid: Add Power Management Unit driver

:::::: TO: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
:::::: CC: Ingo Molnar <mingo@kernel.org>

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

Patch

Index: linux-pm/drivers/pci/pci-acpi.c
===================================================================
--- linux-pm.orig/drivers/pci/pci-acpi.c
+++ linux-pm/drivers/pci/pci-acpi.c
@@ -616,8 +616,7 @@  static const struct pci_platform_pm_ops
 	.set_state = acpi_pci_set_power_state,
 	.get_state = acpi_pci_get_power_state,
 	.choose_state = acpi_pci_choose_state,
-	.sleep_wake = acpi_pci_wakeup,
-	.run_wake = acpi_pci_wakeup,
+	.set_wakeup = acpi_pci_wakeup,
 	.need_resume = acpi_pci_need_resume,
 };
 
Index: linux-pm/drivers/pci/pci.c
===================================================================
--- linux-pm.orig/drivers/pci/pci.c
+++ linux-pm/drivers/pci/pci.c
@@ -574,8 +574,7 @@  static const struct pci_platform_pm_ops
 int pci_set_platform_pm(const struct pci_platform_pm_ops *ops)
 {
 	if (!ops->is_manageable || !ops->set_state  || !ops->get_state ||
-	    !ops->choose_state  || !ops->sleep_wake || !ops->run_wake  ||
-	    !ops->need_resume)
+	    !ops->choose_state  || !ops->set_wakeup || !ops->need_resume)
 		return -EINVAL;
 	pci_platform_pm = ops;
 	return 0;
@@ -603,16 +602,10 @@  static inline pci_power_t platform_pci_c
 			pci_platform_pm->choose_state(dev) : PCI_POWER_ERROR;
 }
 
-static inline int platform_pci_sleep_wake(struct pci_dev *dev, bool enable)
+static inline int platform_pci_set_wakeup(struct pci_dev *dev, bool enable)
 {
 	return pci_platform_pm ?
-			pci_platform_pm->sleep_wake(dev, enable) : -ENODEV;
-}
-
-static inline int platform_pci_run_wake(struct pci_dev *dev, bool enable)
-{
-	return pci_platform_pm ?
-			pci_platform_pm->run_wake(dev, enable) : -ENODEV;
+			pci_platform_pm->set_wakeup(dev, enable) : -ENODEV;
 }
 
 static inline bool platform_pci_need_resume(struct pci_dev *dev)
@@ -1889,10 +1882,9 @@  void pci_pme_active(struct pci_dev *dev,
 EXPORT_SYMBOL(pci_pme_active);
 
 /**
- * __pci_enable_wake - enable PCI device as wakeup event source
+ * pci_enable_wake - enable PCI device as wakeup event source
  * @dev: PCI device affected
  * @state: PCI state from which device will issue wakeup events
- * @runtime: True if the events are to be generated at run time
  * @enable: True to enable event generation; false to disable
  *
  * This enables the device as a wakeup event source, or disables it.
@@ -1908,14 +1900,10 @@  EXPORT_SYMBOL(pci_pme_active);
  * Error code depending on the platform is returned if both the platform and
  * the native mechanism fail to enable the generation of wake-up events
  */
-int __pci_enable_wake(struct pci_dev *dev, pci_power_t state,
-		      bool runtime, bool enable)
+int pci_enable_wake(struct pci_dev *dev, pci_power_t state, bool enable)
 {
 	int ret = 0;
 
-	if (enable && !runtime && !device_may_wakeup(&dev->dev))
-		return -EINVAL;
-
 	/*
 	 * Don't do the same thing twice in a row for one device, but restore
 	 * PME Enable in case it has been updated by config space restoration.
@@ -1938,24 +1926,20 @@  int __pci_enable_wake(struct pci_dev *de
 			pci_pme_active(dev, true);
 		else
 			ret = 1;
-		error = runtime ? platform_pci_run_wake(dev, true) :
-					platform_pci_sleep_wake(dev, true);
+		error = platform_pci_set_wakeup(dev, true);
 		if (ret)
 			ret = error;
 		if (!ret)
 			dev->wakeup_prepared = true;
 	} else {
-		if (runtime)
-			platform_pci_run_wake(dev, false);
-		else
-			platform_pci_sleep_wake(dev, false);
+		platform_pci_set_wakeup(dev, false);
 		pci_pme_active(dev, false);
 		dev->wakeup_prepared = false;
 	}
 
 	return ret;
 }
-EXPORT_SYMBOL(__pci_enable_wake);
+EXPORT_SYMBOL(pci_enable_wake);
 
 /**
  * pci_wake_from_d3 - enable/disable device to wake up from D3_hot or D3_cold
@@ -2097,12 +2081,12 @@  int pci_finish_runtime_suspend(struct pc
 
 	dev->runtime_d3cold = target_state == PCI_D3cold;
 
-	__pci_enable_wake(dev, target_state, true, pci_dev_run_wake(dev));
+	pci_enable_wake(dev, target_state, pci_dev_run_wake(dev));
 
 	error = pci_set_power_state(dev, target_state);
 
 	if (error) {
-		__pci_enable_wake(dev, target_state, true, false);
+		pci_enable_wake(dev, target_state, false);
 		dev->runtime_d3cold = false;
 	}
 
Index: linux-pm/include/linux/pci.h
===================================================================
--- linux-pm.orig/include/linux/pci.h
+++ linux-pm/include/linux/pci.h
@@ -1097,8 +1097,7 @@  int pci_set_power_state(struct pci_dev *
 pci_power_t pci_choose_state(struct pci_dev *dev, pm_message_t state);
 bool pci_pme_capable(struct pci_dev *dev, pci_power_t state);
 void pci_pme_active(struct pci_dev *dev, bool enable);
-int __pci_enable_wake(struct pci_dev *dev, pci_power_t state,
-		      bool runtime, bool enable);
+int pci_enable_wake(struct pci_dev *dev, pci_power_t state, bool enable);
 int pci_wake_from_d3(struct pci_dev *dev, bool enable);
 int pci_prepare_to_sleep(struct pci_dev *dev);
 int pci_back_from_sleep(struct pci_dev *dev);
@@ -1108,12 +1107,6 @@  void pci_pme_wakeup_bus(struct pci_bus *
 void pci_d3cold_enable(struct pci_dev *dev);
 void pci_d3cold_disable(struct pci_dev *dev);
 
-static inline int pci_enable_wake(struct pci_dev *dev, pci_power_t state,
-				  bool enable)
-{
-	return __pci_enable_wake(dev, state, false, enable);
-}
-
 /* PCI Virtual Channel */
 int pci_save_vc_state(struct pci_dev *dev);
 void pci_restore_vc_state(struct pci_dev *dev);
Index: linux-pm/drivers/pci/pci.h
===================================================================
--- linux-pm.orig/drivers/pci/pci.h
+++ linux-pm/drivers/pci/pci.h
@@ -47,11 +47,7 @@  int pci_probe_reset_function(struct pci_
  *                platform; to be used during system-wide transitions from a
  *                sleeping state to the working state and vice versa
  *
- * @sleep_wake: enables/disables the system wake up capability of given device
- *
- * @run_wake: enables/disables the platform to generate run-time wake-up events
- *		for given device (the device's wake-up capability has to be
- *		enabled by @sleep_wake for this feature to work)
+ * @set_wakeup: enables/disables wakeup capability for the device
  *
  * @need_resume: returns 'true' if the given device (which is currently
  *		suspended) needs to be resumed to be configured for system
@@ -65,8 +61,7 @@  struct pci_platform_pm_ops {
 	int (*set_state)(struct pci_dev *dev, pci_power_t state);
 	pci_power_t (*get_state)(struct pci_dev *dev);
 	pci_power_t (*choose_state)(struct pci_dev *dev);
-	int (*sleep_wake)(struct pci_dev *dev, bool enable);
-	int (*run_wake)(struct pci_dev *dev, bool enable);
+	int (*set_wakeup)(struct pci_dev *dev, bool enable);
 	bool (*need_resume)(struct pci_dev *dev);
 };
 
Index: linux-pm/drivers/pci/pci-driver.c
===================================================================
--- linux-pm.orig/drivers/pci/pci-driver.c
+++ linux-pm/drivers/pci/pci-driver.c
@@ -1216,7 +1216,7 @@  static int pci_pm_runtime_resume(struct
 
 	pci_restore_standard_config(pci_dev);
 	pci_fixup_device(pci_fixup_resume_early, pci_dev);
-	__pci_enable_wake(pci_dev, PCI_D0, true, false);
+	pci_enable_wake(pci_dev, PCI_D0, false);
 	pci_fixup_device(pci_fixup_resume, pci_dev);
 
 	rc = pm->runtime_resume(dev);