Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

MIPS: Loongson: Reduce possible loop times and add log in do_thermal_timer()

Once the temperature of any CPUs is too high, it can power off immediately,
no need to check the rest of CPUs, and it is better to print a log before
power off, this is useful when analysis the abnormal issues.

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Signed-off-by: Zhi Li <lizhi01@loongson.cn>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>

authored by

Tiezhu Yang and committed by
Thomas Bogendoerfer
17cbb070 f17d3f21

+6 -7
+6 -7
drivers/platform/mips/cpu_hwmon.c
··· 153 153 154 154 static void do_thermal_timer(struct work_struct *work) 155 155 { 156 - int i, value, temp_max = 0; 156 + int i, value; 157 157 158 158 for (i = 0; i < nr_packages; i++) { 159 159 value = loongson3_cpu_temp(i); 160 - if (value > temp_max) 161 - temp_max = value; 160 + if (value > CPU_THERMAL_THRESHOLD) { 161 + pr_emerg("Power off due to high temp: %d\n", value); 162 + orderly_poweroff(true); 163 + } 162 164 } 163 165 164 - if (temp_max <= CPU_THERMAL_THRESHOLD) 165 - schedule_delayed_work(&thermal_work, msecs_to_jiffies(5000)); 166 - else 167 - orderly_poweroff(true); 166 + schedule_delayed_work(&thermal_work, msecs_to_jiffies(5000)); 168 167 } 169 168 170 169 static int __init loongson_hwmon_init(void)