[PATCH 05/13] thermal: intel: dpti: Tear down DPTI only during boot
From: Ricardo Neri
Date: Mon Nov 09 2026 - 22:42:02 EST
An unacknowledged DPTI setup on a CPU coming online tears DPTI down on all
packages, at any time. During boot, the hotplug online callback runs on
every online CPU. The teardown keeps each of them from spending its own ack
timeout on the same failure.
Add a flag that tells boot apart from later CPU hotplug. Clear it once the
hotplug callbacks are registered. By then at least one CPU has attempted
the setup. If DPTI is still up, that attempt succeeded. From then on,
assume the hardware works and prevent a complete teardown from other code
paths.
The flag is system-wide. This assumes that if DPTI works on the boot
package it will work on others too. This assumption is reasonable since all
packages are identical in hardware and firmware.
Skipping the teardown after boot is safe because a failure leaves the
hardware in a working state: failures in the migration of the interrupt to
another CPU fall back to broadcasting the interrupt to all CPUs in the
package.
Name the failing package in the message and whether it alone or every
package reverts to broadcast. Raise the message to a warning, like the
offline path's.
cpuhp_setup_state() releases the CPU hotplug lock before returning.
Clearing the flag outside the lock means a CPU could come online in that
window, see the flag still set, and hit the boot-teardown path on failure,
even though the initcall has already finished verifying the CPUs to which
"boot" refers. Use cpuhp_setup_state_cpuslocked() under cpus_read_lock()
so the flag is cleared while no CPU can come online.
Signed-off-by: Ricardo Neri <ricardo.neri-calderon@xxxxxxxxxxxxxxx>
---
drivers/thermal/intel/therm_throt.c | 47 +++++++++++++++++++++++++++----------
1 file changed, 34 insertions(+), 13 deletions(-)
diff --git a/drivers/thermal/intel/therm_throt.c b/drivers/thermal/intel/therm_throt.c
index a170dcc8513f..ac719e2407ac 100644
--- a/drivers/thermal/intel/therm_throt.c
+++ b/drivers/thermal/intel/therm_throt.c
@@ -529,6 +529,13 @@ static unsigned int *dpti_owner_cpus;
*/
static bool dpti_shut_down;
+/*
+ * Cleared once the hotplug callbacks are registered: at least one CPU
+ * attempted the setup by then, and the hardware is assumed sane from that
+ * point on.
+ */
+static bool dpti_in_boot __ro_after_init = true;
+
static bool dpti_supported(void)
{
if (!boot_cpu_has(X86_FEATURE_DPTI))
@@ -595,11 +602,7 @@ static int dpti_online(unsigned int cpu)
return 0;
}
- /*
- * A failure indicates faulty hardware. Roll back completely so that
- * no other CPU tries. This is especially important during boot as all
- * CPUs may come online and would otherwise keep trying.
- */
+ /* Roll back on failure so the package reverts to broadcasting mode. */
enable = false;
dpti_config(&enable);
@@ -681,8 +684,7 @@ static void dpti_syscore_resume(void *data)
{
/*
* We can't do anything to handle errors. If direction fails for CPU0,
- * another CPU will take over or disable direction entirely during CPU
- * hotplug.
+ * another CPU will take over during CPU hotplug.
*/
dpti_online(0);
}
@@ -825,8 +827,16 @@ static int thermal_throttle_online(unsigned int cpu)
intel_hfi_online(cpu);
if (dpti_online(cpu)) {
- pr_info_once("Failed to direct package thermal interrupts. All CPUs will receive it\n");
- dpti_cleanup();
+ pr_warn_once("Failed to direct the thermal interrupt of package %u; reverting to broadcast on %s\n",
+ topology_logical_package_id(cpu),
+ dpti_in_boot ? "all packages" : "this package");
+
+ /*
+ * A failure during boot indicates faulty hardware, so no other
+ * CPU should try.
+ */
+ if (dpti_in_boot)
+ dpti_cleanup();
}
/* Unmask the thermal vector after the above workqueues are initialized. */
@@ -871,11 +881,22 @@ static __init int thermal_throttle_init_device(void)
intel_hfi_init();
- ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "x86/therm:online",
- thermal_throttle_online,
- thermal_throttle_offline);
- if (ret >= 0)
+ /*
+ * A CPU coming online before dpti_in_boot is cleared would treat a DPTI
+ * failure as faulty hardware and tear DPTI down. Hold the CPU hotplug
+ * lock across the registration and the clear, so that the flag changes
+ * only while no CPU can come online.
+ */
+ guard(cpus_read_lock)();
+
+ ret = cpuhp_setup_state_cpuslocked(CPUHP_AP_ONLINE_DYN,
+ "x86/therm:online",
+ thermal_throttle_online,
+ thermal_throttle_offline);
+ if (ret >= 0) {
+ dpti_in_boot = false;
return 0;
+ }
dpti_cleanup();
--
2.43.0