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 <manafm@codeaurora.org>
This commit is contained in:
Manaf Meethalavalappu Pallikunhi 2017-09-07 00:23:51 +05:30
parent e29d253ecf
commit 5bd5aebe3d

View file

@ -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)))