Skip to content

Commit

Permalink
cpufreq: intel_pstate: Wait for canceled delayed work to complete
Browse files Browse the repository at this point in the history
Make intel_pstate_disable_hwp_interrupt() wait for canceled delayed work
to complete to avoid leftover work items running when it returns which
may be during driver unregistration and may confuse things going forward.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  • Loading branch information
Rafael J. Wysocki committed Apr 2, 2024
1 parent 12ebba4 commit 432acb2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions drivers/cpufreq/intel_pstate.c
Original file line number Diff line number Diff line change
Expand Up @@ -1682,16 +1682,20 @@ void notify_hwp_interrupt(void)

static void intel_pstate_disable_hwp_interrupt(struct cpudata *cpudata)
{
bool cancel_work;

if (!boot_cpu_has(X86_FEATURE_HWP_NOTIFY))
return;

/* wrmsrl_on_cpu has to be outside spinlock as this can result in IPC */
wrmsrl_on_cpu(cpudata->cpu, MSR_HWP_INTERRUPT, 0x00);

spin_lock_irq(&hwp_notify_lock);
if (cpumask_test_and_clear_cpu(cpudata->cpu, &hwp_intr_enable_mask))
cancel_delayed_work(&cpudata->hwp_notify_work);
cancel_work = cpumask_test_and_clear_cpu(cpudata->cpu, &hwp_intr_enable_mask);
spin_unlock_irq(&hwp_notify_lock);

if (cancel_work)
cancel_delayed_work_sync(&cpudata->hwp_notify_work);
}

static void intel_pstate_enable_hwp_interrupt(struct cpudata *cpudata)
Expand Down

0 comments on commit 432acb2

Please sign in to comment.