mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>,
	 Daniel Lezcano <daniel.lezcano@kernel.org>,
	Zhang Rui <rui.zhang@intel.com>,
	 Lukasz Luba <lukasz.luba@arm.com>,
	 Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: linux-pm@vger.kernel.org, linux-api@vger.kernel.org,
	 linux-kernel@vger.kernel.org, ricardo.neri@intel.com,
	 Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
Subject: [PATCH 05/13] thermal: intel: dpti: Tear down DPTI only during boot
Date: Mon, 09 Nov 2026 19:36:32 -0800	[thread overview]
Message-ID: <20261109-dpti-custom-cpu-v1-5-ead8e2d2067e@linux.intel.com> (raw)
In-Reply-To: <20261109-dpti-custom-cpu-v1-0-ead8e2d2067e@linux.intel.com>

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@linux.intel.com>
---
 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


  parent reply	other threads:[~2026-11-10  3:36 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-10  3:36 [PATCH 00/13] thermal: intel: dpti: Direct the package thermal interrupt to a chosen CPU Ricardo Neri
2026-11-10  3:36 ` [PATCH 01/13] thermal: intel: Keep directed package interrupts off after syscore shutdown Ricardo Neri
2026-11-10  3:36 ` [PATCH 02/13] thermal: intel: Prefix log messages via pr_fmt() Ricardo Neri
2026-11-10  3:36 ` [PATCH 03/13] thermal: intel: Move the sysfs device helpers next to their callers Ricardo Neri
2026-11-10  3:36 ` [PATCH 04/13] thermal: intel: dpti: Adopt the dpti_ prefix and the owner terminology Ricardo Neri
2026-11-10  3:36 ` Ricardo Neri [this message]
2026-11-10  3:36 ` [PATCH 06/13] thermal: intel: dpti: Introduce struct dpti_pkg for per-package state Ricardo Neri
2026-11-10  3:36 ` [PATCH 07/13] thermal: intel: dpti: Configure the local CPU by value Ricardo Neri
2026-11-10  3:36 ` [PATCH 08/13] thermal: intel: dpti: Factor the programming sequence out into a helper Ricardo Neri
2026-11-10  3:36 ` [PATCH 09/13] thermal: intel: dpti: Program the directed interrupt on the target CPU Ricardo Neri
2026-11-10  3:36 ` [PATCH 10/13] thermal: intel: dpti: Add rank-based owner selection Ricardo Neri
2026-11-10  3:36 ` [PATCH 11/13] thermal: intel: dpti: Serialize updates to the directed interrupt state Ricardo Neri
2026-11-10  3:36 ` [PATCH 12/13] thermal: intel: dpti: Avoid nohz_full CPUs when possible Ricardo Neri
2026-11-10  3:36 ` [PATCH 13/13] thermal: intel: dpti: Add sysfs control of interrupt owner Ricardo Neri

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261109-dpti-custom-cpu-v1-5-ead8e2d2067e@linux.intel.com \
    --to=ricardo.neri-calderon@linux.intel.com \
    --cc=daniel.lezcano@kernel.org \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=lukasz.luba@arm.com \
    --cc=rafael@kernel.org \
    --cc=ricardo.neri@intel.com \
    --cc=rui.zhang@intel.com \
    --cc=srinivas.pandruvada@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®