Linux Runtime PM介绍

一、Runtime PM引言

1. 背景

(1)display的需求

(2)系统整机动态功耗优化的需求

(3)upstream

2. 解决方案

(1)引入debounce

(2)使用统一的workqueue来管理任务

(3)实时地关闭不需要工作的device

(4)当device作为parent时,所有的child不工作时,关闭该device

(5)引入pm_rutime

3. 性能指标

(1)快速开关屏场景,亮屏速度提升

(2)动态功耗,更为稳定;唤醒而不亮屏的场景,功耗更低

(3)有助于降低系统整机动态功耗

二、Runtime PM框架

1. Runtime PM层次结构

2. Runtime PM状态

3. Runtime PM控制流程

每个设备或者子系统都会向Runtime PM core注册3个callback。

在struct dev_pm_ops结构体中,定义了这三个callback:

struct dev_pm_ops {

...

int (*runtime_suspend)(struct device *dev);

int (*runtime_resume)(struct device *dev);

int (*runtime_idle)(struct device *dev);

.suspend

.resume

};

注:引入runtime之后,suspend 接口需和runtime接口放在同一个数据结构内;

4. rpm_status(include\linux\pm.h)

enum rpm_status {

RPM_ACTIVE = 0, /* 表示runtime_resume()被成功执行 */

RPM_RESUMING, /* 表示runtime_resume()正在被执行 */

RPM_SUSPENDED, /* 表示runtime_suspend()被成功执行 */

RPM_SUSPENDING, /* 表示runtime_suspend()正在被执行 */

};

5. rpm_request(include\linux\pm.h)

enum rpm_request {

RPM_REQ_NONE = 0,RPM_REQ_IDLE, /* 执行runtime_idle() */

RPM_REQ_SUSPEND, /* 执行runtime_suspend () */

RPM_REQ_AUTOSUSPEND,  /* 延迟autosuspend_delay后执行runtime_suspend() */

RPM_REQ_RESUME,  /* 执行runtime_resume() */

};

请求的类型(设置request_pending才有效)。

6. Idle Reference API

pm_runtime_put_noidle: only put

pm_runtime_idle

pm_request_idle:async

pm_runtime_put: put + async

pm_runtime_put_sync

7. Suspend Reference API

pm_schedule_suspend

pm_runtime_suspend:

pm_runtime_put_sync_suspend: put

pm_runtime_autosuspend: auto

pm_request_autosuspend:async + auto

pm_runtime_put_autosuspend: put + async + auto

pm_runtime_put_sync_autosuspend: put + auto

8. Resume Reference API

pm_runtime_get_noresume

pm_runtime_resume

pm_request_resume: async

pm_runtime_get: get + async

pm_runtime_get_sync: get

9. Device Runtime suspend 流程

触发:

pm_schedule_suspend

pm_runtime_suspend:

pm_runtime_put_sync_suspend: put

pm_runtime_autosuspend: auto

pm_request_autosuspend:async + auto

pm_runtime_put_autosuspend: put + async + auto

pm_runtime_put_sync_autosuspend: put + auto

suspend的条件:

usage_cnt= 0;

disable_depth = 0;

runtime_status = RPM_ACTIVE

10. Device Runtime PM idle流程

idle的触发:

pm_runtime_put_noidle: only put

pm_runtime_idle

pm_request_idle:async

pm_runtime_put: put + async

pm_runtime_put_sync

idle的条件:

usage_cnt= 0;

disable_depth = 0;

runtime_status = RPM_ACTIVE

11. Device Runtime PM resume流程

触发:

pm_runtime_get_noresume

pm_runtime_resume

pm_request_resume: async

pm_runtime_get: get + async

pm_runtime_get_sync: get

条件:

disable_depth = 0

runtime_status != RPM_ACTIVE

三、Runtime PM和设备模型

1. Device Runtime PM 初始化

(1)设备模型完成pm_runtime 的初始化;

(2)对pm_runtime 状态的改变,需在device_register 之后实现;

(3)设备模型,在调用drv probe, remove, shutdown 等接口时,

可以保证pm_runtime 处于disable 状态,或其他约定状态;

void pm_runtime_init(struct device *dev)

{

dev->power.runtime_status = RPM_SUSPENDED;

dev->power.idle_notification = false;

dev->power.disable_depth = 1;

atomic_set(&dev->power.usage_count, 0);

dev->power.runtime_error = 0;

atomic_set(&dev->power.child_count, 0);

pm_suspend_ignore_children(dev, false);

dev->power.runtime_auto = true;

dev->power.request_pending = false;

dev->power.request = RPM_REQ_NONE;

dev->power.deferred_resume = false;

dev->power.accounting_timestamp = jiffies;

INIT_WORK(&dev->power.work, pm_runtime_work);

dev->power.timer_expires = 0;

setup_timer(&dev->power.suspend_timer, pm_suspend_timer_fn, (unsigned long)dev);

init_waitqueue_head(&dev->power.wait_queue);

}

platform_device_register(&platform_disp_device);

pm_runtime_set_active(&platform_disp_device.dev);

pm_runtime_get_noresume(&platform_disp_device.dev);

pm_runtime_enable(&platform_disp_device.dev);

pm_runtime_set_autosuspend_delay(&platform_disp_device.dev, 5000);

pm_runtime_use_autosuspend(&platform_disp_device.dev);

platform_driver_register(&disp_driver);

2. Device Runtime PM remove流程

3. Device Runtime PM shutdown流程

四、Runtime PM和电源管理

1. system sleep flow

2. system sleep flow: resume

3. system sleep flow: suspend

五、Runtime PM实例分析

时间: 2024-07-30 00:13:25

Linux Runtime PM介绍的相关文章

linux runtime pm机制的深入理解

一:runtime机制说明 何为runtime机制?也就是系统在非睡眠状态,设备在空闲时可以进入runtime suspend状态同时不依赖系统wake_lock机制,非空闲时执行runtime resume使得设备进入正常工作状态. 主要代码放在Runtime.c (drivers\base\power)中,同时附带的Runtime_pm.txt (documentation\power)有详细 说明.要使得设备可以进入runtime_idle与runtime_suspend必须满足devic

linux runtime pm在深入了解的机制

一:runtime机构简介 何为runtime机制?也就是系统在非睡眠状态,设备在空暇时能够进入runtime suspend状态同一时候不依赖系统wake_lock机制.非空暇时运行runtime resume使得设备进入正常工作状态. 主要代码放在Runtime.c (drivers\base\power)中,同一时候附带的Runtime_pm.txt (documentation\power)有具体 说明.要使得设备能够进入runtime_idle与runtime_suspend必须满足d

linux驱动程序之电源管理之Run-time PM 详解(4)

Run-time PM. 每个device或者bus都会向run-time PM core注册3个callback struct dev_pm_ops { ... int (*runtime_suspend)(struct device *dev); int (*runtime_resume)(struct device *dev); int (*runtime_idle)(struct device *dev); ... }; 每个device或者bus都会有2个计数器,一个是device的u

一个Linux平台PM功能初探

WatchDog 用户空间节点 /dev/watchdog /sys/bus/platform/devices/zx29_ap_wdt.0 /sys/bus/platform/drivers/zx29_ap_wdt 时钟资源 arch/arm/mach-zx297520v3/include/mach/iomap.h #define ZX_LSP_CRPM_BASE                       (ZX_LSP_BASE) drivers/clk/zte/clk-zx297520v3

linux 防火墙详细介绍

1.其实匹配扩展中,还有需要加-m引用模块的显示扩展,默认是隐含扩展,不要使用 -m状态检测的包过滤-m state       --state {NEW,ESTATBLISHED,INVALID,RELATED}  指定检测那种状态-m multiport 指定多端口号      --sport      --dport      --ports-m iprange 指定IP段      --src-range ip-ip      --dst-range ip-ip-m connlimit

linux 之 yum 介绍 <转>

原文在这里  http://doophp.sinaapp.com/archives/linux/yum-setting-parameter.html 因为是程序员出身,平时虽然经常接触服务器,偶尔也会要装一些软件.配置优化什么的,可能还是个人习惯问题,一般情况下我还是以手工编译居多(这其中的优缺点就不在这里啰嗦了).这几天有同事提出YUM其实更便于日常管理维护,确实,相对于手工编译,服务器多的时候YUM确实要方便不少.今天整理了一下YUM相关的背景知识,东西还不够详细,后续会逐步完善. YUM简

linux的基本介绍和命令行

<linux的基本介绍和命令行> [什么是Shell] (1)简介:shell是一款保护内核的软件.bash是shell的一个版本. 性质:命令解析器 用途:接受用户命令 1)在计算机科学中,shell俗称壳(用来区别核),是指"提供使用者使用界面"的软件(命令解析器).他类似于DOS和后来的cmd.exe.他接收用户命令,然后调用相应的应用程序.同时他又是一种程序设计语言.作为命令语言,他交互式解释和执行用户输入的命令,或者自动地解释和执行预先设定好的一连串命令:作为程序

Linux系统启动过程介绍

Linux系统启动过程介绍 学习操作系统有必要了解一下系统的启动过程,这样在面对各种系统故障的时候能快速定位解决问题,下面以Centos来分析linux系统的启动过程. 1.BIOS自检:当开机的时候,系统进行bios自检工作,当识别出第一块硬盘(IDE SCSI)及其空间之后,系统控制将从BIOS传递到引导装载程序 2.引导装载程序(grub lilo):装载第一块硬盘的前512个字节的物理数据扇区即主引导区MBR到内存中,位于此扇区开始位置的引导装载程序将接管系统控制. (也可以这么理解,在

Linux core 文件介绍

Linux core 文件介绍 http://www.cnblogs.com/dongzhiquan/archive/2012/01/20/2328355.html 1. core文件的简单介绍在一个程序崩溃时,它一般会在指定目录下生成一个core文件.core文件仅仅是一个内存映象(同时加上调试信息),主要是用来调试的. 2. 开启或关闭core文件的生成用以下命令来阻止系统生成core文件:ulimit -c 0下面的命令可以检查生成core文件的选项是否打开:ulimit -a该命令将显示