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;
}
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

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