本帖最后由 keer_zu 于 2020-3-19 15:08 编辑
通过下面程序:
/*************************** Main ***********************************/
int main(int argc, char **argv)
{
XX_Autosleep_Enable(1);
while (deamon_flag) {
sleep(1);
}
return 0;
}
在打开开发板上linux系统的auto sleep之后,将进程杀掉,这时候系统会进入休眠模式,可以看到下面打印信息:
221.312292] Freezing remaining freezable tasks ... (elapsed 0.003 seconds) done.
[ 221.322026] Suspending console(s) (use no_console_suspend to debug)
[ 221.356825] [gale] quectel_low_consume_suspend: OK ###############################
[ 221.362071] msm_serial_hs_suspend(): jun test
[ 221.362078] PM: suspend of devices complete after 32.311 msecs
[ 221.363456] PM: late suspend of devices complete after 1.340 msecs
[ 221.365111] PM: noirq suspend of devices complete after 1.614 msecs
[ 221.365161] suspend ns: 221365144824 suspend cycles: 9966203615
[ 221.365144] CPU0:msm_cpu_pm_enter_sleep mode:3 during suspend
[ 221.365144] resume cycles: 10196593398
[ 221.367060] PM: noirq resume of devices complete after 1.049 msecs
[ 221.368093] PM: early resume of devices complete after 0.644 msecs
[ 221.377232] Resume: sysfs_notify wakeup_in
[ 221.377525] [gale] quectel_low_consume_resume: ###############################
[ 221.378102] msm_otg 78d9000.usb: phy_reset: success
[ 221.436430] PM: resume of devices complete after 68.291 msecs
[ 221.499950] msm_otg 78d9000.usb: msm_otg_reset motg->inputs=1, motg->id_state=1
[ 221.500070] msm_otg 78d9000.usb: USB exited from low power mode
[ 221.530945] Restarting tasks ... done.
[ 221.553122] cpufreq: Frequency violation fixed for CPU0
[ 221.558334] PM: suspend exit 1980-01-06 03:25:28.091607828 UTC
[ 223.042426] PM: suspend entry 1980-01-06 03:25:29.575692202 UTC
[ 223.047464] msm_otg 78d9000.usb: USB in low power mode
[ 223.052538] PM: Syncing filesystems ... done.
[ 223.062319] Freezing user space processes ...
[ 223.073352] mbim_read: Waiting failed
[ 223.080123] (elapsed 0.013 seconds) done.
[ 223.083133] Freezing remaining freezable tasks ... (elapsed 0.003 seconds) done.
[ 223.092845] Suspending console(s) (use no_console_suspend to debug)
在bing下搜索:
Freezing remaining freezable tasks
可以找到linux下关于power manager的内容:
这里正好有待机流程的分析,先向别人学习一下,哈哈
1:待机节点创建
static int __init pm_init(void)
{
int error = pm_start_workqueue();
if (error)
return error;
hibernate_image_size_init();
hibernate_reserved_size_init();
power_kobj = kobject_create_and_add("power", NULL);
if (!power_kobj)
return -ENOMEM;
#ifdef CONFIG_X86_INTEL_XGOLD
power_hal_kobj = kobject_create_and_add("power_HAL_suspend",
power_kobj);
if (!power_hal_kobj)
return -ENOMEM;
#endif
error = sysfs_create_group(power_kobj, &attr_group);
if (error)
return error;
pm_print_times_init();
return pm_autosleep_init();
}
core_initcall(pm_init);
可以看到,内核创建了一个核心节点 ----- "power"节点。如何创建核心节点,参看:linux如何创建核心节点
power节点是在sysfs的ops下创建。它的位置就是 /sys/power
同时,在linux内核代码中找到这些内容的出处:
kernel-src/kernel/power/main.c
|