aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/device_pm.c
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2014-07-22 19:00:53 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2014-07-22 19:00:53 -0400
commitf35cec255557d1037ff0d772edfd6e7b1e92cdc0 (patch)
tree2ee56c1eee38bee3aef538edeca8e97d45531100 /drivers/acpi/device_pm.c
parentc072530f391e33bd22ed0638c08f07528f154493 (diff)
ACPI / PM: Always enable wakeup GPEs when enabling device wakeup
Wakeup GPEs are currently only enabled when setting up devices for remote wakeup at run time. During system-wide transitions they are enabled by ACPICA at the very last stage of suspend (before asking the BIOS to take over). Of course, that only works for system sleep states supported by ACPI, so in particular it doesn't work for the "freeze" sleep state. For this reason, modify the ACPI core device PM code to enable wakeup GPEs for devices when setting them up for wakeup regardless of whether that is remote wakeup at runtime or system wakeup. That allows the same device wakeup setup routine to be used for both runtime PM and system-wide PM and makes it possible to reduce code size quite a bit. This make ACPI-based PCI Wake-on-LAN work with the "freeze" sleep state on my venerable Toshiba Portege R500 and should help other systems too. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/acpi/device_pm.c')
-rw-r--r--drivers/acpi/device_pm.c49
1 files changed, 17 insertions, 32 deletions
diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c
index 366de0b0c39b..ad2810900799 100644
--- a/drivers/acpi/device_pm.c
+++ b/drivers/acpi/device_pm.c
@@ -638,7 +638,6 @@ int acpi_pm_device_sleep_state(struct device *dev, int *d_min_p, int d_max_in)
638} 638}
639EXPORT_SYMBOL(acpi_pm_device_sleep_state); 639EXPORT_SYMBOL(acpi_pm_device_sleep_state);
640 640
641#ifdef CONFIG_PM_RUNTIME
642/** 641/**
643 * acpi_pm_notify_work_func - ACPI devices wakeup notification work function. 642 * acpi_pm_notify_work_func - ACPI devices wakeup notification work function.
644 * @work: Work item to handle. 643 * @work: Work item to handle.
@@ -655,8 +654,9 @@ static void acpi_pm_notify_work_func(struct work_struct *work)
655} 654}
656 655
657/** 656/**
658 * __acpi_device_run_wake - Enable/disable runtime remote wakeup for device. 657 * acpi_device_wakeup - Enable/disable wakeup functionality for device.
659 * @adev: ACPI device to enable/disable the remote wakeup for. 658 * @adev: ACPI device to enable/disable wakeup functionality for.
659 * @target_state: State the system is transitioning into.
660 * @enable: Whether to enable or disable the wakeup functionality. 660 * @enable: Whether to enable or disable the wakeup functionality.
661 * 661 *
662 * Enable/disable the GPE associated with @adev so that it can generate 662 * Enable/disable the GPE associated with @adev so that it can generate
@@ -666,7 +666,8 @@ static void acpi_pm_notify_work_func(struct work_struct *work)
666 * Callers must ensure that @adev is a valid ACPI device node before executing 666 * Callers must ensure that @adev is a valid ACPI device node before executing
667 * this function. 667 * this function.
668 */ 668 */
669int __acpi_device_run_wake(struct acpi_device *adev, bool enable) 669static int acpi_device_wakeup(struct acpi_device *adev, u32 target_state,
670 bool enable)
670{ 671{
671 struct acpi_device_wakeup *wakeup = &adev->wakeup; 672 struct acpi_device_wakeup *wakeup = &adev->wakeup;
672 673
@@ -674,7 +675,7 @@ int __acpi_device_run_wake(struct acpi_device *adev, bool enable)
674 acpi_status res; 675 acpi_status res;
675 int error; 676 int error;
676 677
677 error = acpi_enable_wakeup_device_power(adev, ACPI_STATE_S0); 678 error = acpi_enable_wakeup_device_power(adev, target_state);
678 if (error) 679 if (error)
679 return error; 680 return error;
680 681
@@ -690,6 +691,7 @@ int __acpi_device_run_wake(struct acpi_device *adev, bool enable)
690 return 0; 691 return 0;
691} 692}
692 693
694#ifdef CONFIG_PM_RUNTIME
693/** 695/**
694 * acpi_pm_device_run_wake - Enable/disable remote wakeup for given device. 696 * acpi_pm_device_run_wake - Enable/disable remote wakeup for given device.
695 * @dev: Device to enable/disable the platform to wake up. 697 * @dev: Device to enable/disable the platform to wake up.
@@ -710,29 +712,13 @@ int acpi_pm_device_run_wake(struct device *phys_dev, bool enable)
710 return -ENODEV; 712 return -ENODEV;
711 } 713 }
712 714
713 return __acpi_device_run_wake(adev, enable); 715 return acpi_device_wakeup(adev, enable, ACPI_STATE_S0);
714} 716}
715EXPORT_SYMBOL(acpi_pm_device_run_wake); 717EXPORT_SYMBOL(acpi_pm_device_run_wake);
716#else
717static inline void acpi_pm_notify_work_func(struct work_struct *work) {}
718#endif /* CONFIG_PM_RUNTIME */ 718#endif /* CONFIG_PM_RUNTIME */
719 719
720#ifdef CONFIG_PM_SLEEP 720#ifdef CONFIG_PM_SLEEP
721/** 721/**
722 * __acpi_device_sleep_wake - Enable or disable device to wake up the system.
723 * @dev: Device to enable/desible to wake up the system.
724 * @target_state: System state the device is supposed to wake up from.
725 * @enable: Whether to enable or disable @dev to wake up the system.
726 */
727int __acpi_device_sleep_wake(struct acpi_device *adev, u32 target_state,
728 bool enable)
729{
730 return enable ?
731 acpi_enable_wakeup_device_power(adev, target_state) :
732 acpi_disable_wakeup_device_power(adev);
733}
734
735/**
736 * acpi_pm_device_sleep_wake - Enable or disable device to wake up the system. 722 * acpi_pm_device_sleep_wake - Enable or disable device to wake up the system.
737 * @dev: Device to enable/desible to wake up the system from sleep states. 723 * @dev: Device to enable/desible to wake up the system from sleep states.
738 * @enable: Whether to enable or disable @dev to wake up the system. 724 * @enable: Whether to enable or disable @dev to wake up the system.
@@ -752,8 +738,7 @@ int acpi_pm_device_sleep_wake(struct device *dev, bool enable)
752 return -ENODEV; 738 return -ENODEV;
753 } 739 }
754 740
755 error = __acpi_device_sleep_wake(adev, acpi_target_system_state(), 741 error = acpi_device_wakeup(adev, acpi_target_system_state(), enable);
756 enable);
757 if (!error) 742 if (!error)
758 dev_info(dev, "System wakeup %s by ACPI\n", 743 dev_info(dev, "System wakeup %s by ACPI\n",
759 enable ? "enabled" : "disabled"); 744 enable ? "enabled" : "disabled");
@@ -811,13 +796,13 @@ int acpi_dev_runtime_suspend(struct device *dev)
811 796
812 remote_wakeup = dev_pm_qos_flags(dev, PM_QOS_FLAG_REMOTE_WAKEUP) > 797 remote_wakeup = dev_pm_qos_flags(dev, PM_QOS_FLAG_REMOTE_WAKEUP) >
813 PM_QOS_FLAGS_NONE; 798 PM_QOS_FLAGS_NONE;
814 error = __acpi_device_run_wake(adev, remote_wakeup); 799 error = acpi_device_wakeup(adev, ACPI_STATE_S0, remote_wakeup);
815 if (remote_wakeup && error) 800 if (remote_wakeup && error)
816 return -EAGAIN; 801 return -EAGAIN;
817 802
818 error = acpi_dev_pm_low_power(dev, adev, ACPI_STATE_S0); 803 error = acpi_dev_pm_low_power(dev, adev, ACPI_STATE_S0);
819 if (error) 804 if (error)
820 __acpi_device_run_wake(adev, false); 805 acpi_device_wakeup(adev, ACPI_STATE_S0, false);
821 806
822 return error; 807 return error;
823} 808}
@@ -840,7 +825,7 @@ int acpi_dev_runtime_resume(struct device *dev)
840 return 0; 825 return 0;
841 826
842 error = acpi_dev_pm_full_power(adev); 827 error = acpi_dev_pm_full_power(adev);
843 __acpi_device_run_wake(adev, false); 828 acpi_device_wakeup(adev, ACPI_STATE_S0, false);
844 return error; 829 return error;
845} 830}
846EXPORT_SYMBOL_GPL(acpi_dev_runtime_resume); 831EXPORT_SYMBOL_GPL(acpi_dev_runtime_resume);
@@ -896,13 +881,13 @@ int acpi_dev_suspend_late(struct device *dev)
896 881
897 target_state = acpi_target_system_state(); 882 target_state = acpi_target_system_state();
898 wakeup = device_may_wakeup(dev); 883 wakeup = device_may_wakeup(dev);
899 error = __acpi_device_sleep_wake(adev, target_state, wakeup); 884 error = acpi_device_wakeup(adev, target_state, wakeup);
900 if (wakeup && error) 885 if (wakeup && error)
901 return error; 886 return error;
902 887
903 error = acpi_dev_pm_low_power(dev, adev, target_state); 888 error = acpi_dev_pm_low_power(dev, adev, target_state);
904 if (error) 889 if (error)
905 __acpi_device_sleep_wake(adev, ACPI_STATE_UNKNOWN, false); 890 acpi_device_wakeup(adev, ACPI_STATE_UNKNOWN, false);
906 891
907 return error; 892 return error;
908} 893}
@@ -925,7 +910,7 @@ int acpi_dev_resume_early(struct device *dev)
925 return 0; 910 return 0;
926 911
927 error = acpi_dev_pm_full_power(adev); 912 error = acpi_dev_pm_full_power(adev);
928 __acpi_device_sleep_wake(adev, ACPI_STATE_UNKNOWN, false); 913 acpi_device_wakeup(adev, ACPI_STATE_UNKNOWN, false);
929 return error; 914 return error;
930} 915}
931EXPORT_SYMBOL_GPL(acpi_dev_resume_early); 916EXPORT_SYMBOL_GPL(acpi_dev_resume_early);
@@ -1088,7 +1073,7 @@ int acpi_dev_pm_attach(struct device *dev, bool power_on)
1088 dev->pm_domain = &acpi_general_pm_domain; 1073 dev->pm_domain = &acpi_general_pm_domain;
1089 if (power_on) { 1074 if (power_on) {
1090 acpi_dev_pm_full_power(adev); 1075 acpi_dev_pm_full_power(adev);
1091 __acpi_device_run_wake(adev, false); 1076 acpi_device_wakeup(adev, ACPI_STATE_S0, false);
1092 } 1077 }
1093 return 0; 1078 return 0;
1094} 1079}
@@ -1122,7 +1107,7 @@ void acpi_dev_pm_detach(struct device *dev, bool power_off)
1122 */ 1107 */
1123 dev_pm_qos_hide_latency_limit(dev); 1108 dev_pm_qos_hide_latency_limit(dev);
1124 dev_pm_qos_hide_flags(dev); 1109 dev_pm_qos_hide_flags(dev);
1125 __acpi_device_run_wake(adev, false); 1110 acpi_device_wakeup(adev, ACPI_STATE_S0, false);
1126 acpi_dev_pm_low_power(dev, adev, ACPI_STATE_S0); 1111 acpi_dev_pm_low_power(dev, adev, ACPI_STATE_S0);
1127 } 1112 }
1128 } 1113 }