当前位置: 首页 > news >正文

MTK CPU温度调节一知半解

关键术语

英文术语

中文翻译

解释

Adaptive Power Control

自适应功率控制

根据温度动态调整功耗的算法

Thermal Management (ATM)

热管理

控制芯片温度不超过安全阈值的机制

Power Budget

功率预算

分配给CPU/GPU的最大允许功耗

GPU Loading

GPU负载

GPU利用率(0-100%)

Theta_JA (ΘJA)

封装热阻

从结(Junction)到环境(Ambient)的热阻,单位℃/W

TARGET_TJ

目标结温

芯片核心的目标温度(通常为安全值,如85℃~105℃)

Fast Polling

快速轮询

更高频率的温度采样模式(响应更快但功耗略高)

Minimum Budget Change

最小预算调整步长

单次功率调整的最小值,避免频繁振荡

coolers

MTK coolers包括但不仅限于下面表格。AC8257主要使用了cpu温度过高、pmic温度过高、AP温度过高重启,CPU温度55度以及以上使用cooler atm自适应算法0,54度及以下使用cooler atm自适应算法1。

TZ Name

Trip Point

Cooler Name

mtktscpu

3

125

mtktscpu-sysrst

调用BUG触发重启

55

cpu_adaptive_0

54

cpu_adaptive_1

mtktspmic

1

136

mtktspmic-sysrst

mtktsbattery

0

60

mtktsbattery-sysrst

mtktspa

0

125

mtk-cl-shutdown01

mtktscharger

0

125

mtktscharger-sysrst

mtktscharger2

0

125

mtktscharger2-rst

mtktswmt

1

125

mtktswmt-sysrst

mtktsAP

7

125

mtktsAP-sysrst

90

mtk-cl-shutdown00

发uevent

53

mtk-cl-cam00

procfs给应用使用

47.001

abcct_lcmoff

47

abcct_2nd_lcmoff

45.001

abcct

45

abcct_2nd

mtktsbtsmdpa

4

125

mtk-cl-shutdown02

110

mtk-cl-mdoff

100

mtk-cl-noIMS

68

mtk-cl-adp-mutt

log

TSCPU_LOG_TAG

drivers/misc/mediatek/thermal/common/coolers/mtk_cooler_atm.c

tscpu_dprintk

drivers/misc/mediatek/thermal/ac8257/inc/tscpu_settings.h

245 #define TSCPU_LOG_TAG       "[Thermal/TZ/CPU]"
246
247 #define tscpu_dprintk(fmt, args...)   \
248     do {                                    \
249         if (tscpu_debug_log == 1) {                \
250             pr_notice(TSCPU_LOG_TAG fmt, ##args); \
251         }                                   \
252     } while (0)
253
254 #define tscpu_printk(fmt, args...) pr_notice(TSCPU_LOG_TAG fmt, ##args)
255 #define tscpu_warn(fmt, args...)  pr_notice(TSCPU_LOG_TAG fmt, ##args)

tscpu_debug_log

drivers/misc/mediatek/thermal/ac8257/src/mtk_tc.c

--- a/drivers/misc/mediatek/thermal/ac8257/src/mtk_tc.c
+++ b/drivers/misc/mediatek/thermal/ac8257/src/mtk_tc.c
@@ -127,7 +127,7 @@ const struct of_device_id mt_thermal_of_match[2] = {};#endif-int tscpu_debug_log;
+int tscpu_debug_log = 1;#if MTK_TS_CPU_RTstatic struct task_struct *ktp_thread_handle;

Thermal/TZ/CPU

01-01 08:00:03.344 I/[    0.576243](3)[1:swapper/0](    1): [Thermal/TZ/CPU]atm_loop c 70100 p 0 l 2147483647 L 70100 LL -127000
01-01 08:00:03.344 I/[    0.576290](0)[168:krtatm](  168): [Thermal/TZ/CPU]krtatm_thread c 70100 p 0 cl 2147483647 gl 2147483647 s 0
01-01 08:00:03.874 I/[    1.106175](0)[168:krtatm](  168): [Thermal/TZ/CPU]set_adaptive_cpu_power_limit 1052 T=72500, 1020 T=71900, 963 T=71500, 936 T=70300, 849 T=69700
01-01 08:00:04.394 I/[    1.626264](2)[168:krtatm](  168): [Thermal/TZ/CPU]set_adaptive_cpu_power_limit 1155 T=73900, 1143 T=73600, 1106 T=73700, 1089 T=73400, 1054 T=73300
01-01 08:00:05.854 I/[    3.086191](0)[168:krtatm](  168): [Thermal/TZ/CPU]set_adaptive_cpu_power_limit 925 T=73600, 875 T=76200, 920 T=76500, 945 T=77000, 1035 T=76200
01-01 08:00:07.111 I/[    4.342863](3)[168:krtatm](  168): [Thermal/TZ/CPU]set_adaptive_cpu_power_limit 729 T=76100, 766 T=76100, 783 T=76500, 860 T=76100, 987 T=73900
01-01 08:00:08.330 I/[    5.562685](3)[459:thermal_manager](  459): [Thermal/TZ/CPU]tscpu_write_atm_setting input 0 2000 10 15 1 685 0 280 0
01-01 08:00:08.330 I/[    5.562709](3)[459:thermal_manager](  459): [Thermal/TZ/CPU]tscpu_write_dtm_setting applied 0 2000 10 15 1 685 943 358 798
01-01 08:00:08.442 I/[    5.674076](0)[459:thermal_manager](  459): [Thermal/TZ/CPU]tscpu_write_atm_setting input 1 1000 10 15 1 400 0 220 0
01-01 08:00:08.442 I/[    5.674106](0)[459:thermal_manager](  459): [Thermal/TZ/CPU]tscpu_write_dtm_setting applied 1 1000 10 15 1 400 943 358 798
01-01 08:00:08.442 I/[    5.674565](0)[459:thermal_manager](  459): [Thermal/TZ/CPU]tscpu_write_ctm input 2 85000 55000 43000 46000 75000 51000 515000 10000 419000 8000 500 500 13500
01-01 08:00:08.443 I/[    5.675252](0)[459:thermal_manager](  459): [Thermal/TZ/CPU]tscpu_unbind unbinding OK
01-01 08:00:08.443 I/[    5.675316](0)[459:thermal_manager](  459): [Thermal/TZ/CPU]tscpu_unbind unbinding OK
01-01 08:00:08.443 I/[    5.675333](0)[459:thermal_manager](  459): [Thermal/TZ/CPU]tscpu_unbind unbinding OK
01-01 08:00:08.443 I/[    5.675352](0)[459:thermal_manager](  459): [Thermal/TZ/CPU]tscpu_unbind unbinding OK
01-01 08:00:08.444 I/[    5.675881](0)[459:thermal_manager](  459): [Thermal/TZ/CPU]tscpu_bind binding OK, 0
01-01 08:00:08.444 I/[    5.675942](0)[459:thermal_manager](  459): [Thermal/TZ/CPU]tscpu_bind binding OK, 2
01-01 08:00:08.444 I/[    5.675966](0)[459:thermal_manager](  459): [Thermal/TZ/CPU]tscpu_bind binding OK, 1
01-01 08:05:50.034 I/[  347.266146](0)[168:krtatm](  168): [Thermal/TZ/CPU]set_adaptive_cpu_power_limit 400 T=73900, 685 T=77000, 777 T=75300, 644 T=76100, 669 T=76200
01-01 08:35:44.177 W/[ 2141.409101](1)[980:kworker/u8:12](  980): [Thermal/TZ/CPU] 400 358 CPU T=85100

01-01 08:03:39.288     0     0 I [  214.555763](2)[0:swapper/2]: [Thermal/TZ/CPU]tscpu_thermal_read_tc_temp tc_num 0 type 0 order 0
01-01 08:03:39.288     0     0 I [  214.555784](2)[0:swapper/2]: [Thermal/TZ/CPU]read_tc_raw_temp,ts_raw=3393,temp=42000
01-01 08:03:39.288     0     0 I [  214.555796](2)[0:swapper/2]: [Thermal/TZ/CPU]tscpu_thermal_read_tc_temp order 0 tc_num 0 type 0 temp 42000
01-01 08:03:39.288     0     0 I [  214.555807](2)[0:swapper/2]: [Thermal/TZ/CPU]tscpu_thermal_read_tc_temp tc_num 0 type 1 order 1
01-01 08:03:39.288     0     0 I [  214.555860](2)[0:swapper/2]: [Thermal/TZ/CPU]read_tc_raw_temp,ts_raw=3394,temp=41400
01-01 08:03:39.288     0     0 I [  214.555872](2)[0:swapper/2]: [Thermal/TZ/CPU]tscpu_thermal_read_tc_temp order 1 tc_num 0 type 1 temp 41400
01-01 08:03:39.288     0     0 I [  214.555882](2)[0:swapper/2]: [Thermal/TZ/CPU]tscpu_thermal_read_tc_temp tc_num 0 type 2 order 2
01-01 08:03:39.288     0     0 I [  214.555892](2)[0:swapper/2]: [Thermal/TZ/CPU]read_tc_raw_temp,ts_raw=3395,temp=41300
01-01 08:03:39.288     0     0 I [  214.555903](2)[0:swapper/2]: [Thermal/TZ/CPU]tscpu_thermal_read_tc_temp order 2 tc_num 0 type 2 temp 41300
01-01 08:03:39.288     0     0 I [  214.555914](2)[0:swapper/2]: [Thermal/TZ/CPU]get_immediate_ts1_wrap curr_temp=42000
01-01 08:03:39.288     0     0 I [  214.555924](2)[0:swapper/2]: [Thermal/TZ/CPU]get_immediate_ts2_wrap curr_temp=41400
01-01 08:03:39.288     0     0 I [  214.555934](2)[0:swapper/2]: [Thermal/TZ/CPU]get_immediate_ts3_wrap curr_temp=41300
01-01 08:03:39.288     0     0 I [  214.555945]-(2)[0:swapper/2]: [Thermal/TZ/CPU]tscpu_get_temp tscpu_update_tempinfo, 1960
01-01 08:03:39.288     0     0 I [  214.555955]-(2)[0:swapper/2]: [Thermal/TZ/CPU]get_immediate_ts1_wrap curr_temp=42000
01-01 08:03:39.288     0     0 I [  214.555964]-(2)[0:swapper/2]: [Thermal/TZ/CPU]get_immediate_ts2_wrap curr_temp=41400
01-01 08:03:39.288     0     0 I [  214.555974]-(2)[0:swapper/2]: [Thermal/TZ/CPU]get_immediate_ts3_wrap curr_temp=41300
01-01 08:03:39.288     0     0 I [  214.555983](2)[0:swapper/2]: [Thermal/TZ/CPU]tscpu_get_temp tscpu_max_temperature, 343
01-01 08:03:39.288     0     0 I [  214.555998](2)[0:swapper/2]: [Thermal/TZ/CPU]get_immediate_cpuL_wrap curr_temp=42000
01-01 08:03:39.288     0     0 I [  214.556009](2)[0:swapper/2]: [Thermal/TZ/CPU]atm_loop c 42000 p 42000 l 2147483647 L 42000 LL -127000

tscpu

tscpu_thermal_probe

drivers/misc/mediatek/thermal/common/thermal_zones/mtk_ts_cpu.c

tscpu_get_temp

< -30度,> 85度,前后两次变化超过15度,任意一个条件满足就会打印。

 592 static int tscpu_get_temp(struct thermal_zone_device *thermal, int *t)593 {594     int ret = 0;595     int curr_temp;596 #if ENALBE_SW_FILTER597     int temp_temp;598     static int last_cpu_real_temp;599 #endif600 #if THERMAL_LT_SET_HPM601     int ts_temp, r;602 #endif603604 #ifdef FAST_RESPONSE_ATM605     curr_temp = tscpu_get_curr_max_ts_temp();606 #else607     curr_temp = tscpu_get_curr_temp();608 #endif609     tscpu_dprintk("%s CPU T=%d\n", __func__, curr_temp);610611     if ((curr_temp > (trip_temp[0] - 15000)) || (curr_temp < -30000)612     || (curr_temp > 85000)) {613         printk_ratelimited(TSCPU_LOG_TAG " %u %u CPU T=%d\n",614                 apthermolmt_get_cpu_power_limit(),615                 apthermolmt_get_gpu_power_limit(), curr_temp);616     }

ktp_thread

tscpu_thermal_all_bank_interrupt_handler

cooler atm

drivers/misc/mediatek/thermal/common/coolers/mtk_cooler_atm.c

算法

0: ATMv1 (default)

1: ATMv2 (FTL)

2: CPU_GPU_Weight ATM v2

3: Precise Power Budgeting + Hybrid Power Budgeting

proc fs

clatm_setting
clatm_gpu_threshold
clatm
clthp
clctm

krtatm_thread

mtk_get_gpu_loading获取GPU负载。_adaptive_power_calc根据上次温度、当前温度、GPU负载计算功率。_adaptive_power老版本计算方式(CPT_ADAPTIVE_AP_COOLER)。 _adaptive_power_ppb精准混合动力测算方法(PRECISE_HYBRID_POWER_BUDGET)。基于温度反馈的自适应功率分配算法,其核心是通过实时监测温度变化,动态调整CPU和GPU的功率预算,从而在防止过热和最大化性能之间取得平衡。

2982 #define KRTATM_RT   (1)
2983 #define KRTATM_CFS  (2)
2984 #define KRTATM_SCH  KRTATM_CFS
2985
2986 static int krtatm_thread(void *arg)
2987 {
2988 #ifdef ATM_CFG_PROFILING
2989     ktime_t last, delta;
2990 #endif
2991
2992 #if KRTATM_SCH == KRTATM_RT
2993     struct sched_param param = {.sched_priority = 98 };
2994
2995     sched_setscheduler(current, SCHED_FIFO, &param);
2996 #elif KRTATM_SCH == KRTATM_CFS
2997     set_user_nice(current, MIN_NICE);
2998 #endif
2999     set_current_state(TASK_INTERRUPTIBLE);
3000
3001     tscpu_dprintk("%s 1st run\n", __func__);
3002
3003     schedule();
3004
3005     for (;;) {
3006 #ifdef ATM_CFG_PROFILING
3007         if (atm_resumed) {
3008             atm_resumed = 0;
3009         } else {
3010             delta = ktime_get();
3011             if (ktime_after(delta, last))
3012                 atm_profile_atm_period(
3013                 ktime_to_us(ktime_sub(delta, last)));
3014         }
3015         last = ktime_get();
3016 #endif
3017         tscpu_dprintk("%s awake\n", __func__);
3018 #if (CONFIG_THERMAL_AEE_RR_REC == 1)
3019         aee_rr_rec_thermal_ATM_status(ATM_WAKEUP);
3020 #endif
3021         if (kthread_should_stop())
3022             break;
3023
3024         {
3025 #ifdef ATM_CFG_PROFILING
3026             ktime_t start, end;
3027 #endif
3028             unsigned int gpu_loading;
3029
3030 #ifdef ATM_CFG_PROFILING
3031             start = ktime_get();
3032             cpu_pwr_lmt_latest_delay = 0;
3033             gpu_pwr_lmt_latest_delay = 0;
3034 #endif
3035
3036             if (!mtk_get_gpu_loading(&gpu_loading))
3037                 gpu_loading = 0;
3038
3039             /* use separate prev/curr in krtatm because
3040              * krtatm may be blocked by PPM
3041              */
3042             krtatm_prev_maxtj = krtatm_curr_maxtj;
3043             krtatm_curr_maxtj = atm_curr_maxtj;
3044             if (krtatm_prev_maxtj == 0)
3045                 krtatm_prev_maxtj = atm_prev_maxtj;
3046
3047             _adaptive_power_calc(krtatm_prev_maxtj,
3048                         krtatm_curr_maxtj,
3049                         (unsigned int) gpu_loading);
3050
3051             /* To confirm if krtatm kthread is really running. */
3052             if (krtatm_curr_maxtj >= 100000 ||
3053             (krtatm_curr_maxtj - krtatm_prev_maxtj >= 20000))
3054                 tscpu_warn("%s c %d p %d cl %d gl %d s %d\n",
3055                 __func__, krtatm_curr_maxtj,
3056                 krtatm_prev_maxtj,
3057                 adaptive_cpu_power_limit,
3058                 adaptive_gpu_power_limit,
3059                 cl_dev_adp_cpu_state_active);
3060
3061 #ifdef ATM_CFG_PROFILING
3062             end = ktime_get();
3063             if (ktime_after(end, start))
3064                 atm_profile_atm_exec((ktime_to_us(
3065                     ktime_sub(end, start)) -
3066                     cpu_pwr_lmt_latest_delay
3067                     - gpu_pwr_lmt_latest_delay));
3068 #endif
3069         }
3070         set_current_state(TASK_INTERRUPTIBLE);
3071         schedule();
3072     }
3073
3074     tscpu_warn("%s stopped\n", __func__);
3075     return 0;
3076 }

_adaptive_power

_adaptive_power_ppb

算法的核心思想是:温度上升 → 功率预算减少;温度下降 → 功率预算增加。输入: 温度(当前、上次)、GPU负载。根据温度变化计算一个新的系统总功率预算。输出: 一个分解到CPU/GPU的功率限制值(通过 P_adaptive 函数)。

atm_loop

日志中c后面的表示当前温度,p后面的先前温度,l后面是cpu功耗限制,L后面为TS_MCU1温度,LL后面为-127000。大于100度或前后2次温度差超过15度,用tscpu_warn打印;否则tscpu_dprintk打印。

2827 #if KRTATM_TIMER == KRTATM_HR
2828 static enum hrtimer_restart atm_loop(struct hrtimer *timer)
2829 {
2830     ktime_t ktime;
2831 #elif KRTATM_TIMER == KRTATM_NORMAL
2832 static int atm_loop(void)
2833 {
2834 #endif
2835     int temp;
2836 #ifdef ENALBE_UART_LIMIT
2837 #if ENALBE_UART_LIMIT
2838     static int hasDisabled;
2839 #endif
2840 #endif
2841     char buffer[128];
2842     unsigned long polling_time;
2843 #if KRTATM_TIMER == KRTATM_HR
2844     unsigned long polling_time_s;
2845     unsigned long polling_time_ns;
2846 #endif
2847
2848     tscpu_workqueue_start_timer();
2849
2850     atm_prev_maxtj = atm_curr_maxtj;
2851     atm_curr_maxtj = tscpu_get_curr_temp();
2852
2853 #ifdef CONFIG_MTK_TINYSYS_SSPM_SUPPORT
2854 #if THERMAL_ENABLE_TINYSYS_SSPM && CPT_ADAPTIVE_AP_COOLER &&    \
2855     PRECISE_HYBRID_POWER_BUDGET && CONTINUOUS_TM
2856     if (atm_sspm_enabled == 1) {
2857 #ifdef ATM_CFG_PROFILING
2858         atm_resumed = 1; /* Must skip last timestamp. */
2859 #endif
2860         goto exit;
2861     }
2862 #endif
2863 #endif
2864
2865     temp = sprintf(buffer, "%s c %d p %d l %d ", __func__,
2866                         atm_curr_maxtj, atm_prev_maxtj,
2867                         adaptive_cpu_power_limit);
2868
2869     if (atm_curr_maxtj >= 100000
2870     || (atm_curr_maxtj - atm_prev_maxtj >= 15000))
2871         print_risky_temps(buffer, temp, 1);
2872     else
2873         print_risky_temps(buffer, temp, 0);
2874
2875 #ifdef ENALBE_UART_LIMIT
2876 #if ENALBE_UART_LIMIT
2877     temp = atm_curr_maxtj;
2878     if ((TEMP_DIS_UART - TEMP_TOLERANCE) < temp) {
2879         /************************************************
2880          *  Disable UART log
2881          ************************************************
2882          */
2883         if (mt_get_uartlog_status()) {
2884             hasDisabled = 1;
2885             set_uartlog_status(false);
2886         }
2887     }
2888
2889     if (temp < (TEMP_EN_UART + TEMP_TOLERANCE)) {
2890         /*************************************************
2891          *  Restore UART log
2892          ************************************************
2893          */
2894         if (!mt_get_uartlog_status() && hasDisabled)
2895             set_uartlog_status(true);
2896
2897         hasDisabled = 0;
2898     }
2899 #endif
2900 #endif
2901
2902     if (krtatm_thread_handle != NULL)
2903         wake_up_process(krtatm_thread_handle);
2904
2905
2906 #ifdef CONFIG_MTK_TINYSYS_SSPM_SUPPORT
2907 #if THERMAL_ENABLE_TINYSYS_SSPM && CPT_ADAPTIVE_AP_COOLER &&    \
2908     PRECISE_HYBRID_POWER_BUDGET && CONTINUOUS_TM
2909 exit:
2910 #endif
2911 #endif
2912
2913     polling_time = atm_get_timeout_time(atm_curr_maxtj);
2914
2915 #if KRTATM_TIMER == KRTATM_HR
2916
2917     /* avoid overflow */
2918     if (polling_time > (1000000000-1)) {
2919         polling_time_s = polling_time / 1000000000;
2920         polling_time_ns = polling_time % 1000000000;
2921         ktime = ktime_set(polling_time_s, polling_time_ns);
2922         /* tscpu_warn("%s polling_time_s=%ld  "
2923          *  "polling_time_ns=%ld\n", __func__,
2924          *  polling_time_s,polling_time_ns);
2925          */
2926
2927     } else {
2928         ktime = ktime_set(0, polling_time);
2929     }
2930
2931     hrtimer_forward_now(timer, ktime);
2932
2933     return HRTIMER_RESTART;
2934 #elif KRTATM_TIMER == KRTATM_NORMAL
2935
2936     atm_timer.expires = jiffies + msecs_to_jiffies(polling_time);
2937     add_timer(&atm_timer);
2938
2939     return 0;
2940 #endif
2941
2942 }

print_risky_temps

1624 /* chip dependent */
1625 void print_risky_temps(char *prefix, int offset, int printLevel)
1626 {
1627     sprintf((prefix + offset), "L %d LL %d",
1628             get_immediate_cpuL_wrap(), get_immediate_cpuLL_wrap());
1629
1630     switch (printLevel) {
1631     case 0:
1632         tscpu_dprintk("%s\n", prefix);
1633         break;
1634     case 1:
1635         tscpu_warn("%s\n", prefix);
1636         break;
1637     default:
1638         tscpu_dprintk("%s\n", prefix);
1639     }
1640 }

set_adaptive_cpu_power_limit

每运行5次打印1次。

 698 static void set_adaptive_cpu_power_limit(unsigned int limit)699 {700 #ifdef CONFIG_MTK_TINYSYS_SSPM_SUPPORT701 #if THERMAL_ENABLE_TINYSYS_SSPM && CPT_ADAPTIVE_AP_COOLER &&    \702     PRECISE_HYBRID_POWER_BUDGET && CONTINUOUS_TM703     mutex_lock(&atm_cpu_lmt_mutex);704 #endif705 #endif706707     prv_adp_cpu_pwr_lim = adaptive_cpu_power_limit;708     adaptive_cpu_power_limit = (limit != 0) ? limit : 0x7FFFFFFF;709 #ifdef CONFIG_MTK_TINYSYS_SSPM_SUPPORT710 #if THERMAL_ENABLE_TINYSYS_SSPM && CPT_ADAPTIVE_AP_COOLER &&    \711     PRECISE_HYBRID_POWER_BUDGET && CONTINUOUS_TM712     if (atm_sspm_enabled)713         adaptive_cpu_power_limit = 0x7FFFFFFF;714 #endif715 #endif716717     if (prv_adp_cpu_pwr_lim != adaptive_cpu_power_limit) {718 #ifdef ATM_CFG_PROFILING719         ktime_t now, delta;720 #endif721722         /* print debug log */723         adaptive_limit[print_cunt][0] =724             (int) (adaptive_cpu_power_limit != 0x7FFFFFFF) ?725                         adaptive_cpu_power_limit : 0;726727 #ifdef FAST_RESPONSE_ATM728         adaptive_limit[print_cunt][1] = krtatm_curr_maxtj;729 #else730         adaptive_limit[print_cunt][1] = tscpu_get_curr_temp();731 #endif732         print_cunt++;733         if (print_cunt == 5) {734             tscpu_warn(735                 "%s %d T=%d, %d T=%d, %d T=%d, %d T=%d, %d T=%d\n",736                 __func__,737                 adaptive_limit[4][0], adaptive_limit[4][1],738                 adaptive_limit[3][0], adaptive_limit[3][1],739                 adaptive_limit[2][0], adaptive_limit[2][1],740                 adaptive_limit[1][0], adaptive_limit[1][1],741                 adaptive_limit[0][0], adaptive_limit[0][1]);742743             print_cunt = 0;744         } else {745 #ifdef FAST_RESPONSE_ATM746             if ((prv_adp_cpu_pwr_lim != 0x7FFFFFFF) &&747                 ((adaptive_cpu_power_limit + 1000)748                 < prv_adp_cpu_pwr_lim))749                 tscpu_warn(750                     "%s Big delta power %u curr_T=%d, %u prev_T=%d\n",751                     __func__, adaptive_cpu_power_limit,752                     krtatm_curr_maxtj, prv_adp_cpu_pwr_lim,753                     krtatm_prev_maxtj);754 #endif755         }756757 #ifdef ATM_CFG_PROFILING758         now = ktime_get();759 #endif760         apthermolmt_set_cpu_power_limit(&ap_atm,761                     adaptive_cpu_power_limit);762763 #ifdef ATM_CFG_PROFILING764         delta = ktime_get();765         if (ktime_after(delta, now)) {766             cpu_pwr_lmt_latest_delay =767                     ktime_to_us(ktime_sub(delta, now));768769             atm_profile_cpu_power_limit(cpu_pwr_lmt_latest_delay);770         }771 #endif772     }773774 #ifdef CONFIG_MTK_TINYSYS_SSPM_SUPPORT775 #if THERMAL_ENABLE_TINYSYS_SSPM && CPT_ADAPTIVE_AP_COOLER &&    \776     PRECISE_HYBRID_POWER_BUDGET && CONTINUOUS_TM777     mutex_unlock(&atm_cpu_lmt_mutex);778 #endif779 #endif780 }

timer

高精度定时器,每100ms调用tscpu_get_curr_temp获取当前cpu温度。打印日志,c后面是当前温度,p后面是上一次温度,l后面是cpu功耗限制。"%s c %d p %d l %d ", __func__, atm_curr_maxtj, atm_prev_maxtj, adaptive_cpu_power_limit

2944 #if KRTATM_TIMER == KRTATM_HR
2945 static void atm_hrtimer_init(void)
2946 {
2947     ktime_t ktime;
2948
2949     tscpu_dprintk("%s\n", __func__);
2950
2951     /*100000000 = 100 ms,polling delay can't larger than 100ms*/
2952     atm_hrtimer_polling_delay =
2953             (atm_hrtimer_polling_delay < 100000000) ?
2954                     atm_hrtimer_polling_delay : 100000000;
2955
2956     ktime = ktime_set(0, atm_hrtimer_polling_delay);
2957
2958     hrtimer_init(&atm_hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
2959
2960     atm_hrtimer.function = atm_loop;
2961     hrtimer_start(&atm_hrtimer, ktime, HRTIMER_MODE_REL);
2962 }
2963 #elif KRTATM_TIMER == KRTATM_NORMAL
2964 static void atm_timer_init(void)
2965 {
2966     tscpu_dprintk("%s\n", __func__);
2967
2968     /*polling delay can't larger than 100ms*/
2969     atm_timer_polling_delay = (atm_timer_polling_delay < 100) ?
2970                         atm_timer_polling_delay : 100;
2971
2972     init_timer_deferrable(&atm_timer);
2973     atm_timer.function = (void *)&atm_loop;
2974     atm_timer.data = (unsigned long)&atm_timer;
2975     atm_timer.expires =
2976         jiffies + msecs_to_jiffies(atm_timer_polling_delay);
2977
2978     add_timer(&atm_timer);
2979 }
2980 #endif

polling delay

 288 #define TS_MS_TO_NS(x) (x * 1000 * 1000)289 #if KRTATM_TIMER == KRTATM_HR290 static struct hrtimer atm_hrtimer;291 static unsigned long atm_hrtimer_polling_delay =292                 TS_MS_TO_NS(CLATM_INIT_HRTIMER_POLLING_DELAY);

POLLING DELAY

drivers/misc/mediatek/thermal/ac8257/inc/clatm_initcfg.h

 62 #define CLATM_INIT_HRTIMER_POLLING_DELAY    (100)

cooler sysrst

drivers/misc/mediatek/thermal/common/coolers/mtk_cooler_sysrst.c

 52 /*53  * cooling device callback functions (tscpu_cooling_sysrst_ops)54  * 1 : ON and 0 : OFF55  */56 static int sysrst_cpu_get_max_state(57 struct thermal_cooling_device *cdev, unsigned long *state)58 {59     /* tscpu_dprintk("sysrst_cpu_get_max_state\n"); */60     *state = 1;61     return 0;62 }6364 static int sysrst_cpu_get_cur_state(65 struct thermal_cooling_device *cdev, unsigned long *state)66 {67     /* tscpu_dprintk("sysrst_cpu_get_cur_state\n"); */68     *state = cl_dev_sysrst_state;69     return 0;70 }7172 static int sysrst_cpu_set_cur_state(73 struct thermal_cooling_device *cdev, unsigned long state)74 {75     cl_dev_sysrst_state = state;7677     if (cl_dev_sysrst_state == 1) {78         tscpu_printk("sysrst_cpu_set_cur_state = 1\n");79         tscpu_printk("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");80         tscpu_printk("*****************************************\n");81         tscpu_printk("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");828384         /* To trigger data abort to reset the system85          * for thermal protection.86          */87         BUG();888990     }91     return 0;92 }

http://www.dtcms.com/a/393361.html

相关文章:

  • V90伺服驱动器“速度模式“双极性模拟量速度控制
  • 课前练习题-20250919
  • C++类与对象
  • 企业级Docker镜像仓库Harbor
  • ESD防护设计宝典(七):生命线的秩序——关键信号线布线规则
  • 【ROS2】Beginner : CLI tools - 理解 ROS 2 话题
  • RL知识回顾
  • Java多线程编程指南
  • 【论文速读】基于地面激光扫描(TLS)和迭 代最近点(ICP)算法的土坝监测变形分析
  • GAMES101:现代计算机图形学入门(Chapter2 向量与线性代数)迅猛式学线性代数学习笔记
  • 汉语构词智慧:从历史优势到现实考量——兼论“汉语全面改造英语”的可能性
  • 仿tcmalloc高并发内存池
  • 墨者学院-通关攻略(持续更新持续改进)
  • 10厘米钢板矫平机:把“波浪”压成“镜面”的科学
  • ESP32- 项目应用1 智能手表之网络配置 #6
  • TCP/IP 互联网的真相:空间域和时间域的统计学
  • 同步与异步
  • C++中char与string的终极对比指南
  • Java基础 9.20
  • U228721 反转单链表
  • 串行总线、并行总线
  • `HTML`实体插入软连字符: `shy;`
  • 日志驱动切换针对海外vps日志收集的操作标准
  • Zynq开发实践(SDK之自定义IP2 - FPGA验证)
  • 广东电信RTSP单播源参数解析
  • 关于工作中AI Coding的一些踩坑经验
  • MyBatis 参数传递详解:从基础到复杂场景全解析
  • ego(8)---L-BFGS优化算法与B样条生成最终轨迹
  • 【开题答辩全过程】以 HPV疫苗预约网站为例,包含答辩的问题和答案
  • Linux网络中Socket网络套接字的高级应用与优化策略