
// devices\base\power\main.c
/**
* dpm_suspend_start - Prepare devices for PM transition and suspend them.
* @state: PM transition of the system being carried out.
*
* Prepare all non-sysdev devices for system PM transition and execute "suspend"
* callbacks for them.
*/
int dpm_suspend_start(pm_message_t state)
{
ktime_t starttime = ktime_get();
int error;
error = dpm_prepare(state);
if (error) {
suspend_stats.failed_prepare++;
dpm_save_failed_step(SUSPEND_PREPARE);
} else
error = dpm_suspend(state);
dpm_show_time(starttime, state, error, "start");
return error;
}
EXPORT_SYMBOL_GPL(dpm_suspend_start);
然后调用dpm_suspend实现挂起流程,即流程图中的过程4。
// drivers\base\power\main.c
/**
* dpm_suspend - Execute "suspend" callbacks for all non-sysdev devices.
* @state: PM transition of the system being carried out.
*/
int dpm_suspend(pm_message_t state)
{
ktime_t starttime = ktime_get();
int error = 0;
trace_suspend_resume(TPS("dpm_suspend"), state.event, true);
might_sleep();
devfreq_suspend();
cpufreq_suspend();
mutex_lock(&dpm_list_mtx);
pm_transition = state;
async_error = 0;
while (!list_empty(&dpm_prepared_list)) {
struct device *dev = to_device(dpm_prepared_list.prev);
get_device(dev);
mutex_unlock(&dpm_list_mtx);
error = device_suspend(dev<

本文详细解析了Linux内核挂起流程中的dpm_suspend操作,包括复制状态到全局变量、遍历设备列表、执行设备挂起准备、处理失败情况以及设备链表转移等关键步骤。在设备挂起过程中,会根据dev->pm_domain->ops调用相应驱动的pm方法,若不存在则逐级向上查找type、class、bus的pm操作。
最低0.47元/天 解锁文章
2064

被折叠的 条评论
为什么被折叠?



