Skip to contentSkip to conversation

cpufreq: intel_pstate: cancel HWP notify work in driver cleanup

PATCH In review Tristan Madani 2 participants 2 messages Oct 19 – Oct 22

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cpufreq: intel_pstate: cancel HWP notify work in driver cleanup

From: Tristan Madani <[email protected]>

intel_pstate_driver_cleanup() frees per-CPU data without cancelling the pending HWP notify delayed work. If hwp_notify_work is still scheduled or running when the struct is freed, the work function accesses freed memory via container_of().

Call intel_pstate_disable_hwp_interrupt() before kfree() to disable the interrupt source and cancel the pending work, matching the pattern used in intel_pstate_suspend() and intel_pstate_hwp_offline().

Fixes d0e936adfe84 ("cpufreq: intel_pstate: Add HWP_HIGHEST_PERF_CHANGE handling")
---
 drivers/cpufreq/intel_pstate.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/cpufreq/intel_pstate.c +2 -0
index 17158cb25dd89..0e6ae4cdda5de 100644
@@ -3436,6 +3436,8 @@ static void intel_pstate_driver_cleanup(void)
 			if (intel_pstate_driver == &intel_pstate)
 				intel_pstate_clear_update_util_hook(cpu);
 
+			intel_pstate_disable_hwp_interrupt(all_cpu_data[cpu]);
+
 			kfree(all_cpu_data[cpu]);
 			WRITE_ONCE(all_cpu_data[cpu], NULL);
 		}
Signature · 1 line
2.47.3
#1 lore raw
Quoted 8 lines · Tristan Madani

From: Tristan Madani <[email protected]>

intel_pstate_driver_cleanup() frees per-CPU data without cancelling the pending HWP notify delayed work. If hwp_notify_work is still scheduled or running when the struct is freed, the work function accesses freed memory via container_of().

Quoted 5 lines

Call intel_pstate_disable_hwp_interrupt() before kfree() to disable the interrupt source and cancel the pending work, matching the pattern used in intel_pstate_suspend() and intel_pstate_hwp_offline().

Fixes d0e936adfe84 ("cpufreq: intel_pstate: Add HWP_HIGHEST_PERF_CHANGE handling")

Where did you get this commit from? It is not a mainline one AFAICS.

Quoted 11 lines
---
 drivers/cpufreq/intel_pstate.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/cpufreq/intel_pstate.c +0 -0
index 17158cb25dd89..0e6ae4cdda5de 100644

drivers/cpufreq/intel_pstate.c static void intel_pstate_driver_cleanup(void)

Quoted 9 lines
drivers/cpufreq/intel_pstate.c +2 -1
@@ -3436,6 +3436,8 @@ static void intel_pstate_driver_cleanup(void)
                        if (intel_pstate_driver == &intel_pstate)
                                intel_pstate_clear_update_util_hook(cpu);
 
+                       intel_pstate_disable_hwp_interrupt(all_cpu_data[cpu]);
+
                        kfree(all_cpu_data[cpu]);
                        WRITE_ONCE(all_cpu_data[cpu], NULL);
                }
--

The Fixes: tag replaced with the following one:

Fixes d845cd901b28 ("cpufreq: intel_pstate: Support highest

performance change interrupt")

and patch applied as 7.4-rc material.

Thanks!