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 01/13] thermal: intel: Keep directed package interrupts off after syscore shutdown
Date: Mon, 09 Nov 2026 19:36:28 -0800	[thread overview]
Message-ID: <20261109-dpti-custom-cpu-v1-1-ead8e2d2067e@linux.intel.com> (raw)
In-Reply-To: <20261109-dpti-custom-cpu-v1-0-ead8e2d2067e@linux.intel.com>

On kexec, the syscore shutdown callback disables the directed package-level
thermal interrupt (DPTI) on every package. kernel_kexec() runs the callback
with CPU hotplug disabled, but re-enables CPU hotplug before
machine_shutdown() stops the other CPUs. A CPU hotplug operation in that
window directs the interrupt again: offlining the CPU that handles it
migrates the interrupt to another CPU, and a CPU coming online claims a
package that has no handler. The next kernel inherits the enable bit on
that CPU, never records the CPU as a handler, and never clears it.

Set a flag in the shutdown callback and make the CPU hotplug callbacks
leave DPTI alone once it is set. No lock is needed. The callback runs with
CPU hotplug disabled. Every later CPU hotplug operation takes
cpu_add_remove_lock, which cpu_hotplug_enable() releases after the flag is
set.

Fixes: 1e768cc92bc7 ("thermal: intel: Add a syscore shutdown callback for kexec reboot")
Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
---
Each package's handler is the first of its CPUs to come online, which for
package 0 is CPU0. On x86, CPU0 cannot be offlined. Its interrupt never
migrates: a single-package system never opens the window. The other
packages of a multi-package system can.

The sysfs interface added later in this series makes the window real on any
system: it can move the interrupt off CPU0, and each write programs a CPU
without a CPU hotplug operation.
---
 drivers/thermal/intel/therm_throt.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/drivers/thermal/intel/therm_throt.c b/drivers/thermal/intel/therm_throt.c
index 59520cac6cc8..1ed604bd70e0 100644
--- a/drivers/thermal/intel/therm_throt.c
+++ b/drivers/thermal/intel/therm_throt.c
@@ -578,6 +578,13 @@ static void config_directed_thermal_pkg_intr(void *info)
  */
 static unsigned int *directed_intr_handler_cpus;
 
+/*
+ * Set by the syscore shutdown callback before it disables the directed
+ * interrupt, so that no CPU hotplug operation enables it again on the way to
+ * kexec.
+ */
+static bool directed_pkg_intr_shut_down;
+
 static bool directed_thermal_pkg_intr_supported(void)
 {
 	if (!boot_cpu_has(X86_FEATURE_DPTI))
@@ -603,6 +610,10 @@ static void disable_directed_thermal_pkg_intr_all(void)
 	if (!directed_thermal_pkg_intr_supported())
 		return;
 
+	/*
+	 * No need to reset the handlers: callers free directed_intr_handler_cpus
+	 * or have shut DPTI down.
+	 */
 	for (i = 0; i < topology_max_packages(); i++) {
 		if (directed_intr_handler_cpus[i] == nr_cpu_ids)
 			continue;
@@ -625,6 +636,9 @@ static int enable_directed_thermal_pkg_intr(unsigned int cpu)
 	if (pkg_id >= topology_max_packages())
 		return -EINVAL;
 
+	if (directed_pkg_intr_shut_down)
+		return 0;
+
 	/* Another CPU in this package already handles the directed interrupt. */
 	if (directed_intr_handler_cpus[pkg_id] != nr_cpu_ids)
 		return 0;
@@ -662,6 +676,9 @@ static void disable_directed_thermal_pkg_intr(unsigned int cpu)
 	if (pkg_id >= topology_max_packages())
 		return;
 
+	if (directed_pkg_intr_shut_down)
+		return;
+
 	/* Not the CPU handling the directed interrupt. */
 	if (directed_intr_handler_cpus[pkg_id] != cpu)
 		return;
@@ -738,6 +755,8 @@ static int directed_pkg_intr_syscore_suspend(void *data)
 
 static void directed_pkg_intr_syscore_shutdown(void *data)
 {
+	directed_pkg_intr_shut_down = true;
+
 	disable_directed_thermal_pkg_intr_all();
 }
 

-- 
2.43.0


  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 ` Ricardo Neri [this message]
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 ` [PATCH 05/13] thermal: intel: dpti: Tear down DPTI only during boot Ricardo Neri
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-1-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®