[PATCH 07/13] thermal: intel: dpti: Configure the local CPU by value

From: Ricardo Neri

Date: Mon Nov 09 2026 - 22:41:45 EST


dpti_config() enables or disables the directed package-level thermal
interrupt (DPTI) on the CPU that runs it. It takes its argument by
pointer because it also serves as an smp_call_function_single()
callback. A caller that only programs its own CPU therefore has to
declare a scratch bool and track which value it holds at each call site.

Rename it to dpti_config_this_cpu() and let it take the setting by value.
Only the callers that reach another CPU need the callback signature;
unmarshal the argument for them in a thin dpti_config_ipi() trampoline.
The scratch bool then exists only where an SMP function call is made.

This also prepares for factoring the hardware programming sequence into a
helper that runs on the local CPU and configures the interrupt the same
way.

No functional change intended: the MSR read-modify-write is unchanged, and
the scratch bools held a known value at every converted call site.

Signed-off-by: Ricardo Neri <ricardo.neri-calderon@xxxxxxxxxxxxxxx>
---
drivers/thermal/intel/therm_throt.c | 24 ++++++++++++++----------
1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/drivers/thermal/intel/therm_throt.c b/drivers/thermal/intel/therm_throt.c
index a0a3842e2760..36cdbe0eb6c1 100644
--- a/drivers/thermal/intel/therm_throt.c
+++ b/drivers/thermal/intel/therm_throt.c
@@ -500,9 +500,8 @@ static int dpti_wait_for_ack(void)
return 0;
}

-static void dpti_config(void *info)
+static void dpti_config_this_cpu(bool enable)
{
- bool enable = *((bool *)info);
u64 msr_val;

rdmsrq(MSR_IA32_THERM_INTERRUPT, msr_val);
@@ -515,6 +514,11 @@ static void dpti_config(void *info)
wrmsrq(MSR_IA32_THERM_INTERRUPT, msr_val);
}

+static void dpti_config_ipi(void *info)
+{
+ dpti_config_this_cpu(*((bool *)info));
+}
+
/**
* struct dpti_pkg - Per-package DPTI state
* @owner: CPU currently programmed to receive the package-level
@@ -578,14 +582,13 @@ static void dpti_clear_all(void)
if (dpti_pkgs[i].owner == nr_cpu_ids)
continue;

- smp_call_function_single(dpti_pkgs[i].owner, dpti_config,
+ smp_call_function_single(dpti_pkgs[i].owner, dpti_config_ipi,
&enable, true);
}
}

static int dpti_online(unsigned int cpu)
{
- bool enable = true;
u16 pkg_id;

if (!dpti_supported())
@@ -605,15 +608,14 @@ static int dpti_online(unsigned int cpu)
thermal_clear_package_intr_status(PACKAGE_LEVEL,
PACKAGE_THERM_STATUS_DPTI_ACK);

- dpti_config(&enable);
+ dpti_config_this_cpu(true);
if (!dpti_wait_for_ack()) {
dpti_pkgs[pkg_id].owner = cpu;
return 0;
}

/* Roll back on failure so the package reverts to broadcasting mode. */
- enable = false;
- dpti_config(&enable);
+ dpti_config_this_cpu(false);

return -ETIMEDOUT;
}
@@ -657,7 +659,8 @@ static void dpti_offline(unsigned int cpu)
* but it does not reach this path because all the secondary
* CPUs are offline.
*/
- smp_call_function_single(new_cpu, dpti_config, &enable, true);
+ smp_call_function_single(new_cpu, dpti_config_ipi, &enable,
+ true);
}

/*
@@ -668,7 +671,8 @@ static void dpti_offline(unsigned int cpu)
*/
enable = false;
if (new_cpu < nr_cpu_ids && dpti_wait_for_ack()) {
- smp_call_function_single(new_cpu, dpti_config, &enable, true);
+ smp_call_function_single(new_cpu, dpti_config_ipi, &enable,
+ true);

pr_warn_once("Failed to redirect package thermal interrupt from CPU%u to CPU%u; reverting to broadcast\n",
cpu, new_cpu);
@@ -680,7 +684,7 @@ static void dpti_offline(unsigned int cpu)
* Clear the directed interrupt on @cpu. Hardware acknowledgment can be
* ignored since @cpu is going offline.
*/
- dpti_config(&enable);
+ dpti_config_this_cpu(false);

dpti_pkgs[pkg_id].owner = (new_cpu < nr_cpu_ids) ? new_cpu : nr_cpu_ids;
}

--
2.43.0