drivers/acpi/sleep.c
Source file repositories/reference/linux-study-clean/drivers/acpi/sleep.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/acpi/sleep.c- Extension
.c- Size
- 28975 bytes
- Lines
- 1153
- Domain
- Driver Families
- Bucket
- drivers/acpi
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/delay.hlinux/irq.hlinux/dmi.hlinux/device.hlinux/interrupt.hlinux/suspend.hlinux/reboot.hlinux/acpi.hlinux/module.hlinux/syscore_ops.hasm/io.htrace/events/power.hinternal.hsleep.h
Detected Declarations
function acpi_sleep_tts_switchfunction tts_notify_rebootfunction acpi_sleep_preparefunction acpi_sleep_state_supportedfunction acpi_target_system_statefunction acpi_nvs_nosavefunction acpi_nvs_nosave_s3function init_nvs_save_s3function acpi_old_suspend_orderingfunction init_old_suspend_orderingfunction init_nvs_nosavefunction init_default_s3function acpi_sleep_no_blacklistfunction acpi_sleep_dmi_checkfunction acpi_pm_freezefunction acpi_pm_pre_suspendfunction __acpi_pm_preparefunction acpi_pm_preparefunction upfunction acpi_pm_startfunction acpi_pm_endfunction acpi_sleep_dmi_checkfunction acpi_suspend_beginfunction acpi_suspend_enterfunction acpi_suspend_state_validfunction acpi_suspend_begin_oldfunction acpi_s2idle_beginfunction acpi_s2idle_preparefunction acpi_s2idle_wakefunction acpi_s2idle_restorefunction acpi_s2idle_endfunction acpi_s2idle_setupfunction acpi_sleep_suspend_setupfunction acpi_sleep_suspend_setupfunction acpi_save_bm_rldfunction acpi_restore_bm_rldfunction acpi_sleep_syscore_initfunction acpi_sleep_syscore_initfunction acpi_hibernation_beginfunction acpi_hibernation_enterfunction acpi_hibernation_leavefunction acpi_pm_thawfunction acpi_hibernation_begin_oldfunction acpi_sleep_hibernate_setupfunction acpi_sleep_hibernate_setupfunction acpi_power_offfunction acpi_sleep_initexport acpi_target_system_state
Annotated Snippet
static inline void acpi_sleep_dmi_check(void) {}
#endif /* CONFIG_ACPI_SLEEP */
#ifdef CONFIG_SUSPEND
static u32 acpi_suspend_states[] = {
[PM_SUSPEND_ON] = ACPI_STATE_S0,
[PM_SUSPEND_STANDBY] = ACPI_STATE_S1,
[PM_SUSPEND_MEM] = ACPI_STATE_S3,
[PM_SUSPEND_MAX] = ACPI_STATE_S5
};
/**
* acpi_suspend_begin - Set the target system sleep state to the state
* associated with given @pm_state, if supported.
* @pm_state: The target system power management state.
*/
static int acpi_suspend_begin(suspend_state_t pm_state)
{
u32 acpi_state = acpi_suspend_states[pm_state];
int error;
error = (nvs_nosave || nvs_nosave_s3) ? 0 : suspend_nvs_alloc();
if (error)
return error;
if (!sleep_states[acpi_state]) {
pr_err("ACPI does not support sleep state S%u\n", acpi_state);
return -ENOSYS;
}
if (acpi_state > ACPI_STATE_S1)
pm_set_suspend_via_firmware();
acpi_pm_start(acpi_state);
return 0;
}
/**
* acpi_suspend_enter - Actually enter a sleep state.
* @pm_state: ignored
*
* Flush caches and go to sleep. For STR we have to call arch-specific
* assembly, which in turn call acpi_enter_sleep_state().
* It's unfortunate, but it works. Please fix if you're feeling frisky.
*/
static int acpi_suspend_enter(suspend_state_t pm_state)
{
acpi_status status = AE_OK;
u32 acpi_state = acpi_target_sleep_state;
int error;
trace_suspend_resume(TPS("acpi_suspend"), acpi_state, true);
switch (acpi_state) {
case ACPI_STATE_S1:
barrier();
status = acpi_enter_sleep_state(acpi_state);
break;
case ACPI_STATE_S3:
if (!acpi_suspend_lowlevel)
return -ENOSYS;
error = acpi_suspend_lowlevel();
if (error)
return error;
pr_info("Low-level resume complete\n");
pm_set_resume_via_firmware();
break;
}
trace_suspend_resume(TPS("acpi_suspend"), acpi_state, false);
/* This violates the spec but is required for bug compatibility. */
acpi_write_bit_register(ACPI_BITREG_SCI_ENABLE, 1);
/* Reprogram control registers */
acpi_leave_sleep_state_prep(acpi_state);
/* ACPI 3.0 specs (P62) says that it's the responsibility
* of the OSPM to clear the status bit [ implying that the
* POWER_BUTTON event should not reach userspace ]
*
* However, we do generate a small hint for userspace in the form of
* a wakeup event. We flag this condition for now and generate the
* event later, as we're currently too early in resume to be able to
* generate wakeup events.
*/
if (ACPI_SUCCESS(status) && (acpi_state == ACPI_STATE_S3)) {
acpi_event_status pwr_btn_status = ACPI_EVENT_FLAG_DISABLED;
acpi_get_event_status(ACPI_EVENT_POWER_BUTTON, &pwr_btn_status);
if (pwr_btn_status & ACPI_EVENT_FLAG_STATUS_SET) {
Annotation
- Immediate include surface: `linux/delay.h`, `linux/irq.h`, `linux/dmi.h`, `linux/device.h`, `linux/interrupt.h`, `linux/suspend.h`, `linux/reboot.h`, `linux/acpi.h`.
- Detected declarations: `function acpi_sleep_tts_switch`, `function tts_notify_reboot`, `function acpi_sleep_prepare`, `function acpi_sleep_state_supported`, `function acpi_target_system_state`, `function acpi_nvs_nosave`, `function acpi_nvs_nosave_s3`, `function init_nvs_save_s3`, `function acpi_old_suspend_ordering`, `function init_old_suspend_ordering`.
- Atlas domain: Driver Families / drivers/acpi.
- Implementation status: integration implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.