THERMALD: minor fixes

file:944e6a3bcff0d1996bb7de1ba82ad197e83d010e -> file:39ef96af76dbedbe491a92b5dca152ac44aee1b8
--- a/drivers/thermal/msm_thermal.c
+++ b/drivers/thermal/msm_thermal.c
@@ -20,6 +20,7 @@
#include <linux/workqueue.h>
#include <linux/cpu.h>
#include <linux/reboot.h>
+#include <linux/earlysuspend.h>
#define DEF_TEMP_SENSOR0 0
#define DEF_TEMP_SENSOR1 1
@@ -52,6 +53,9 @@ static int thermal_throttled = 0;
//Save the cpu max freq before throttling
static int pre_throttled_max = 0;
+//screen status
+static bool screen_blank = false;
+
static struct delayed_work check_temp_work;
static struct workqueue_struct *check_temp_workq;
@@ -103,7 +107,7 @@ static int update_cpu_max_freq(struct cp
ret = cpufreq_update_policy(cpu);
if (!ret)
- pr_info("msm_thermal: Limiting core%d max frequency to %d\n",
+ pr_debug("msm_thermal: Limiting core%d max frequency to %d\n",
cpu, max_freq);
return ret;
@@ -114,11 +118,12 @@ static void check_temp(struct work_struc
struct cpufreq_policy *cpu_policy = NULL;
struct tsens_device tsens_dev0;
struct tsens_device tsens_dev1;
- unsigned long temp0 = 0, temp1 = 0;
+ unsigned long temp = 0, temp0 = 0, temp1 = 0;
unsigned int max_freq = 0;
bool update_policy = false;
int i = 0, cpu = 0;
int ret0 = 0, ret1 = 0;
+ bool sensor_fail = false;
tsens_dev0.sensor_num = DEF_TEMP_SENSOR0;
ret0 = tsens_get_temp(&tsens_dev0, &temp0);
@@ -130,11 +135,20 @@ static void check_temp(struct work_struc
goto reschedule;
}
- if ((max(temp0, temp1)) >= (msm_thermal_tuners_ins.shutdown_temp)) {
+ if ((screen_blank) || (temp1 < 0) || (temp1 > 150)) {
+ sensor_fail = true;
+ temp = temp0;
+ } else {
+ sensor_fail = false;
+ temp = (max(temp0, temp1));
+ }
+
+ if (temp >= msm_thermal_tuners_ins.shutdown_temp) {
mutex_lock(&emergency_shutdown_mutex);
pr_warn("################################\n");
pr_warn("################################\n");
pr_warn("- %u OVERTEMP! SHUTTING DOWN! -\n", msm_thermal_tuners_ins.shutdown_temp);
+ pr_warn("- cur temp:%lu measured by:%s -\n", temp, ((sensor_fail) || (temp0>temp1)) ? "0" : "1");
pr_warn("################################\n");
pr_warn("################################\n");
/* orderly poweroff tries to power down gracefully
@@ -145,7 +159,7 @@ static void check_temp(struct work_struc
max_freq = msm_thermal_tuners_ins.allowed_max_freq;
thermal_throttled = 3;
pr_warn("msm_thermal: Emergency throttled CPU%i to %u! temp:%lu\n",
- cpu, msm_thermal_tuners_ins.allowed_max_freq, (max(temp0, temp1)));
+ cpu, msm_thermal_tuners_ins.allowed_max_freq, temp);
}
mutex_unlock(&emergency_shutdown_mutex);
}
@@ -163,18 +177,18 @@ static void check_temp(struct work_struc
pre_throttled_max = cpu_policy->max;
//low trip point
- if (((max(temp0, temp1)) >= msm_thermal_tuners_ins.allowed_low_high) &&
- ((max(temp0, temp1)) < msm_thermal_tuners_ins.allowed_mid_high) &&
+ if ((temp >= msm_thermal_tuners_ins.allowed_low_high) &&
+ (temp < msm_thermal_tuners_ins.allowed_mid_high) &&
(thermal_throttled < 1)) {
update_policy = true;
max_freq = msm_thermal_tuners_ins.allowed_low_freq;
if (cpu == (CONFIG_NR_CPUS-1)) {
thermal_throttled = 1;
pr_warn("msm_thermal: Thermal Throttled (low)! temp:%lu by:%s\n",
- (max(temp0, temp1)), (temp0>temp1) ? "0" : "1");
+ temp, ((sensor_fail) || (temp0>temp1)) ? "0" : "1");
}
//low clr point
- } else if (((max(temp0, temp1)) < msm_thermal_tuners_ins.allowed_low_low) &&
+ } else if ((temp < msm_thermal_tuners_ins.allowed_low_low) &&
(thermal_throttled > 0)) {
if (pre_throttled_max != 0)
max_freq = pre_throttled_max;
@@ -191,18 +205,18 @@ static void check_temp(struct work_struc
if (cpu == (CONFIG_NR_CPUS-1)) {
thermal_throttled = 0;
pr_warn("msm_thermal: Low thermal throttle ended! temp:%lu by:%s\n",
- (max(temp0, temp1)), (temp0>temp1) ? "0" : "1");
+ temp, ((sensor_fail) || (temp0>temp1)) ? "0" : "1");
}
//mid trip point
- } else if (((max(temp0, temp1)) >= msm_thermal_tuners_ins.allowed_mid_high) &&
- ((max(temp0, temp1)) < msm_thermal_tuners_ins.allowed_max_high) &&
+ } else if ((temp >= msm_thermal_tuners_ins.allowed_mid_high) &&
+ (temp < msm_thermal_tuners_ins.allowed_max_high) &&
(thermal_throttled < 2)) {
update_policy = true;
max_freq = msm_thermal_tuners_ins.allowed_mid_freq;
if (cpu == (CONFIG_NR_CPUS-1)) {
thermal_throttled = 2;
pr_warn("msm_thermal: Thermal Throttled (mid)! temp:%lu by:%s\n",
- (max(temp0, temp1)), (temp0>temp1) ? "0" : "1");
+ temp, ((sensor_fail) || (temp0>temp1)) ? "0" : "1");
}
//mid clr point
} else if (((max(temp0, temp1)) < msm_thermal_tuners_ins.allowed_mid_low) &&
@@ -212,26 +226,26 @@ static void check_temp(struct work_struc
if (cpu == (CONFIG_NR_CPUS-1)) {
thermal_throttled = 1;
pr_warn("msm_thermal: Mid thermal throttle ended! temp:%lu by:%s\n",
- (max(temp0, temp1)), (temp0>temp1) ? "0" : "1");
+ temp, ((sensor_fail) || (temp0>temp1)) ? "0" : "1");
}
//max trip point
- } else if ((max(temp0, temp1)) >= msm_thermal_tuners_ins.allowed_max_high) {
+ } else if (temp >= msm_thermal_tuners_ins.allowed_max_high) {
update_policy = true;
max_freq = msm_thermal_tuners_ins.allowed_max_freq;
if (cpu == (CONFIG_NR_CPUS-1)) {
thermal_throttled = 3;
pr_warn("msm_thermal: Thermal Throttled (max)! temp:%lu by:%s\n",
- (max(temp0, temp1)), (temp0>temp1) ? "0" : "1");
+ temp, ((sensor_fail) || (temp0>temp1)) ? "0" : "1");
}
//max clr point
- } else if (((max(temp0, temp1)) < msm_thermal_tuners_ins.allowed_max_low) &&
+ } else if ((temp < msm_thermal_tuners_ins.allowed_max_low) &&
(thermal_throttled > 2)) {
max_freq = msm_thermal_tuners_ins.allowed_mid_freq;
update_policy = true;
if (cpu == (CONFIG_NR_CPUS-1)) {
thermal_throttled = 2;
pr_warn("msm_thermal: Max thermal throttle ended! temp:%lu by:%s\n",
- (max(temp0, temp1)), (temp0>temp1) ? "0" : "1");
+ temp, ((sensor_fail) || (temp0>temp1)) ? "0" : "1");
}
}
@@ -502,6 +516,22 @@ static struct attribute_group msm_therma
};
/**************************** SYSFS END ****************************/
+static void msm_thermal_early_suspend(struct early_suspend *h)
+{
+ screen_blank = true;
+}
+
+static void msm_thermal_late_resume(struct early_suspend *h)
+{
+ screen_blank = false;
+}
+
+static struct early_suspend msm_thermal_early_suspend_handler = {
+ .level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN,
+ .suspend = msm_thermal_early_suspend,
+ .resume = msm_thermal_late_resume,
+};
+
static int __init msm_thermal_init(void)
{
int rc, ret = 0;
@@ -524,6 +554,8 @@ static int __init msm_thermal_init(void)
} else
pr_warn("msm_thermal: sysfs: ERROR, could not create sysfs kobj");
+ register_early_suspend(&msm_thermal_early_suspend_handler);
+
return ret;
}
fs_initcall(msm_thermal_init);