huchuan2025/20-Area/202-Work/222-ReadNote/Linux OS/内核代码分析/睡眠过程分析.md

54 lines
2.7 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

- 文件夹
- kernel/power/
- main.c 模块入口 core_initcall
- suspend.c 睡眠 to RAM
- hibernate.c 休眠 to DISK
- poweroff.c 关机
- 数据结构
- syspend的几种模式
- `#define PM_SUSPEND_ON       ((__force suspend_state_t) 0)`
- `#define PM_SUSPEND_TO_IDLE  ((__force suspend_state_t) 1)` // s2-idle sleep
- `#define PM_SUSPEND_STANDBY  ((__force suspend_state_t) 2)` // standby modern?
- `#define PM_SUSPEND_MEM      ((__force suspend_state_t) 3)` // s3 sleep
- 函数
- pm_suspend S2 S3(deep sleep) CONFIG_SUSPEND_SKIP_SYNC
- **enter_state** // s2idle shallow deep
- **ksys_sync_helper** // 选择是否sync CONFIG_SUSPEND_SKIP_SYNC
- **suspend_prepare** // 主要就是冻结软件进程
- suspend_freeze_processes
- freeze_processes // 冻结用户态进程
- freeze_kernel_threads // 冻结内核任务
- **suspend_devices_and_enter** // core function
- platform_suspend_begin
- suspend_console // 挂起console从此时开始console无法再输出
- **suspend_enter** // power/suspend.c 进入syspend模式
- s2 和 s3的模式在这个函数中很不一样
- S2
- s2idle_loop // s2本质上是一个循环
- S3 standby
- suspend_disable_secondary_cpus
- **arch_suspend_disable_irqs** -> local_irq_disable 屏蔽本核I位 但是FIQ依然可以响应
- syscore_suspend drivers/base/syscore.c
- **psci_system_suspend_enter** // arm64用的是psci进行电源管理
- cpu_suspend // arm64
- cpu_suspend_enter // arch/arm64/kernel/sleep.s
- psci_system_suspend ==> bl3
- suspend_finish
[H 86.979381374] cs: c0 pc[c023c69a] lr[c023c689] sp[c0e5bdf0]
[H 86.985310124] c0 pc: [<0xc023c69a>] arch_spin_lock+0x1a/0x32
[H 86.991243291] c0 [<0xc047cd4b>] _raw_spin_lock_irqsave+0xd/0x10
[H 86.997429541] c0 [<0xc023b997>] down_trylock+0x9/0x1c
[H 87.2745749] c0 [<0xc023ebb3>] __down_trylock_console_sem.constprop.0+0x13/0x28
[H 87.10231208] c0 [<0xc023ebcf>] console_trylock+0x7/0x30
[H 87.15717749] c0 [<0xc023ebff>] console_trylock_spinning+0x7/0x78
[H 87.21985249] c0 [<0xc024038f>] vprintk_emit+0x6b/0x90
[H 87.27297749] c0 [<0xc02403c7>] vprintk_default+0x13/0x18
[H 87.32869624] c0 [<0xbf8cb173>] osal_printk+0x1f/0x34 [osaldrv]
[H 87.39013916] c0 [<0xbf9941ad>] vnne_suspend+0x19/0x30 [vnne]
[H 87.44949749] c0 [<0xc03983a7>] dpm_run_callback+0x17/0x30
[H 87.50613124] c0 [<0xc0398705>] __device_suspend+0x109/0x230
[H 87.56445583] c0 [<0xc0398d8d>] dpm_suspend+0x5f/0xea
[H 87.61672416] c0 [<0xc0398eeb>] dpm_suspend_start+0x2f/0x38
[H 87.67417708] c0 [<0xc023e5cd>] suspend_devices_and_enter+0x49/0xe4