Lines Matching +full:suspend +full:- +full:to +full:- +full:idle

1 // SPDX-License-Identifier: GPL-2.0-only
3 * kernel/power/suspend.c - Suspend to RAM and standby functionality.
26 #include <linux/suspend.h>
65 * pm_suspend_default_s2idle - Check if suspend-to-idle is the default suspend.
67 * Return 'true' if suspend-to-idle has been selected as the default system
68 * suspend method.
103 /* Push all the CPUs into the idle loop. */ in s2idle_enter()
105 /* Make the current CPU wait so it can enter the idle loop too. */ in s2idle_enter()
110 * Kick all CPUs to ensure that they resume their timers and restore in s2idle_enter()
128 pm_pr_dbg("suspend-to-idle\n"); in s2idle_loop()
131 * Suspend-to-idle equals: in s2idle_loop()
132 * frozen processes + suspended devices + idle processors. in s2idle_loop()
136 * Wakeups during the noirq suspend of devices may be spurious, so try in s2idle_loop()
137 * to avoid them upfront. in s2idle_loop()
140 if (s2idle_ops && s2idle_ops->wake) { in s2idle_loop()
141 if (s2idle_ops->wake()) in s2idle_loop()
147 if (s2idle_ops && s2idle_ops->check) in s2idle_loop()
148 s2idle_ops->check(); in s2idle_loop()
153 pm_pr_dbg("resume from suspend-to-idle\n"); in s2idle_loop()
172 * The PM_SUSPEND_STANDBY and PM_SUSPEND_MEM states require low-level in valid_state()
173 * support and need to be valid to the low-level implementation. in valid_state()
175 * No ->valid() or ->enter() callback implies that none are valid. in valid_state()
177 return suspend_ops && suspend_ops->valid && suspend_ops->valid(state) && in valid_state()
178 suspend_ops->enter; in valid_state()
187 * Suspend-to-idle should be supported even without any suspend_ops, in pm_states_init()
210 * suspend_set_ops - Set the global suspend method table.
211 * @ops: Suspend operations to use.
238 * suspend_valid_only_mem - Generic memory-only valid callback.
241 * Platform drivers that implement mem suspend only and only need to check for
259 return state != PM_SUSPEND_TO_IDLE && suspend_ops->prepare ? in platform_suspend_prepare()
260 suspend_ops->prepare() : 0; in platform_suspend_prepare()
265 return state == PM_SUSPEND_TO_IDLE && s2idle_ops && s2idle_ops->prepare ? in platform_suspend_prepare_late()
266 s2idle_ops->prepare() : 0; in platform_suspend_prepare_late()
272 return s2idle_ops && s2idle_ops->prepare_late ? in platform_suspend_prepare_noirq()
273 s2idle_ops->prepare_late() : 0; in platform_suspend_prepare_noirq()
275 return suspend_ops->prepare_late ? suspend_ops->prepare_late() : 0; in platform_suspend_prepare_noirq()
281 if (s2idle_ops && s2idle_ops->restore_early) in platform_resume_noirq()
282 s2idle_ops->restore_early(); in platform_resume_noirq()
283 } else if (suspend_ops->wake) { in platform_resume_noirq()
284 suspend_ops->wake(); in platform_resume_noirq()
290 if (state == PM_SUSPEND_TO_IDLE && s2idle_ops && s2idle_ops->restore) in platform_resume_early()
291 s2idle_ops->restore(); in platform_resume_early()
296 if (state != PM_SUSPEND_TO_IDLE && suspend_ops->finish) in platform_resume_finish()
297 suspend_ops->finish(); in platform_resume_finish()
302 if (state == PM_SUSPEND_TO_IDLE && s2idle_ops && s2idle_ops->begin) in platform_suspend_begin()
303 return s2idle_ops->begin(); in platform_suspend_begin()
304 else if (suspend_ops && suspend_ops->begin) in platform_suspend_begin()
305 return suspend_ops->begin(state); in platform_suspend_begin()
312 if (state == PM_SUSPEND_TO_IDLE && s2idle_ops && s2idle_ops->end) in platform_resume_end()
313 s2idle_ops->end(); in platform_resume_end()
314 else if (suspend_ops && suspend_ops->end) in platform_resume_end()
315 suspend_ops->end(); in platform_resume_end()
320 if (state != PM_SUSPEND_TO_IDLE && suspend_ops->recover) in platform_recover()
321 suspend_ops->recover(); in platform_recover()
326 return state != PM_SUSPEND_TO_IDLE && suspend_ops->suspend_again ? in platform_suspend_again()
327 suspend_ops->suspend_again() : false; in platform_suspend_again()
334 "Number of seconds to wait before resuming from suspend test");
341 pr_info("suspend debug: Waiting for %d second(s).\n", in suspend_test()
351 * suspend_prepare - Prepare for entering system sleep state.
355 * hibernation). Run suspend notifiers, allocate the "suspend" console and
363 return -EPERM; in suspend_prepare()
397 * suspend_enter - Make the system enter the given sleep state.
398 * @state: System sleep state to enter.
399 * @wakeup: Returns information that the sleep state should not be re-entered.
413 pr_err("late suspend of devices failed\n"); in suspend_enter()
422 pr_err("noirq suspend of devices failed\n"); in suspend_enter()
452 error = suspend_ops->enter(state); in suspend_enter()
456 error = -EBUSY; in suspend_enter()
485 * suspend_devices_and_enter - Suspend devices and enter system sleep state.
486 * @state: System sleep state to enter.
494 return -ENOSYS; in suspend_devices_and_enter()
509 pr_err("Some devices failed to suspend, or early wake event detected\n"); in suspend_devices_and_enter()
512 suspend_test_finish("suspend devices"); in suspend_devices_and_enter()
539 * suspend_finish - Clean up before finishing the suspend sequence.
541 * Call platform code to clean up, restart processes, and free the console that
552 * enter_state - Do common work needed to enter system sleep state.
553 * @state: System sleep state to enter.
555 * Make sure that no one else is trying to put the system into a sleep state.
556 * Fail if that's not the case. Otherwise, prepare for system suspend, make the
567 …pr_warn("Unsupported test mode for suspend to idle, please choose none/freezer/devices/platform.\n… in enter_state()
568 return -EAGAIN; in enter_state()
572 return -EINVAL; in enter_state()
575 return -EBUSY; in enter_state()
611 * pm_suspend - Externally visible function for suspending the system.
612 * @state: System sleep state to enter.
615 * execute enter_state() and update system suspend statistics.
622 return -EINVAL; in pm_suspend()
624 pr_info("suspend entry (%s)\n", mem_sleep_labels[state]); in pm_suspend()
627 pr_info("suspend exit\n"); in pm_suspend()