Linux kernel thermal manager

节点信息解释

Thermal sysfs节点位置---/sys/class/thermal
每个thermal_zone下面代表一个sensor对应的抽象,每个节点的基本含义如下

Thermal zone device sys I/F, created once it's registered:
/sys/class/thermal/thermal_zone[0-*]:
    |---type:                   Type of the thermal zone
    |---temp:                   Current temperature
    |---mode:                   Working mode of the thermal zone
    |---policy:                 Thermal governor used for this zone
    |---available_policies:     Available thermal governors for this zone
    |---trip_point_[0-*]_temp:  Trip point temperature
    |---trip_point_[0-*]_type:  Trip point type
    |---trip_point_[0-*]_hyst:  Hysteresis value for this trip point
    |---emul_temp:              Emulated temperature set node
    |---sustainable_power:      Sustainable dissipatable power
    |---k_po:                   Proportional term during temperature overshoot
    |---k_pu:                   Proportional term during temperature undershoot
    |---k_i:                    PID's integral term in the power allocator gov
    |---k_d:                    PID's derivative term in the power allocator
    |---integral_cutoff:        Offset above which errors are accumulated
    |---slope:                  Slope constant applied as linear extrapolation
    |---offset:                 Offset constant applied as linear extrapolation

补充:
passive :(被动)默认是0,表示disabled,也可以设置以millidegrees为单位的温度值,来使能被动的trip point for this zone
policy  : 一种当前thermal zone的thermal governor, mtk用的只有backward_compatible(温度大于等于设定,对应的cooling device set_cur_state=1,温度小于设定,对应的cooling device set_cur_state=0), 高通的是多种的,有 low_limits_floor low_limits_cap user_space step_wise 等
mode    : [enable/disable] enabled         = enable Kernel Thermal management , disabled 表示应用程序来调节thermal,内核不管(mtk默认使用私有的应用层程序来管理)

Thermal cooling device sys I/F, created once it's registered:
/sys/class/thermal/cooling_device[0-*]:
    |---type:                   Type of the cooling device(processor/fan/...)
    |---max_state:              Maximum cooling state of the cooling device
    |---cur_state:              Current cooling state of the cooling device

Kernel thermal governor --- step_wise 分析:

step_wise --- 根据温度变化趋势来确定,如果thermal_zone温度是逐渐升高的,则对应的cooling device会采取对应的降温措施,如果thermal_zone温度是降低的,则会逐渐恢复性能限制。
对应判断的状态枚举参数如下

 enum thermal_trend {
          THERMAL_TREND_STABLE, /* temperature is stable */
          THERMAL_TREND_RAISING, /* temperature is raising */
          THERMAL_TREND_DROPPING, /* temperature is dropping */
          THERMAL_TREND_RAISE_FULL, /* apply highest cooling action */
          THERMAL_TREND_DROP_FULL, /* apply lowest cooling action */
  };
  
  throttle函数
  static int step_wise_throttle(struct thermal_zone_device *tz, int trip)
{
        struct thermal_instance *instance;

        thermal_zone_trip_update(tz, trip); //根据当前温度和上次温度对比,得到温度趋势;然后根据温度趋势得出Cooling设备对应的state。

        if (tz->forced_passive)
                thermal_zone_trip_update(tz, THERMAL_TRIPS_NONE);

        mutex_lock(&tz->lock);

        list_for_each_entry(instance, &tz->thermal_instances, tz_node)
                thermal_cdev_update(instance->cdev);//遍历cdev->thermal_instances选择最深的cooling状态。然后调用cdev->ops->set_cur_state()中

        mutex_unlock(&tz->lock);

        return 0;
}
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 216,470评论 6 501
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 92,393评论 3 392
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 162,577评论 0 353
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,176评论 1 292
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,189评论 6 388
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,155评论 1 299
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,041评论 3 418
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 38,903评论 0 274
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,319评论 1 310
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,539评论 2 332
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,703评论 1 348
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,417评论 5 343
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,013评论 3 325
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,664评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,818评论 1 269
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 47,711评论 2 368
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,601评论 2 353

推荐阅读更多精彩内容

  • 文章目录 文章目录 Thermal概况 Thermal框架结构 1.Thermal zone device 2.T...
    7f9ac2878fdb阅读 881评论 0 0
  • (非原创,引用,入门阅读) 源码位置: kernel3.18/ include/linux/thermal.h d...
    tiger桂阅读 1,898评论 0 2
  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 7,322评论 0 10
  • megalomaniac \ˌme-gə-lō-ˈmā-nē-ˌak\ A mental disorder mar...
    fei老师阅读 713评论 0 0
  • 久违的晴天,家长会。 家长大会开好到教室时,离放学已经没多少时间了。班主任说已经安排了三个家长分享经验。 放学铃声...
    飘雪儿5阅读 7,520评论 16 22