linux/kernel/power/suspend.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * kernel/power/suspend.c - Suspend to RAM and standby functionality.
 *
 * Copyright (c) 2003 Patrick Mochel
 * Copyright (c) 2003 Open Source Development Lab
 * Copyright (c) 2009 Rafael J. Wysocki <[email protected]>, Novell Inc.
 */

#define pr_fmt(fmt)

#include <linux/string.h>
#include <linux/delay.h>
#include <linux/errno.h>
#include <linux/init.h>
#include <linux/console.h>
#include <linux/cpu.h>
#include <linux/cpuidle.h>
#include <linux/gfp.h>
#include <linux/io.h>
#include <linux/kernel.h>
#include <linux/list.h>
#include <linux/mm.h>
#include <linux/slab.h>
#include <linux/export.h>
#include <linux/suspend.h>
#include <linux/syscore_ops.h>
#include <linux/swait.h>
#include <linux/ftrace.h>
#include <trace/events/power.h>
#include <linux/compiler.h>
#include <linux/moduleparam.h>

#include "power.h"

const char * const pm_labels[] =;
const char *pm_states[PM_SUSPEND_MAX];
static const char * const mem_sleep_labels[] =;
const char *mem_sleep_states[PM_SUSPEND_MAX];

suspend_state_t mem_sleep_current =;
suspend_state_t mem_sleep_default =;
suspend_state_t pm_suspend_target_state;
EXPORT_SYMBOL_GPL();

unsigned int pm_suspend_global_flags;
EXPORT_SYMBOL_GPL();

static const struct platform_suspend_ops *suspend_ops;
static const struct platform_s2idle_ops *s2idle_ops;
static DECLARE_SWAIT_QUEUE_HEAD(s2idle_wait_head);

enum s2idle_states __read_mostly s2idle_state;
static DEFINE_RAW_SPINLOCK(s2idle_lock);

/**
 * pm_suspend_default_s2idle - Check if suspend-to-idle is the default suspend.
 *
 * Return 'true' if suspend-to-idle has been selected as the default system
 * suspend method.
 */
bool pm_suspend_default_s2idle(void)
{}
EXPORT_SYMBOL_GPL();

void s2idle_set_ops(const struct platform_s2idle_ops *ops)
{}

static void s2idle_begin(void)
{}

static void s2idle_enter(void)
{}

static void s2idle_loop(void)
{}

void s2idle_wake(void)
{}
EXPORT_SYMBOL_GPL();

static bool valid_state(suspend_state_t state)
{}

void __init pm_states_init(void)
{}

static int __init mem_sleep_default_setup(char *str)
{}
__setup();

/**
 * suspend_set_ops - Set the global suspend method table.
 * @ops: Suspend operations to use.
 */
void suspend_set_ops(const struct platform_suspend_ops *ops)
{}
EXPORT_SYMBOL_GPL();

/**
 * suspend_valid_only_mem - Generic memory-only valid callback.
 * @state: Target system sleep state.
 *
 * Platform drivers that implement mem suspend only and only need to check for
 * that in their .valid() callback can use this instead of rolling their own
 * .valid() callback.
 */
int suspend_valid_only_mem(suspend_state_t state)
{}
EXPORT_SYMBOL_GPL();

static bool sleep_state_supported(suspend_state_t state)
{}

static int platform_suspend_prepare(suspend_state_t state)
{}

static int platform_suspend_prepare_late(suspend_state_t state)
{}

static int platform_suspend_prepare_noirq(suspend_state_t state)
{}

static void platform_resume_noirq(suspend_state_t state)
{}

static void platform_resume_early(suspend_state_t state)
{}

static void platform_resume_finish(suspend_state_t state)
{}

static int platform_suspend_begin(suspend_state_t state)
{}

static void platform_resume_end(suspend_state_t state)
{}

static void platform_recover(suspend_state_t state)
{}

static bool platform_suspend_again(suspend_state_t state)
{}

#ifdef CONFIG_PM_DEBUG
static unsigned int pm_test_delay =;
module_param(pm_test_delay, uint, 0644);
MODULE_PARM_DESC();
#endif

static int suspend_test(int level)
{}

/**
 * suspend_prepare - Prepare for entering system sleep state.
 * @state: Target system sleep state.
 *
 * Common code run for every system sleep state that can be entered (except for
 * hibernation).  Run suspend notifiers, allocate the "suspend" console and
 * freeze processes.
 */
static int suspend_prepare(suspend_state_t state)
{}

/* default implementation */
void __weak arch_suspend_disable_irqs(void)
{}

/* default implementation */
void __weak arch_suspend_enable_irqs(void)
{}

/**
 * suspend_enter - Make the system enter the given sleep state.
 * @state: System sleep state to enter.
 * @wakeup: Returns information that the sleep state should not be re-entered.
 *
 * This function should be called after devices have been suspended.
 */
static int suspend_enter(suspend_state_t state, bool *wakeup)
{}

/**
 * suspend_devices_and_enter - Suspend devices and enter system sleep state.
 * @state: System sleep state to enter.
 */
int suspend_devices_and_enter(suspend_state_t state)
{}

/**
 * suspend_finish - Clean up before finishing the suspend sequence.
 *
 * Call platform code to clean up, restart processes, and free the console that
 * we've allocated. This routine is not called for hibernation.
 */
static void suspend_finish(void)
{}

/**
 * enter_state - Do common work needed to enter system sleep state.
 * @state: System sleep state to enter.
 *
 * Make sure that no one else is trying to put the system into a sleep state.
 * Fail if that's not the case.  Otherwise, prepare for system suspend, make the
 * system enter the given sleep state and clean up after wakeup.
 */
static int enter_state(suspend_state_t state)
{}

/**
 * pm_suspend - Externally visible function for suspending the system.
 * @state: System sleep state to enter.
 *
 * Check if the value of @state represents one of the supported states,
 * execute enter_state() and update system suspend statistics.
 */
int pm_suspend(suspend_state_t state)
{}
EXPORT_SYMBOL();