mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hugo Sales <hugo@hsal.es>
To: "Rafael J. Wysocki" <rafael@kernel.org>,
	Viresh Kumar <viresh.kumar@linaro.org>
Cc: Len Brown <lenb@kernel.org>, Zhang Rui <rui.zhang@intel.com>,
	Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>,
	Jonathan Corbet <corbet@lwn.net>,
	Shuah Khan <skhan@linuxfoundation.org>,
	"Ashton A." <me@ashtonantila.com>,
	linux-pm@vger.kernel.org, linux-acpi@vger.kernel.org,
	linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [RFC PATCH 3/4] ACPI: processor: thermal: Factor out the thermal_req update
Date: Sun,  1 Nov 2026 18:58:06 +0000	[thread overview]
Message-ID: <20261101185807.112449-4-hugo@hsal.es> (raw)
In-Reply-To: <20261101185807.112449-1-hugo@hsal.es>

Split the cap computation and the thermal_req update out of
cpufreq_update_thermal_limit() into cpufreq_update_thermal_req(), which
takes the policy and the step as arguments. This prepares for
recomputing the cap on CPUFREQ_UPDATE_CPUINFO, where the notifier
passes the policy and the step is stored for each CPU

No functional change

Signed-off-by: Hugo Sales <hugo@hsal.es>
---
 drivers/acpi/processor_thermal.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/drivers/acpi/processor_thermal.c b/drivers/acpi/processor_thermal.c
index 11036f0d2b942..25c4b0ad64e36 100644
--- a/drivers/acpi/processor_thermal.c
+++ b/drivers/acpi/processor_thermal.c
@@ -88,23 +88,30 @@ static int cpufreq_get_cur_state(unsigned int cpu)
 	return reduction_step(cpu);
 }
 
-static bool cpufreq_update_thermal_limit(unsigned int cpu, struct acpi_processor *pr)
+static void cpufreq_update_thermal_req(struct cpufreq_policy *policy,
+				       struct acpi_processor *pr,
+				       unsigned int step)
 {
 	unsigned long max_freq;
 	int ret;
 
-	struct cpufreq_policy *policy __free(put_cpufreq_policy) = cpufreq_cpu_get(cpu);
-	if (!policy)
-		return false;
-
 	max_freq = (policy->cpuinfo.max_freq *
-		(100 - reduction_step(cpu) * cpufreq_thermal_reduction_pctg)) / 100;
+		(100 - step * cpufreq_thermal_reduction_pctg)) / 100;
 
 	ret = freq_qos_update_request(&pr->thermal_req, max_freq);
 	if (ret < 0) {
 		pr_warn("Failed to update thermal freq constraint: CPU%d (%d)\n",
 			pr->id, ret);
 	}
+}
+
+static bool cpufreq_update_thermal_limit(unsigned int cpu, struct acpi_processor *pr)
+{
+	struct cpufreq_policy *policy __free(put_cpufreq_policy) = cpufreq_cpu_get(cpu);
+	if (!policy)
+		return false;
+
+	cpufreq_update_thermal_req(policy, pr, reduction_step(cpu));
 
 	return true;
 }
-- 
2.56.0


  parent reply	other threads:[~2026-11-01 18:58 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-01 18:58 [RFC PATCH 0/4] ACPI: processor: thermal: Recompute the frequency cap when boost changes Hugo Sales
2026-11-01 18:58 ` [RFC PATCH 1/4] cpufreq: Add a CPUFREQ_UPDATE_CPUINFO policy notifier event Hugo Sales
2026-11-01 18:58 ` [RFC PATCH 2/4] cpufreq: intel_pstate: Send CPUFREQ_UPDATE_CPUINFO on max_freq changes Hugo Sales
2026-11-08  7:12   ` Ximing Zhang
2026-11-01 18:58 ` Hugo Sales [this message]
2026-11-01 18:58 ` [RFC PATCH 4/4] ACPI: processor: thermal: Recompute the frequency cap when boost changes Hugo Sales

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=20261101185807.112449-4-hugo@hsal.es \
    --to=hugo@hsal.es \
    --cc=corbet@lwn.net \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=me@ashtonantila.com \
    --cc=rafael@kernel.org \
    --cc=rui.zhang@intel.com \
    --cc=skhan@linuxfoundation.org \
    --cc=srinivas.pandruvada@linux.intel.com \
    --cc=viresh.kumar@linaro.org \
    /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®