drivers/base/power/main.c
Source file repositories/reference/linux-study-clean/drivers/base/power/main.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/base/power/main.c- Extension
.c- Size
- 61986 bytes
- Lines
- 2428
- Domain
- Driver Families
- Bucket
- drivers/base
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/device.hlinux/export.hlinux/mutex.hlinux/pm.hlinux/pm_runtime.hlinux/pm-trace.hlinux/pm_wakeirq.hlinux/interrupt.hlinux/sched.hlinux/sched/debug.hlinux/sysctl.hlinux/async.hlinux/suspend.htrace/events/power.hlinux/cpufreq.hlinux/devfreq.hlinux/thermal.hlinux/timer.hlinux/nmi.h../base.hpower.h
Detected Declarations
struct dpm_watchdogfunction pm_hibernate_is_recoveringfunction device_pm_sleep_initfunction device_pm_lockfunction device_pm_unlockfunction device_pm_addfunction device_pm_removefunction device_pm_move_beforefunction device_pm_move_afterfunction device_pm_move_lastfunction initcall_debug_startfunction initcall_debug_reportfunction dpm_waitfunction dpm_wait_fnfunction dpm_wait_for_childrenfunction dpm_wait_for_suppliersfunction dpm_wait_for_superiorfunction dpm_wait_for_consumersfunction dpm_wait_for_subordinatefunction pm_opfunction pm_late_early_opfunction pm_noirq_opfunction pm_dev_dbgfunction pm_dev_errfunction dpm_show_timefunction dpm_run_callbackfunction proc_dodpm_watchdog_timeout_secsfunction dpm_watchdog_sysctl_initfunction dpm_watchdog_handlerfunction dpm_watchdog_setfunction dpm_watchdog_clearfunction dev_pm_skip_resumefunction is_asyncfunction __dpm_asyncfunction dpm_async_fnfunction dpm_async_with_cleanupfunction dpm_async_resume_childrenfunction dpm_async_resume_subordinatefunction dpm_clear_async_statefunction dpm_root_devicefunction device_resume_noirqfunction async_resume_noirqfunction dpm_noirq_resume_devicesfunction dpm_resume_noirqfunction device_resume_earlyfunction async_resume_earlyfunction dpm_resume_earlyfunction dpm_resume_start
Annotated Snippet
subsys_initcall(dpm_watchdog_sysctl_init);
/**
* dpm_watchdog_handler - Driver suspend / resume watchdog handler.
* @t: The timer that PM watchdog depends on.
*
* Called when a driver has timed out suspending or resuming.
* There's not much we can do here to recover so panic() to
* capture a crash-dump in pstore.
*/
static void dpm_watchdog_handler(struct timer_list *t)
{
struct dpm_watchdog *wd = timer_container_of(wd, t, timer);
struct timer_list *timer = &wd->timer;
unsigned int time_left;
if (wd->fatal) {
unsigned int this_cpu = smp_processor_id();
dev_emerg(wd->dev, "**** DPM device timeout ****\n");
show_stack(wd->tsk, NULL, KERN_EMERG);
if (dpm_watchdog_all_cpu_backtrace)
trigger_allbutcpu_cpu_backtrace(this_cpu);
panic("%s %s: unrecoverable failure\n",
dev_driver_string(wd->dev), dev_name(wd->dev));
}
time_left = dpm_watchdog_timeout - dpm_watchdog_warning_timeout;
dev_warn(wd->dev, "**** DPM device timeout after %u seconds; %u seconds until panic ****\n",
dpm_watchdog_warning_timeout, time_left);
show_stack(wd->tsk, NULL, KERN_WARNING);
wd->fatal = true;
mod_timer(timer, jiffies + HZ * time_left);
}
/**
* dpm_watchdog_set - Enable pm watchdog for given device.
* @wd: Watchdog. Must be allocated on the stack.
* @dev: Device to handle.
*/
static void dpm_watchdog_set(struct dpm_watchdog *wd, struct device *dev)
{
struct timer_list *timer = &wd->timer;
wd->dev = dev;
wd->tsk = current;
wd->fatal = dpm_watchdog_timeout == dpm_watchdog_warning_timeout;
timer_setup_on_stack(timer, dpm_watchdog_handler, 0);
/* use same timeout value for both suspend and resume */
timer->expires = jiffies + HZ * dpm_watchdog_warning_timeout;
add_timer(timer);
}
/**
* dpm_watchdog_clear - Disable suspend/resume watchdog.
* @wd: Watchdog to disable.
*/
static void dpm_watchdog_clear(struct dpm_watchdog *wd)
{
struct timer_list *timer = &wd->timer;
timer_delete_sync(timer);
timer_destroy_on_stack(timer);
}
#else
#define DECLARE_DPM_WATCHDOG_ON_STACK(wd)
#define dpm_watchdog_set(x, y)
#define dpm_watchdog_clear(x)
#endif
/*------------------------- Resume routines -------------------------*/
/**
* dev_pm_skip_resume - System-wide device resume optimization check.
* @dev: Target device.
*
* Return:
* - %false if the transition under way is RESTORE.
* - Return value of dev_pm_skip_suspend() if the transition under way is THAW.
* - The logical negation of %power.must_resume otherwise (that is, when the
* transition under way is RESUME).
*/
bool dev_pm_skip_resume(struct device *dev)
{
if (pm_transition.event == PM_EVENT_RESTORE)
return false;
if (pm_transition.event == PM_EVENT_THAW)
Annotation
- Immediate include surface: `linux/device.h`, `linux/export.h`, `linux/mutex.h`, `linux/pm.h`, `linux/pm_runtime.h`, `linux/pm-trace.h`, `linux/pm_wakeirq.h`, `linux/interrupt.h`.
- Detected declarations: `struct dpm_watchdog`, `function pm_hibernate_is_recovering`, `function device_pm_sleep_init`, `function device_pm_lock`, `function device_pm_unlock`, `function device_pm_add`, `function device_pm_remove`, `function device_pm_move_before`, `function device_pm_move_after`, `function device_pm_move_last`.
- Atlas domain: Driver Families / drivers/base.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.