转自:http://blog.csdn.net/wlwl0071986/article/details/42677403

一、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实例分析

Linux Runtime PM介绍【转】的更多相关文章

  1. linux runtime pm在深入了解的机制

    一:runtime机构简介 何为runtime机制?也就是系统在非睡眠状态,设备在空暇时能够进入runtime suspend状态同一时候不依赖系统wake_lock机制.非空暇时运行runtime  ...

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

    Run-time PM. 每个device或者bus都会向run-time PM core注册3个callback   struct dev_pm_ops { ... int (*runtime_su ...

  3. Runtime PM 处理不当导致的 external abort on non-linefetch 案例分享

    硬件平台:某ARM SoC 软件平台:Linux 1 Runtime PM 简介 在介绍 Runtime PM 之前,不妨先看看传统的电源管理.传统的电源管理机制,称之为 System PM(Syst ...

  4. Linux实战教学笔记07:Linux系统目录结构介绍

    第七节 Linux系统目录结构介绍 标签(空格分隔):Linux实战教学笔记 第1章 前言 windows目录结构 C:\windows D:\Program Files E:\你懂的\精品 F:\你 ...

  5. Linux的简单介绍和常用命令的介绍

    Linux的简单介绍和常用命令的介绍 本说明以Ubuntu系统为例 Ubuntu系统的安装自行百度,或者参考http://www.cnblogs.com/CoderJYF/p/6091068.html ...

  6. Linux性能工具介绍

    l  Linux性能工具介绍 p  CPU高 p  磁盘I/O p  网络 p  内存 p  应用程序跟踪 l  操作系统与应用程序的关系比喻为“唇亡齿寒”一点不为过 l  应用程序的性能问题/功能问 ...

  7. Linux core 文件介绍

    Linux core 文件介绍 http://www.cnblogs.com/dongzhiquan/archive/2012/01/20/2328355.html 1. core文件的简单介绍在一个 ...

  8. Linux 启动参数介绍

    Linux 启动参数介绍 取自2.6.18 kernel Documentation/i386/boot.txt 文件中介绍 vga= 这里的不是一个整数(在C语言表示法中,应是十进制,八进制或者十六 ...

  9. Linux系统启动过程介绍

    Linux系统启动过程介绍 学习操作系统有必要了解一下系统的启动过程,这样在面对各种系统故障的时候能快速定位解决问题,下面以Centos来分析linux系统的启动过程. 1.BIOS自检:当开机的时候 ...

随机推荐

  1. 搭建和使用Docker私有仓库

    需要注意的是,从Docker Pool下载的镜像文件,与官方镜像文件是完全一致的. 安装Docker之后,可以是使用官方提供的registry镜像来搭建一套本地私有仓库环境:  docker run  ...

  2. 十大技巧快速提升原生APP开发性能

    移动应用市场用户争夺战日益激烈,原来做APP拼想法拼创意拼是否抓住用户痛点.现在,精细化用户体验成为了一个APP能否留存用户的关键问题,一旦用户觉得体验不畅,马上就有竞品APP后补,如何开发高性能的移 ...

  3. 由一个Servlet 看java入门常犯的几个错误

    安装完java环境后,cmd-javac 报错           ------------->环境变量配错了,最后全配成系统变量,ok了 能浪费一天的时间 写一个最简单的Servlet ,to ...

  4. window.open被浏览器拦截的解决方案

    现象 最近在做项目的时候碰到了使用window.open被浏览器拦截的情况,搞得人无比郁闷啊,虽然在自己的环境可以对页面进行放行,但是对用户来说,不能要求用户都来通过拦截.何况当出现拦截时,很多小白根 ...

  5. ZOOKEEPER解惑

    现在网上关于ZooKeeper的文章很多,有介绍Leader选举算法的,有介绍ZooKeeper Server内部原理的,还有介绍ZooKeeper Client的.本文不打算再写类似的内容,而专注与 ...

  6. mysql 授权 user@'%' 为什么登陆的时候localhost 不行呢???

    公司业务服务器还没迁移到阿里云上的时候,创建的一个用户明明是所有的,但是本机登陆就是不行,一直也搞不懂原因 今天才知道 原来 %不包括 localhost mysql> grant all on ...

  7. SSH项目练习的时候报错:[applicationContext.xml]: Invocation of init method failed;

    这里是控制台的报错信息:org.springframework.beans.factory.BeanCreationException: Error creating bean with name ' ...

  8. canvas学习之圆周运动

    html部分 ...... <body> <canvas id="myCanvas" width="400" height="400 ...

  9. Linux14.04安装JDK

    1.下载jdk-7u5-linux-x64.tar.gz, 2.解压 一版有人会安装在e有人会安装在tc/local,etc/lib 或者opt等目录下. 安装目录:etc/local 解压到etc/ ...

  10. css less

    LESSCSS是一种动态样式语言,属于CSS预处理语言的一种,它使用类似CSS的语法,为CSS的赋予了动态语言的特性,如变量.继承.运算.函数等,更方便CSS的编写和维护. LESSCSS可以在多种语 ...