public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: Linux PM <linux-pm@vger.kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Subject: [PATCH v1 6/6] cpufreq: intel_pstate: Update the maximum CPU frequency consistently
Date: Mon, 25 Mar 2024 18:06:09 +0100	[thread overview]
Message-ID: <9269494.CDJkKcVGEf@kreacher> (raw)
In-Reply-To: <13494237.uLZWGnKmhe@kreacher>

From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

There are 3 places at which the maximum CPU frequency may change,
store_no_turbo(), intel_pstate_update_limits() (when called by the
cpufreq core) and intel_pstate_notify_work() (when handling a HWP
change notification).  Currently, cpuinfo.max_freq is only updated by
store_no_turbo(), although it principle it may be necessary to update
it at the other 2 places too.

Make all of them mutually consistent.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/cpufreq/intel_pstate.c |   23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

Index: linux-pm/drivers/cpufreq/intel_pstate.c
===================================================================
--- linux-pm.orig/drivers/cpufreq/intel_pstate.c
+++ linux-pm/drivers/cpufreq/intel_pstate.c
@@ -1153,18 +1153,32 @@ static void intel_pstate_update_policies
 static void __intel_pstate_update_max_freq(struct cpudata *cpudata,
 					   struct cpufreq_policy *policy)
 {
+	intel_pstate_get_hwp_cap(cpudata);
+
 	policy->cpuinfo.max_freq = READ_ONCE(global.no_turbo) ?
 			cpudata->pstate.max_freq : cpudata->pstate.turbo_freq;
+
 	refresh_frequency_limits(policy);
 }
 
 static void intel_pstate_update_limits(unsigned int cpu)
 {
-	mutex_lock(&intel_pstate_driver_lock);
+	struct cpufreq_policy *policy = cpufreq_cpu_acquire(cpu);
 
-	cpufreq_update_policy(cpu);
+	if (!policy)
+		return;
 
-	mutex_unlock(&intel_pstate_driver_lock);
+	__intel_pstate_update_max_freq(all_cpu_data[cpu], policy);
+
+	cpufreq_cpu_release(policy);
+}
+
+static void intel_pstate_update_limits_for_all(void)
+{
+	int cpu;
+
+	for_each_possible_cpu(cpu)
+		intel_pstate_update_limits(cpu);
 }
 
 /************************** sysfs begin ************************/
@@ -1311,7 +1325,7 @@ static ssize_t store_no_turbo(struct kob
 
 	mutex_unlock(&intel_pstate_limits_lock);
 
-	intel_pstate_update_policies();
+	intel_pstate_update_limits_for_all();
 	arch_set_max_freq_ratio(no_turbo);
 
 unlock_driver:
@@ -1595,7 +1609,6 @@ static void intel_pstate_notify_work(str
 	struct cpufreq_policy *policy = cpufreq_cpu_acquire(cpudata->cpu);
 
 	if (policy) {
-		intel_pstate_get_hwp_cap(cpudata);
 		__intel_pstate_update_max_freq(cpudata, policy);
 
 		cpufreq_cpu_release(policy);




  parent reply	other threads:[~2024-03-25 17:06 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-25 17:00 [PATCH v1 0/6] intel_pstate: Turbo disabled handling rework Rafael J. Wysocki
2024-03-25 17:01 ` [PATCH v1 1/6] cpufreq: intel_pstate: Fold intel_pstate_max_within_limits() into caller Rafael J. Wysocki
2024-04-01 20:06   ` srinivas pandruvada
2024-03-25 17:02 ` [PATCH v1 2/6] cpufreq: intel_pstate: Do not update global.turbo_disabled after initialization Rafael J. Wysocki
2024-06-02  3:21   ` Xi Ruoyao
2024-06-02  4:03     ` srinivas pandruvada
2024-06-02  4:25       ` Xi Ruoyao
2024-06-02 13:40         ` srinivas pandruvada
2024-06-02 16:07           ` Xi Ruoyao
2024-06-02 23:11             ` srinivas pandruvada
2024-06-03 13:12               ` Xi Ruoyao
2024-06-03 17:11                 ` srinivas pandruvada
2024-06-03 17:44                   ` Xi Ruoyao
2024-06-03 18:32                     ` Rafael J. Wysocki
2024-06-03 18:47                       ` srinivas pandruvada
2024-06-04  4:10                         ` srinivas pandruvada
2024-06-04  4:31                         ` srinivas pandruvada
2024-06-04  9:30                           ` Xi Ruoyao
2024-06-04 10:29                             ` srinivas pandruvada
2024-06-04 10:32                               ` Xi Ruoyao
2024-06-04 16:41                                 ` srinivas pandruvada
2024-06-04 16:46                                   ` Rafael J. Wysocki
2024-06-04 16:56                                     ` srinivas pandruvada
2024-06-05  5:21                                       ` Xi Ruoyao
2024-06-05 12:05                                         ` srinivas pandruvada
2024-06-07 15:04                                           ` Rafael J. Wysocki
2024-06-07 15:18                                             ` srinivas pandruvada
2024-06-08  9:30                                               ` Xi Ruoyao
2024-03-25 17:03 ` [PATCH v1 3/6] cpufreq: intel_pstate: Rearrange show_no_turbo() and store_no_turbo() Rafael J. Wysocki
2024-03-25 17:04 ` [PATCH v1 4/6] cpufreq: intel_pstate: Read global.no_turbo under READ_ONCE() Rafael J. Wysocki
2024-03-25 17:05 ` [PATCH v1 5/6] cpufreq: intel_pstate: Replace three global.turbo_disabled checks Rafael J. Wysocki
2024-03-25 17:06 ` Rafael J. Wysocki [this message]
2024-03-27 18:08   ` [PATCH v1 6/6] cpufreq: intel_pstate: Update the maximum CPU frequency consistently srinivas pandruvada
2024-03-28 11:26     ` Rafael J. Wysocki
2024-03-28 19:02   ` [PATCH v1.1 " Rafael J. Wysocki
2024-04-02  8:46 ` [PATCH v1 0/6] intel_pstate: Turbo disabled handling rework srinivas pandruvada

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=9269494.CDJkKcVGEf@kreacher \
    --to=rjw@rjwysocki.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --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