Skip to content

Commit 6d167a4

Browse files
shilpasrirafaeljw
authored andcommitted
cpufreq: powernv: Hot-plug safe the kworker thread
In the kworker_thread powernv_cpufreq_work_fn(), we can end up sending an IPI to a cpu going offline. This is a rare corner case which is fixed using {get/put}_online_cpus(). Along with this fix, this patch adds changes to do oneshot cpumask_{clear/and} operation. Suggested-by: Shreyas B Prabhu <shreyas@linux.vnet.ibm.com> Suggested-by: Gautham R Shenoy <ego@linux.vnet.ibm.com> Signed-off-by: Shilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com> Reviewed-by: Gautham R. Shenoy <ego@linux.vnet.ibm.com> Acked-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 86622cb commit 6d167a4

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

‎drivers/cpufreq/powernv-cpufreq.c‎

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <linux/of.h>
2929
#include <linux/reboot.h>
3030
#include <linux/slab.h>
31+
#include <linux/cpu.h>
3132

3233
#include <asm/cputhreads.h>
3334
#include <asm/firmware.h>
@@ -423,28 +424,30 @@ void powernv_cpufreq_work_fn(struct work_struct *work)
423424
{
424425
struct chip *chip = container_of(work, struct chip, throttle);
425426
unsigned int cpu;
426-
cpumask_var_t mask;
427+
cpumask_t mask;
427428

428-
smp_call_function_any(&chip->mask,
429+
get_online_cpus();
430+
cpumask_and(&mask, &chip->mask, cpu_online_mask);
431+
smp_call_function_any(&mask,
429432
powernv_cpufreq_throttle_check, NULL, 0);
430433

431434
if (!chip->restore)
432-
return;
435+
goto out;
433436

434437
chip->restore = false;
435-
cpumask_copy(mask, &chip->mask);
436-
for_each_cpu_and(cpu, mask, cpu_online_mask) {
437-
int index, tcpu;
438+
for_each_cpu(cpu, &mask) {
439+
int index;
438440
struct cpufreq_policy policy;
439441

440442
cpufreq_get_policy(&policy, cpu);
441443
cpufreq_frequency_table_target(&policy, policy.freq_table,
442444
policy.cur,
443445
CPUFREQ_RELATION_C, &index);
444446
powernv_cpufreq_target_index(&policy, index);
445-
for_each_cpu(tcpu, policy.cpus)
446-
cpumask_clear_cpu(tcpu, mask);
447+
cpumask_andnot(&mask, &mask, policy.cpus);
447448
}
449+
out:
450+
put_online_cpus();
448451
}
449452

450453
static char throttle_reason[][30] = {

0 commit comments

Comments
 (0)