引用
- 【原创】Linux Suspend流程分析
- Linux 进程中 Stop, Park, Freeze
- Linux Signal
- Linux电源管理(6)_Generic PM之Suspend功能
- Linux电源管理(13)_Driver的电源管理
- Linux电源管理(11)_Runtime PM之功能描述
- 【原创】Linux PSCI框架
- Linux电源管理(13)_Driver的电源管理
- 系统休眠(System Suspend)和设备中断处理
- Linux电源管理(14)_从设备驱动的角度看电源管理
- 翻译:Linux的电源管理架构
一. Linux Power Management
二. Linux Generic PM
2.1 Suspend
https://elixir.bootlin.com/linux/latest/source/kernel/power/suspend.c#L605
2.2 Hibernate and Sleep
https://elixir.bootlin.com/linux/latest/source/kernel/power/main.c#L782
2.3 Wakeup events framework
2.3.1 wakeup events architecture
2.3.2 wakeup count
https://elixir.bootlin.com/linux/latest/source/drivers/base/power/wakeup.c#L971
2.3.3 wakelocks
https://elixir.bootlin.com/linux/latest/source/kernel/power/wakelock.c#L206
2.3.4 autosleep
https://elixir.bootlin.com/linux/latest/source/kernel/power/autosleep.c#L117
三. Runtime PM
https://elixir.bootlin.com/linux/latest/source/include/linux/pm_runtime.h#L417
device driver(或者driver所在的bus、class等)需要提供3个回调函数,runtime_suspend、runtime_resume和runtime_idle,分别用于suspend device、resume device和idle device。它们一般由RPM core在合适的时机调用,以便降低device的power consumption。
而调用的时机,最终是由device driver决定的。driver会在适当的操作点,调用RPM core提供的put和get系列的helper function,汇报device的当前状态。RPM core会为每个device维护一个引用计数,get时增加计数值,put时减少计数值,当计数为0时,表明device不再被使用,可以立即或一段时间后suspend,以节省功耗。
四. Linux PM files and Data structure
- kernel/power/ *
- drivers/power/
- drivers/base/power/*
- drivers/cpuidle/*
- drivers/cpufreq/*
- drivers/devfreq/*
- include/linux/power_supply.h
- include/linux/cpuidle.h
- include/linux/cpufreq.h
- include/linux/cpu_pm.h
- include/linux/device.h
- include/linux/pm.h
- include/linux/pm domain.h
- include/linux/pm runtime.h
- include/linux/pm wakeup.h
- include/linux/suspend.h
- Documentation/power/*.txt
https://elixir.bootlin.com/linux/latest/source/include/linux/pm.h#L278
/* struct dev_pm_ops - device PM callbacks. */
struct dev_pm_ops {
int (*prepare)(struct device *dev);
void (*complete)(struct device *dev);
int (*suspend)(struct device *dev);
int (*resume)(struct device *dev);
int (*freeze)(struct device *dev);
int (*thaw)(struct device *dev);
int (*poweroff)(struct device *dev);
int (*restore)(struct device *dev);
int (*suspend_late)(struct device *dev);
int (*resume_early)(struct device *dev);
int (*freeze_late)(struct device *dev);
int (*thaw_early)(struct device *dev);
int (*poweroff_late)(struct device *dev);
int (*restore_early)(struct device *dev);
int (*suspend_noirq)(struct device *dev);
int (*resume_noirq)(struct device *dev);
int (*freeze_noirq)(struct device *dev);
int (*thaw_noirq)(struct device *dev);
int (*poweroff_noirq)(struct device *dev);
int (*restore_noirq)(struct device *dev);
int (*runtime_suspend)(struct device *dev);
int (*runtime_resume)(struct device *dev);
int (*runtime_idle)(struct device *dev);
};
从Linux PM Core的角度来说,这些callbacks并不复杂,因为PM Core要做的就是在特定的电源管理阶段,调用相应的callbacks,例如在suspend/resume的过程中,PM Core会依次调用“prepare—>suspend—>suspend_late—>suspend_noirq <.........lowpower.......> wakeup--------->resume_noirq—>resume_early—>resume-->complete”。