Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d68bd7fb authored by Ram Chandrasekar's avatar Ram Chandrasekar
Browse files

drivers: thermal: cpu_isolate: core isolate outside critical section



Core isolation and unisolation is done inside the critical section with
the core isolation mutex. There is a possibility of deadlock, when the
core unisolation and core online from userspace happens simultaneously.
To avoid this move the core isolation and unisolation outside the
critical section so that deadlock is avoided.

Change-Id: Ic685a69ce8aa9929a3f12a7d0f287444748f1e26
Signed-off-by: default avatarRam Chandrasekar <rkumbako@codeaurora.org>
parent c0835c6a
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -70,9 +70,11 @@ static int cpu_isolate_pm_notify(struct notifier_block *nb,
				if (cpu_online(cpu) &&
					!cpumask_test_and_set_cpu(cpu,
					&cpus_isolated_by_thermal)) {
					mutex_unlock(&cpu_isolate_lock);
					if (sched_isolate_cpu(cpu))
						cpumask_clear_cpu(cpu,
						&cpus_isolated_by_thermal);
					mutex_lock(&cpu_isolate_lock);
				}
				continue;
			}
@@ -182,9 +184,11 @@ static int cpu_isolate_set_cur_state(struct thermal_cooling_device *cdev,
		if (cpu_online(cpu) &&
			(!cpumask_test_and_set_cpu(cpu,
			&cpus_isolated_by_thermal))) {
			mutex_unlock(&cpu_isolate_lock);
			if (sched_isolate_cpu(cpu))
				cpumask_clear_cpu(cpu,
					&cpus_isolated_by_thermal);
			mutex_lock(&cpu_isolate_lock);
		}
		cpumask_set_cpu(cpu, &cpus_in_max_cooling_level);
		blocking_notifier_call_chain(&cpu_max_cooling_level_notifer,
@@ -194,6 +198,7 @@ static int cpu_isolate_set_cur_state(struct thermal_cooling_device *cdev,
			cpu_dev = get_cpu_device(cpu);
			if (!cpu_dev) {
				pr_err("CPU:%d cpu dev error\n", cpu);
				mutex_unlock(&cpu_isolate_lock);
				return ret;
			}
			mutex_unlock(&cpu_isolate_lock);
@@ -203,7 +208,9 @@ static int cpu_isolate_set_cur_state(struct thermal_cooling_device *cdev,
			return ret;
		} else if (cpumask_test_and_clear_cpu(cpu,
			&cpus_isolated_by_thermal)) {
			mutex_unlock(&cpu_isolate_lock);
			sched_unisolate_cpu(cpu);
			mutex_lock(&cpu_isolate_lock);
		}
		cpumask_clear_cpu(cpu, &cpus_in_max_cooling_level);
		blocking_notifier_call_chain(&cpu_max_cooling_level_notifer,