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 06/13] thermal: intel: dpti: Introduce struct dpti_pkg for per-package state
Date: Mon, 09 Nov 2026 19:36:33 -0800	[thread overview]
Message-ID: <20261109-dpti-custom-cpu-v1-6-ead8e2d2067e@linux.intel.com> (raw)
In-Reply-To: <20261109-dpti-custom-cpu-v1-0-ead8e2d2067e@linux.intel.com>

The array dpti_owner_cpus[] tracks the CPU that owns the directed
package-level thermal interrupt (DPTI) for each package.

A sticky, per-package owner CPU that the user selects through sysfs will
need a field of its own. Rather than adding a second parallel array, wrap
the state in a struct. Future members can be added in one place without
churning every call site again.

No functional change intended.

Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
---
 drivers/thermal/intel/therm_throt.c | 38 ++++++++++++++++++++++---------------
 1 file changed, 23 insertions(+), 15 deletions(-)

diff --git a/drivers/thermal/intel/therm_throt.c b/drivers/thermal/intel/therm_throt.c
index ac719e2407ac..a0a3842e2760 100644
--- a/drivers/thermal/intel/therm_throt.c
+++ b/drivers/thermal/intel/therm_throt.c
@@ -515,12 +515,21 @@ static void dpti_config(void *info)
 	wrmsrq(MSR_IA32_THERM_INTERRUPT, msr_val);
 }
 
+/**
+ * struct dpti_pkg - Per-package DPTI state
+ * @owner:	CPU currently programmed to receive the package-level
+ *		interrupt, or nr_cpu_ids when the package has no owner.
+ */
+struct dpti_pkg {
+	unsigned int owner;
+};
+
 /*
  * Accessed from CPU hotplug callbacks and from code that runs while CPU
  * hotplug is inactive: the init and cleanup paths as well as syscore callbacks.
  * No extra locking needed.
  */
-static unsigned int *dpti_owner_cpus;
+static struct dpti_pkg *dpti_pkgs;
 
 /*
  * Set by the syscore shutdown callback before it disables the directed
@@ -541,7 +550,7 @@ static bool dpti_supported(void)
 	if (!boot_cpu_has(X86_FEATURE_DPTI))
 		return false;
 
-	if (!dpti_owner_cpus)
+	if (!dpti_pkgs)
 		return false;
 
 	return true;
@@ -562,14 +571,14 @@ static void dpti_clear_all(void)
 		return;
 
 	/*
-	 * No need to reset the owners: callers free dpti_owner_cpus or have shut
+	 * No need to reset the owners: callers free dpti_pkgs[] or have shut
 	 * DPTI down.
 	 */
 	for (i = 0; i < topology_max_packages(); i++) {
-		if (dpti_owner_cpus[i] == nr_cpu_ids)
+		if (dpti_pkgs[i].owner == nr_cpu_ids)
 			continue;
 
-		smp_call_function_single(dpti_owner_cpus[i], dpti_config,
+		smp_call_function_single(dpti_pkgs[i].owner, dpti_config,
 					 &enable, true);
 	}
 }
@@ -590,7 +599,7 @@ static int dpti_online(unsigned int cpu)
 		return 0;
 
 	/* Another CPU in this package already owns the directed interrupt. */
-	if (dpti_owner_cpus[pkg_id] != nr_cpu_ids)
+	if (dpti_pkgs[pkg_id].owner != nr_cpu_ids)
 		return 0;
 
 	thermal_clear_package_intr_status(PACKAGE_LEVEL,
@@ -598,7 +607,7 @@ static int dpti_online(unsigned int cpu)
 
 	dpti_config(&enable);
 	if (!dpti_wait_for_ack()) {
-		dpti_owner_cpus[pkg_id] = cpu;
+		dpti_pkgs[pkg_id].owner = cpu;
 		return 0;
 	}
 
@@ -626,7 +635,7 @@ static void dpti_offline(unsigned int cpu)
 		return;
 
 	/* Not the owner of the directed interrupt. */
-	if (dpti_owner_cpus[pkg_id] != cpu)
+	if (dpti_pkgs[pkg_id].owner != cpu)
 		return;
 
 	/*
@@ -673,7 +682,7 @@ static void dpti_offline(unsigned int cpu)
 	 */
 	dpti_config(&enable);
 
-	dpti_owner_cpus[pkg_id] = (new_cpu < nr_cpu_ids) ? new_cpu : nr_cpu_ids;
+	dpti_pkgs[pkg_id].owner = (new_cpu < nr_cpu_ids) ? new_cpu : nr_cpu_ids;
 }
 
 /*
@@ -720,13 +729,12 @@ static __init void dpti_init(void)
 	if (!boot_cpu_has(X86_FEATURE_DPTI))
 		return;
 
-	dpti_owner_cpus = kmalloc_objs(*dpti_owner_cpus,
-				       topology_max_packages());
-	if (!dpti_owner_cpus)
+	dpti_pkgs = kmalloc_objs(*dpti_pkgs, topology_max_packages());
+	if (!dpti_pkgs)
 		return;
 
 	for (i = 0; i < topology_max_packages(); i++)
-		dpti_owner_cpus[i] = nr_cpu_ids;
+		dpti_pkgs[i].owner = nr_cpu_ids;
 
 	register_syscore(&dpti_syscore);
 }
@@ -738,8 +746,8 @@ static void dpti_cleanup(void)
 
 	unregister_syscore(&dpti_syscore);
 	dpti_clear_all();
-	kfree(dpti_owner_cpus);
-	dpti_owner_cpus = NULL;
+	kfree(dpti_pkgs);
+	dpti_pkgs = NULL;
 }
 
 /* Add/Remove thermal_throttle interface for CPU device: */

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