From 5bd5aebe3dc587775f53c1fb78e2bf84d6c232b5 Mon Sep 17 00:00:00 2001 From: Manaf Meethalavalappu Pallikunhi Date: Thu, 7 Sep 2017 00:23:51 +0530 Subject: [PATCH] msm: thermal: Check cpu variables are initialized before setting threshold Userspace thermal daemon initiate KTM hotplug monitor related initialization. Thermal core control can be disabled/enabled from userspace via KTM sysfs for cpu related initialization after boot. There is a possible race condition between KTM hotplug initialization from thermal daemon and KTM core control re-enablement from userpsace shell. When these both events are triggered at the same time, thermal core control enablement tries to set emergency hotplug threshold prior to per cpu hotplug related initialization like sensor id, trip and threshold value etc. This leads to wrong sensor threshold settings and eventually thermal core sensor threshold list will be broken. To avoid this wrong threshold settings during thermal core control enablement, check KTM hotplug related initialization is done prior to threshold setting for each core. Change-Id: I916527d187146d5e292dd57897aa70b21cf87fbc Signed-off-by: Manaf Meethalavalappu Pallikunhi --- drivers/thermal/msm_thermal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/thermal/msm_thermal.c b/drivers/thermal/msm_thermal.c index 4b586f62cdc7..d7c6cd21a4f1 100644 --- a/drivers/thermal/msm_thermal.c +++ b/drivers/thermal/msm_thermal.c @@ -4996,7 +4996,7 @@ static ssize_t __ref store_cc_enabled(struct kobject *kobj, hotplug_init_cpu_offlined(); mutex_lock(&core_control_mutex); update_offline_cores(cpus_offlined); - if (hotplug_enabled) { + if (hotplug_enabled && hotplug_task) { for_each_possible_cpu(cpu) { if (!(msm_thermal_info.core_control_mask & BIT(cpus[cpu].cpu)))