Commit d54520f7 authored by Stuart Hayes's avatar Stuart Hayes Committed by Greg Kroah-Hartman

acpi_pad: fix power_saving thread deadlock

commit 5f160126 upstream.

The acpi_pad driver can get stuck in destroy_power_saving_task()
waiting for kthread_stop() to stop a power_saving thread.  The problem
is that the isolated_cpus_lock mutex is owned when
destroy_power_saving_task() calls kthread_stop(), which waits for a
power_saving thread to end, and the power_saving thread tries to
acquire the isolated_cpus_lock when it calls round_robin_cpu().  This
patch fixes the issue by making round_robin_cpu() use its own mutex.

https://bugzilla.kernel.org/show_bug.cgi?id=42981Signed-off-by: default avatarStuart Hayes <Stuart_Hayes@Dell.com>
Signed-off-by: default avatarLen Brown <len.brown@intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 4849c078
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#define ACPI_PROCESSOR_AGGREGATOR_DEVICE_NAME "Processor Aggregator" #define ACPI_PROCESSOR_AGGREGATOR_DEVICE_NAME "Processor Aggregator"
#define ACPI_PROCESSOR_AGGREGATOR_NOTIFY 0x80 #define ACPI_PROCESSOR_AGGREGATOR_NOTIFY 0x80
static DEFINE_MUTEX(isolated_cpus_lock); static DEFINE_MUTEX(isolated_cpus_lock);
static DEFINE_MUTEX(round_robin_lock);
static unsigned long power_saving_mwait_eax; static unsigned long power_saving_mwait_eax;
...@@ -107,7 +108,7 @@ static void round_robin_cpu(unsigned int tsk_index) ...@@ -107,7 +108,7 @@ static void round_robin_cpu(unsigned int tsk_index)
if (!alloc_cpumask_var(&tmp, GFP_KERNEL)) if (!alloc_cpumask_var(&tmp, GFP_KERNEL))
return; return;
mutex_lock(&isolated_cpus_lock); mutex_lock(&round_robin_lock);
cpumask_clear(tmp); cpumask_clear(tmp);
for_each_cpu(cpu, pad_busy_cpus) for_each_cpu(cpu, pad_busy_cpus)
cpumask_or(tmp, tmp, topology_thread_cpumask(cpu)); cpumask_or(tmp, tmp, topology_thread_cpumask(cpu));
...@@ -116,7 +117,7 @@ static void round_robin_cpu(unsigned int tsk_index) ...@@ -116,7 +117,7 @@ static void round_robin_cpu(unsigned int tsk_index)
if (cpumask_empty(tmp)) if (cpumask_empty(tmp))
cpumask_andnot(tmp, cpu_online_mask, pad_busy_cpus); cpumask_andnot(tmp, cpu_online_mask, pad_busy_cpus);
if (cpumask_empty(tmp)) { if (cpumask_empty(tmp)) {
mutex_unlock(&isolated_cpus_lock); mutex_unlock(&round_robin_lock);
return; return;
} }
for_each_cpu(cpu, tmp) { for_each_cpu(cpu, tmp) {
...@@ -131,7 +132,7 @@ static void round_robin_cpu(unsigned int tsk_index) ...@@ -131,7 +132,7 @@ static void round_robin_cpu(unsigned int tsk_index)
tsk_in_cpu[tsk_index] = preferred_cpu; tsk_in_cpu[tsk_index] = preferred_cpu;
cpumask_set_cpu(preferred_cpu, pad_busy_cpus); cpumask_set_cpu(preferred_cpu, pad_busy_cpus);
cpu_weight[preferred_cpu]++; cpu_weight[preferred_cpu]++;
mutex_unlock(&isolated_cpus_lock); mutex_unlock(&round_robin_lock);
set_cpus_allowed_ptr(current, cpumask_of(preferred_cpu)); set_cpus_allowed_ptr(current, cpumask_of(preferred_cpu));
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment