diff options
Diffstat (limited to 'drivers/thermal')
-rw-r--r-- | drivers/thermal/intel_powerclamp.c | 45 |
1 files changed, 20 insertions, 25 deletions
diff --git a/drivers/thermal/intel_powerclamp.c b/drivers/thermal/intel_powerclamp.c index 0e4dc0afcfd2..63657d193db5 100644 --- a/drivers/thermal/intel_powerclamp.c +++ b/drivers/thermal/intel_powerclamp.c | |||
@@ -508,10 +508,27 @@ static void poll_pkg_cstate(struct work_struct *dummy) | |||
508 | schedule_delayed_work(&poll_pkg_cstate_work, HZ); | 508 | schedule_delayed_work(&poll_pkg_cstate_work, HZ); |
509 | } | 509 | } |
510 | 510 | ||
511 | static void start_power_clamp_thread(unsigned long cpu) | ||
512 | { | ||
513 | struct task_struct **p = per_cpu_ptr(powerclamp_thread, cpu); | ||
514 | struct task_struct *thread; | ||
515 | |||
516 | thread = kthread_create_on_node(clamp_thread, | ||
517 | (void *) cpu, | ||
518 | cpu_to_node(cpu), | ||
519 | "kidle_inject/%ld", cpu); | ||
520 | if (IS_ERR(thread)) | ||
521 | return; | ||
522 | |||
523 | /* bind to cpu here */ | ||
524 | kthread_bind(thread, cpu); | ||
525 | wake_up_process(thread); | ||
526 | *p = thread; | ||
527 | } | ||
528 | |||
511 | static int start_power_clamp(void) | 529 | static int start_power_clamp(void) |
512 | { | 530 | { |
513 | unsigned long cpu; | 531 | unsigned long cpu; |
514 | struct task_struct *thread; | ||
515 | 532 | ||
516 | set_target_ratio = clamp(set_target_ratio, 0U, MAX_TARGET_RATIO - 1); | 533 | set_target_ratio = clamp(set_target_ratio, 0U, MAX_TARGET_RATIO - 1); |
517 | /* prevent cpu hotplug */ | 534 | /* prevent cpu hotplug */ |
@@ -527,20 +544,7 @@ static int start_power_clamp(void) | |||
527 | 544 | ||
528 | /* start one thread per online cpu */ | 545 | /* start one thread per online cpu */ |
529 | for_each_online_cpu(cpu) { | 546 | for_each_online_cpu(cpu) { |
530 | struct task_struct **p = | 547 | start_power_clamp_thread(cpu); |
531 | per_cpu_ptr(powerclamp_thread, cpu); | ||
532 | |||
533 | thread = kthread_create_on_node(clamp_thread, | ||
534 | (void *) cpu, | ||
535 | cpu_to_node(cpu), | ||
536 | "kidle_inject/%ld", cpu); | ||
537 | /* bind to cpu here */ | ||
538 | if (likely(!IS_ERR(thread))) { | ||
539 | kthread_bind(thread, cpu); | ||
540 | wake_up_process(thread); | ||
541 | *p = thread; | ||
542 | } | ||
543 | |||
544 | } | 548 | } |
545 | put_online_cpus(); | 549 | put_online_cpus(); |
546 | 550 | ||
@@ -572,7 +576,6 @@ static int powerclamp_cpu_callback(struct notifier_block *nfb, | |||
572 | unsigned long action, void *hcpu) | 576 | unsigned long action, void *hcpu) |
573 | { | 577 | { |
574 | unsigned long cpu = (unsigned long)hcpu; | 578 | unsigned long cpu = (unsigned long)hcpu; |
575 | struct task_struct *thread; | ||
576 | struct task_struct **percpu_thread = | 579 | struct task_struct **percpu_thread = |
577 | per_cpu_ptr(powerclamp_thread, cpu); | 580 | per_cpu_ptr(powerclamp_thread, cpu); |
578 | 581 | ||
@@ -581,15 +584,7 @@ static int powerclamp_cpu_callback(struct notifier_block *nfb, | |||
581 | 584 | ||
582 | switch (action) { | 585 | switch (action) { |
583 | case CPU_ONLINE: | 586 | case CPU_ONLINE: |
584 | thread = kthread_create_on_node(clamp_thread, | 587 | start_power_clamp_thread(cpu); |
585 | (void *) cpu, | ||
586 | cpu_to_node(cpu), | ||
587 | "kidle_inject/%lu", cpu); | ||
588 | if (likely(!IS_ERR(thread))) { | ||
589 | kthread_bind(thread, cpu); | ||
590 | wake_up_process(thread); | ||
591 | *percpu_thread = thread; | ||
592 | } | ||
593 | /* prefer BSP as controlling CPU */ | 588 | /* prefer BSP as controlling CPU */ |
594 | if (cpu == 0) { | 589 | if (cpu == 0) { |
595 | control_cpu = 0; | 590 | control_cpu = 0; |