关键词:
1. Hibernate介绍
2. Linux下Hibernate配置及操作
在内核中使能Hibernation功能:
由于Hibernate镜像需要保存在swap文件中,所以在内核中使能swap功能:
由于在hibernate过程中backlight pwm和panel rgb阻碍suspend流程,在dts和defconfig中关闭:
CONFIG_PWM_STM32=n
CONFIG_PWM_STM32_LP=n
修改cmdline,增加hiernate相关内容:
resume=/dev/mmcblk2p3 hibernate=nocompress
创建并挂载swap分区:
mkswap /dev/mmcblk2p3
swapon /dev/mmcblk2p3
触发系统进入hibernate:
echo disk > /sys/power/state
对设备重启或者重新上电后,会进入hibernate的resume流程。
3. Linux Hibernate简单分析
hibernate suspend流程log:
[ 52.887333] PM: hibernation entry
[ 52.929313] Filesystems sync: 0.035 seconds
[ 52.932150] Freezing user space processes ... (elapsed 0.001 seconds) done.
[ 52.939024] OOM killer disabled.
[ 52.942457] PM: Preallocating image memory... done (allocated 16233 pages)
[ 53.248077] PM: Allocated 64932 kbytes in 0.30 seconds (216.44 MB/s)
[ 53.254523] Freezing remaining freezable tasks ... (elapsed 0.001 seconds) done.
[ 53.384540] PM: Creating hibernation image:
[ 53.384540] PM: Need to copy 16078 pages
[ 53.384540] PM: Hibernation image created (16078 pages copied)
[ 53.554738] mmc2: switch to bus width 8 failed
[ 53.560104] PM: Saving image data pages (16094 pages)...
[ 53.564545] PM: Image saving progress: 0%
[ 53.601408] PM: Image saving progress: 10%
[ 53.629244] PM: Image saving progress: 20%
[ 53.656327] PM: Image saving progress: 30%
[ 53.685321] PM: Image saving progress: 40%
[ 53.712630] PM: Image saving progress: 50%
[ 53.740625] PM: Image saving progress: 60%
[ 53.768257] PM: Image saving progress: 70%
[ 53.797453] PM: Image saving progress: 80%
[ 53.825003] PM: Image saving progress: 90%
[ 53.859307] PM: Image saving progress: 100%
[ 56.790787] PM: Image saving done
[ 56.792765] PM: Wrote 64376 kbytes in 3.22 seconds (19.99 MB/s)
[ 56.799714] PM: S|
[ 56.858127] reboot: Power down
INFO: arnoldlu psci_smc_handler smc_fid=0x84000008 [r1:r3]=0x00000000 0x00000000 0x00000000
INFO: arnoldlu psci_system_off
INFO: PSCI Power Domain Map:
INFO: Domain Node : Level 1, parent_node -1, State ON (0x0)
INFO: Domain Node : Level 0, parent_node 0, State ON (0x0)
INFO: CPU Node : MPID 0x0, parent_node 0, State ON (0x0)
INFO: CPU Node : MPID 0xffffffff, parent_node 0, State OFF (0x2)
INFO: arnoldlu stm32_system_off
INFO: arnoldlu stm32_enter_low_power, mode=0x00000005, nsec_addr=0x00000000
INFO: arnoldlu enter_cstop-133
INFO: arnoldlu stm32_pwr_down_wfi-338
INFO: arnoldlu stm32_pwr_down_wfi-343
hibernate resume流程log:
[ 3.500455] PM: resume from hibernation
[ 3.504076] Freezing user space processes ... (elapsed 0.000 seconds) done.
[ 3.509839] OOM killer disabled.
[ 3.536106] PM: Loading image data pages (16094 pages)...
[ 3.540530] PM: Image loading progress: 0%
[ 3.637384] PM: Image loading progress: 10%
[ 3.652342] PM: Image loading progress: 20%
[ 3.666588] PM: Image loading progress: 30%
[ 3.681412] PM: Image loading progress: 40%
[ 3.695582] PM: Image loading progress: 50%
[ 3.709767] PM: Image loading progress: 60%
[ 3.726351] PM: Image loading progress: 70%
[ 3.740577] PM: Image loading progress: 80%
[ 6.184681] PM: Image loading progress: 90%
[ 6.992923] PM: Image loading progress: 100%
[ 6.997255] PM: Image loading done
[ 6.999253] PM: Read 64376 kbytes in 3.45 seconds (18.65 MB/s)
[ 53.546686] OOM killer enabled.
[ 53.548373] Restarting tasks ... done.
[ 53.554439] PM: hibernation exit
# [ 53.608205] mmc1: Problem switching card into high-speed mode!
Linux下hibernate suspend流程:
sate_store hibernate hibernation_available lock_system_sleep pm_prepare_console __pm_notifier_call_chain ksys_sync_helper freeze_processes lock_device_hotplug create_basic_memory_bitmaps hibernation_snapshot swsusp_write swsusp_free power_down--根据hibernate模式不同执行不同流程,通过/sys/power/state设置。 suspend_devices_and_enter--suspend模式。 kernel_restart--reboot模式。 hiberrnation_platform_enter--platform模式。 kernel_power_off--shutdown模式。
在Linux启动时,调用software_resume检查是否上次为hibernate关闭:
late_initcall_sync(software_resume) pm_prepare_console __pm_notifier_call_chain freeze_processes load_image_and_restore lock_device_hotplug create_basic_memory_bitmaps swsusp_read swsusp_close hibernation_restore swsusp_free free_basic_memory_bitmaps unlock_device_hotplug thaw_processes __pm_notifier_call_chain pm_restore_console swsusp_close
标签:INFO,Hibernate,saving,STM32MP157D,Image,loading,Linux,progress,PM From: https://www.cnblogs.com/arnoldlu/p/16970810.html