diff options
author | Sudeep Holla <Sudeep.Holla@arm.com> | 2016-02-17 07:03:23 -0500 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2016-02-21 18:53:56 -0500 |
commit | 504997cf96fabf67b4768b7a8ca1a1b622abd839 (patch) | |
tree | b28e6c830f8ff61044f6b0974847e5461ae08c91 | |
parent | db62fda318a6b9082ee9d230be8b45e56b6545c0 (diff) |
ACPI / sleep: move acpi_processor_sleep to sleep.c
acpi_processor_sleep is neither related nor used by CPUIdle framework.
It's used in system suspend/resume path as a syscore operation. It makes
more sense to move it to acpi/sleep.c where all the S-state transition
(a.k.a. Linux system suspend/hiberate) related code are present.
Also make it depend on CONFIG_ACPI_SYSTEM_POWER_STATES_SUPPORT so that
it's not compiled on architecture like ARM64 where S-states are not
yet defined in ACPI.
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r-- | drivers/acpi/processor_driver.c | 2 | ||||
-rw-r--r-- | drivers/acpi/processor_idle.c | 37 | ||||
-rw-r--r-- | drivers/acpi/sleep.c | 35 | ||||
-rw-r--r-- | include/acpi/processor.h | 8 |
4 files changed, 35 insertions, 47 deletions
diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c index 11154a330f07..d2fa8cb82d2b 100644 --- a/drivers/acpi/processor_driver.c +++ b/drivers/acpi/processor_driver.c | |||
@@ -314,7 +314,6 @@ static int __init acpi_processor_driver_init(void) | |||
314 | if (result < 0) | 314 | if (result < 0) |
315 | return result; | 315 | return result; |
316 | 316 | ||
317 | acpi_processor_syscore_init(); | ||
318 | register_hotcpu_notifier(&acpi_cpu_notifier); | 317 | register_hotcpu_notifier(&acpi_cpu_notifier); |
319 | acpi_thermal_cpufreq_init(); | 318 | acpi_thermal_cpufreq_init(); |
320 | acpi_processor_ppc_init(); | 319 | acpi_processor_ppc_init(); |
@@ -330,7 +329,6 @@ static void __exit acpi_processor_driver_exit(void) | |||
330 | acpi_processor_ppc_exit(); | 329 | acpi_processor_ppc_exit(); |
331 | acpi_thermal_cpufreq_exit(); | 330 | acpi_thermal_cpufreq_exit(); |
332 | unregister_hotcpu_notifier(&acpi_cpu_notifier); | 331 | unregister_hotcpu_notifier(&acpi_cpu_notifier); |
333 | acpi_processor_syscore_exit(); | ||
334 | driver_unregister(&acpi_processor_driver); | 332 | driver_unregister(&acpi_processor_driver); |
335 | } | 333 | } |
336 | 334 | ||
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c index e057aa8fafb0..fadce354d2b7 100644 --- a/drivers/acpi/processor_idle.c +++ b/drivers/acpi/processor_idle.c | |||
@@ -31,7 +31,6 @@ | |||
31 | #include <linux/sched.h> /* need_resched() */ | 31 | #include <linux/sched.h> /* need_resched() */ |
32 | #include <linux/tick.h> | 32 | #include <linux/tick.h> |
33 | #include <linux/cpuidle.h> | 33 | #include <linux/cpuidle.h> |
34 | #include <linux/syscore_ops.h> | ||
35 | #include <acpi/processor.h> | 34 | #include <acpi/processor.h> |
36 | 35 | ||
37 | /* | 36 | /* |
@@ -193,42 +192,6 @@ static void lapic_timer_state_broadcast(struct acpi_processor *pr, | |||
193 | 192 | ||
194 | #endif | 193 | #endif |
195 | 194 | ||
196 | #ifdef CONFIG_PM_SLEEP | ||
197 | static u32 saved_bm_rld; | ||
198 | |||
199 | static int acpi_processor_suspend(void) | ||
200 | { | ||
201 | acpi_read_bit_register(ACPI_BITREG_BUS_MASTER_RLD, &saved_bm_rld); | ||
202 | return 0; | ||
203 | } | ||
204 | |||
205 | static void acpi_processor_resume(void) | ||
206 | { | ||
207 | u32 resumed_bm_rld = 0; | ||
208 | |||
209 | acpi_read_bit_register(ACPI_BITREG_BUS_MASTER_RLD, &resumed_bm_rld); | ||
210 | if (resumed_bm_rld == saved_bm_rld) | ||
211 | return; | ||
212 | |||
213 | acpi_write_bit_register(ACPI_BITREG_BUS_MASTER_RLD, saved_bm_rld); | ||
214 | } | ||
215 | |||
216 | static struct syscore_ops acpi_processor_syscore_ops = { | ||
217 | .suspend = acpi_processor_suspend, | ||
218 | .resume = acpi_processor_resume, | ||
219 | }; | ||
220 | |||
221 | void acpi_processor_syscore_init(void) | ||
222 | { | ||
223 | register_syscore_ops(&acpi_processor_syscore_ops); | ||
224 | } | ||
225 | |||
226 | void acpi_processor_syscore_exit(void) | ||
227 | { | ||
228 | unregister_syscore_ops(&acpi_processor_syscore_ops); | ||
229 | } | ||
230 | #endif /* CONFIG_PM_SLEEP */ | ||
231 | |||
232 | #if defined(CONFIG_X86) | 195 | #if defined(CONFIG_X86) |
233 | static void tsc_check_state(int state) | 196 | static void tsc_check_state(int state) |
234 | { | 197 | { |
diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c index 9cb975200cac..fbfcce3b5227 100644 --- a/drivers/acpi/sleep.c +++ b/drivers/acpi/sleep.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/reboot.h> | 19 | #include <linux/reboot.h> |
20 | #include <linux/acpi.h> | 20 | #include <linux/acpi.h> |
21 | #include <linux/module.h> | 21 | #include <linux/module.h> |
22 | #include <linux/syscore_ops.h> | ||
22 | #include <asm/io.h> | 23 | #include <asm/io.h> |
23 | #include <trace/events/power.h> | 24 | #include <trace/events/power.h> |
24 | 25 | ||
@@ -677,6 +678,39 @@ static void acpi_sleep_suspend_setup(void) | |||
677 | static inline void acpi_sleep_suspend_setup(void) {} | 678 | static inline void acpi_sleep_suspend_setup(void) {} |
678 | #endif /* !CONFIG_SUSPEND */ | 679 | #endif /* !CONFIG_SUSPEND */ |
679 | 680 | ||
681 | #ifdef CONFIG_PM_SLEEP | ||
682 | static u32 saved_bm_rld; | ||
683 | |||
684 | static int acpi_save_bm_rld(void) | ||
685 | { | ||
686 | acpi_read_bit_register(ACPI_BITREG_BUS_MASTER_RLD, &saved_bm_rld); | ||
687 | return 0; | ||
688 | } | ||
689 | |||
690 | static void acpi_restore_bm_rld(void) | ||
691 | { | ||
692 | u32 resumed_bm_rld = 0; | ||
693 | |||
694 | acpi_read_bit_register(ACPI_BITREG_BUS_MASTER_RLD, &resumed_bm_rld); | ||
695 | if (resumed_bm_rld == saved_bm_rld) | ||
696 | return; | ||
697 | |||
698 | acpi_write_bit_register(ACPI_BITREG_BUS_MASTER_RLD, saved_bm_rld); | ||
699 | } | ||
700 | |||
701 | static struct syscore_ops acpi_sleep_syscore_ops = { | ||
702 | .suspend = acpi_save_bm_rld, | ||
703 | .resume = acpi_restore_bm_rld, | ||
704 | }; | ||
705 | |||
706 | void acpi_sleep_syscore_init(void) | ||
707 | { | ||
708 | register_syscore_ops(&acpi_sleep_syscore_ops); | ||
709 | } | ||
710 | #else | ||
711 | static inline void acpi_sleep_syscore_init(void) {} | ||
712 | #endif /* CONFIG_PM_SLEEP */ | ||
713 | |||
680 | #ifdef CONFIG_HIBERNATION | 714 | #ifdef CONFIG_HIBERNATION |
681 | static unsigned long s4_hardware_signature; | 715 | static unsigned long s4_hardware_signature; |
682 | static struct acpi_table_facs *facs; | 716 | static struct acpi_table_facs *facs; |
@@ -839,6 +873,7 @@ int __init acpi_sleep_init(void) | |||
839 | 873 | ||
840 | sleep_states[ACPI_STATE_S0] = 1; | 874 | sleep_states[ACPI_STATE_S0] = 1; |
841 | 875 | ||
876 | acpi_sleep_syscore_init(); | ||
842 | acpi_sleep_suspend_setup(); | 877 | acpi_sleep_suspend_setup(); |
843 | acpi_sleep_hibernate_setup(); | 878 | acpi_sleep_hibernate_setup(); |
844 | 879 | ||
diff --git a/include/acpi/processor.h b/include/acpi/processor.h index 54d7860cac11..6f1805dd5d3c 100644 --- a/include/acpi/processor.h +++ b/include/acpi/processor.h | |||
@@ -395,14 +395,6 @@ static inline int acpi_processor_hotplug(struct acpi_processor *pr) | |||
395 | } | 395 | } |
396 | #endif /* CONFIG_ACPI_PROCESSOR_IDLE */ | 396 | #endif /* CONFIG_ACPI_PROCESSOR_IDLE */ |
397 | 397 | ||
398 | #if defined(CONFIG_PM_SLEEP) & defined(CONFIG_ACPI_PROCESSOR_IDLE) | ||
399 | void acpi_processor_syscore_init(void); | ||
400 | void acpi_processor_syscore_exit(void); | ||
401 | #else | ||
402 | static inline void acpi_processor_syscore_init(void) {} | ||
403 | static inline void acpi_processor_syscore_exit(void) {} | ||
404 | #endif | ||
405 | |||
406 | /* in processor_thermal.c */ | 398 | /* in processor_thermal.c */ |
407 | int acpi_processor_get_limit_info(struct acpi_processor *pr); | 399 | int acpi_processor_get_limit_info(struct acpi_processor *pr); |
408 | extern const struct thermal_cooling_device_ops processor_cooling_ops; | 400 | extern const struct thermal_cooling_device_ops processor_cooling_ops; |