Linux kernel thermal manager

節(jié)點(diǎn)信息解釋

Thermal sysfs節(jié)點(diǎn)位置---/sys/class/thermal
每個(gè)thermal_zone下面代表一個(gè)sensor對(duì)應(yīng)的抽象,每個(gè)節(jié)點(diǎn)的基本含義如下

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

補(bǔ)充:
passive :(被動(dòng))默認(rèn)是0,表示disabled,也可以設(shè)置以millidegrees為單位的溫度值,來使能被動(dòng)的trip point for this zone
policy  : 一種當(dāng)前thermal zone的thermal governor, mtk用的只有backward_compatible(溫度大于等于設(shè)定,對(duì)應(yīng)的cooling device set_cur_state=1,溫度小于設(shè)定,對(duì)應(yīng)的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 表示應(yīng)用程序來調(diào)節(jié)thermal,內(nèi)核不管(mtk默認(rèn)使用私有的應(yīng)用層程序來管理)

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 --- 根據(jù)溫度變化趨勢來確定,如果thermal_zone溫度是逐漸升高的,則對(duì)應(yīng)的cooling device會(huì)采取對(duì)應(yīng)的降溫措施,如果thermal_zone溫度是降低的,則會(huì)逐漸恢復(fù)性能限制。
對(duì)應(yīng)判斷的狀態(tài)枚舉參數(shù)如下

 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函數(shù)
  static int step_wise_throttle(struct thermal_zone_device *tz, int trip)
{
        struct thermal_instance *instance;

        thermal_zone_trip_update(tz, trip); //根據(jù)當(dāng)前溫度和上次溫度對(duì)比,得到溫度趨勢;然后根據(jù)溫度趨勢得出Cooling設(shè)備對(duì)應(yīng)的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狀態(tài)。然后調(diào)用cdev->ops->set_cur_state()中

        mutex_unlock(&tz->lock);

        return 0;
}
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 文章目錄 文章目錄 Thermal概況 Thermal框架結(jié)構(gòu) 1.Thermal zone device 2.T...
    7f9ac2878fdb閱讀 1,141評(píng)論 0 0
  • (非原創(chuàng),引用,入門閱讀) 源碼位置: kernel3.18/ include/linux/thermal.h d...
    tiger桂閱讀 2,111評(píng)論 0 2
  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi閱讀 7,871評(píng)論 0 10
  • megalomaniac \?me-g?-lō-?mā-nē-?ak\ A mental disorder mar...
    fei老師閱讀 935評(píng)論 0 0
  • 久違的晴天,家長會(huì)。 家長大會(huì)開好到教室時(shí),離放學(xué)已經(jīng)沒多少時(shí)間了。班主任說已經(jīng)安排了三個(gè)家長分享經(jīng)驗(yàn)。 放學(xué)鈴聲...
    飄雪兒5閱讀 7,865評(píng)論 16 22

友情鏈接更多精彩內(nèi)容