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 09/13] thermal: intel: dpti: Program the directed interrupt on the target CPU
Date: Mon, 09 Nov 2026 19:36:36 -0800 [thread overview]
Message-ID: <20261109-dpti-custom-cpu-v1-9-ead8e2d2067e@linux.intel.com> (raw)
In-Reply-To: <20261109-dpti-custom-cpu-v1-0-ead8e2d2067e@linux.intel.com>
The CPU online and offline paths of the directed package-level thermal
interrupt (DPTI) both perform the same hardware programming sequence: clear
the acknowledgment status, enable the interrupt on a target CPU, wait for
the hardware to acknowledge the setup, and roll back the enable if the
acknowledgment times out.
MSR_IA32_PACKAGE_THERM_STATUS is package-scoped, but both paths clear and
poll it on the CPU that runs them while enabling the interrupt on the
target CPU. This setup works because every caller today targets a CPU in
its own package. A sysfs interface that programs an owner on behalf of any
package will lift that restriction.
Run the full sequence on the target CPU instead.
smp_call_function_single() cannot be used for the sequence: it would wait
for up to 15ms in interrupt context. Instead, use smp_call_on_cpu(), which
can wait and cannot migrate to another CPU.
Keep using smp_call_function_single() to clear the directed interrupt on a
CPU. It does not wait for acknowledgment and can therefore run in interrupt
context. Clearing is then the only remote configuration left. Replace
dpti_config_ipi() with dpti_clear_ipi(), which takes no setting.
Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
---
drivers/thermal/intel/therm_throt.c | 63 +++++++++++++++++--------------------
1 file changed, 29 insertions(+), 34 deletions(-)
diff --git a/drivers/thermal/intel/therm_throt.c b/drivers/thermal/intel/therm_throt.c
index 72dabffe3b2f..e6ce443c0a9d 100644
--- a/drivers/thermal/intel/therm_throt.c
+++ b/drivers/thermal/intel/therm_throt.c
@@ -514,9 +514,14 @@ static void dpti_config_this_cpu(bool enable)
wrmsrq(MSR_IA32_THERM_INTERRUPT, msr_val);
}
-static void dpti_config_ipi(void *info)
+static void dpti_clear_ipi(void *unused)
{
- dpti_config_this_cpu(*((bool *)info));
+ dpti_config_this_cpu(false);
+}
+
+static void dpti_clear_on_cpu(unsigned int cpu)
+{
+ smp_call_function_single(cpu, dpti_clear_ipi, NULL, true);
}
/* The unused argument matches the smp_call_on_cpu() callback signature. */
@@ -538,6 +543,18 @@ static int dpti_program_this_cpu(void *unused)
return ret;
}
+/*
+ * MSR_IA32_PACKAGE_THERM_STATUS is package-scoped, so the acknowledgment must
+ * be polled on the same package. Run a worker bound to @cpu: it cannot be
+ * migrated and may wait for the acknowledgment for as long as 15ms.
+ */
+static int dpti_program_on_cpu(unsigned int cpu)
+{
+ lockdep_assert_cpus_held();
+
+ return smp_call_on_cpu(cpu, dpti_program_this_cpu, NULL, false);
+}
+
/**
* struct dpti_pkg - Per-package DPTI state
* @owner: CPU currently programmed to receive the package-level
@@ -619,7 +636,6 @@ static bool dpti_cpu_is_owner(unsigned int cpu)
*/
static void dpti_clear_all(void)
{
- bool enable = false;
int i;
if (!dpti_supported())
@@ -630,11 +646,12 @@ static void dpti_clear_all(void)
* DPTI down.
*/
for (i = 0; i < topology_max_packages(); i++) {
- if (dpti_pkgs[i].owner == nr_cpu_ids)
+ unsigned int owner = dpti_pkgs[i].owner;
+
+ if (owner == nr_cpu_ids)
continue;
- smp_call_function_single(dpti_pkgs[i].owner, dpti_config_ipi,
- &enable, true);
+ dpti_clear_on_cpu(owner);
}
}
@@ -657,7 +674,7 @@ static int dpti_online(unsigned int cpu)
if (dpti_pkgs[pkg_id].owner != nr_cpu_ids)
return 0;
- ret = dpti_program_this_cpu(NULL);
+ ret = dpti_program_on_cpu(cpu);
if (ret)
return ret;
@@ -669,7 +686,6 @@ static int dpti_online(unsigned int cpu)
static void dpti_offline(unsigned int cpu)
{
unsigned int new_cpu;
- bool enable;
u16 pkg_id;
if (!dpti_supported())
@@ -691,35 +707,14 @@ static void dpti_offline(unsigned int cpu)
* offline.
*/
new_cpu = cpumask_any_but(topology_core_cpumask(cpu), cpu);
- if (new_cpu < nr_cpu_ids) {
- enable = true;
- thermal_clear_package_intr_status(PACKAGE_LEVEL,
- PACKAGE_THERM_STATUS_DPTI_ACK);
-
- /*
- * We are here via CPU hotplug. Since we are holding the
- * cpu_hotplug_lock, @new_cpu cannot go offline and interrupts
- * are enabled, so the SMP function call is safe.
- *
- * The syscore suspend callback runs with interrupts disabled,
- * but it does not reach this path because all the secondary
- * CPUs are offline.
- */
- smp_call_function_single(new_cpu, dpti_config_ipi, &enable,
- true);
- }
/*
- * If hardware does not acknowledge the directed interrupt setup on
- * @new_cpu, disable the redirection. Since no other CPU is configured
- * to receive the package-level interrupt, all CPUs in the package will
- * receive it.
+ * dpti_program_on_cpu() undoes a setup that the hardware does not
+ * acknowledge on @new_cpu. With @cpu cleared below, no CPU is then
+ * configured to receive the package-level interrupt: all CPUs in the
+ * package receive it.
*/
- enable = false;
- if (new_cpu < nr_cpu_ids && dpti_wait_for_ack()) {
- smp_call_function_single(new_cpu, dpti_config_ipi, &enable,
- true);
-
+ if (new_cpu < nr_cpu_ids && dpti_program_on_cpu(new_cpu)) {
pr_warn_once("Failed to redirect package thermal interrupt from CPU%u to CPU%u; reverting to broadcast\n",
cpu, new_cpu);
--
2.43.0
next prev 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 ` [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 ` Ricardo Neri [this message]
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-9-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®