mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Riwen Lu <luriwen@hotmail.com>
To: rafael@kernel.org, viresh.kumar@linaro.org
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
	Riwen Lu <luriwen@kylinos.cn>
Subject: [PATCH v2] cpufreq/cppc: Take policy->cur into judge when set target
Date: Wed, 29 May 2024 11:22:26 +0800	[thread overview]
Message-ID: <TYCP286MB24861BA890594C119892FB3DB1F22@TYCP286MB2486.JPNP286.PROD.OUTLOOK.COM> (raw)

From: Riwen Lu <luriwen@kylinos.cn>

There is a case that desired_perf is exactly the same with the old perf,
but the actual current freq is not. Add a judgment condition to return
only when the three values are exactly the same.

This happened in S3 while the cpufreq governor is set to powersave.
During resume process, the CPU frequency is adjusted to the highest
perf. For the booting CPU, there's a warning that "CPU frequency out of
sync:", because the policy->cur is the lowest_perf while the actual
current frequency is the highest_perf that obtained via
cppc_cpufreq_get_rate(), then set policy->cur to highest_perf. The
governor->limits() intent to configure the CPU frequency to lowest_perf
and the governor->target() returned because the desired_perf is equal to
cpu->perf_ctrls.desired_perf leaving the actual current frequency and
policy->cur are remain the highest_perf. Add a judgement that if
policy->cur is the same with desired_perf to decide whther to return.

Signed-off-by: Riwen Lu <luriwen@kylinos.cn>

---
v1 -> v2:
 - Update commit message and email.
---
 drivers/cpufreq/cppc_cpufreq.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/cpufreq/cppc_cpufreq.c b/drivers/cpufreq/cppc_cpufreq.c
index 15f1d41920a3..802f7c7c0ad8 100644
--- a/drivers/cpufreq/cppc_cpufreq.c
+++ b/drivers/cpufreq/cppc_cpufreq.c
@@ -296,7 +296,8 @@ static int cppc_cpufreq_set_target(struct cpufreq_policy *policy,
 
 	desired_perf = cppc_khz_to_perf(&cpu_data->perf_caps, target_freq);
 	/* Return if it is exactly the same perf */
-	if (desired_perf == cpu_data->perf_ctrls.desired_perf)
+	if (desired_perf == cpu_data->perf_ctrls.desired_perf &&
+	    desired_perf == policy->cur)
 		return ret;
 
 	cpu_data->perf_ctrls.desired_perf = desired_perf;
-- 
2.25.1


             reply	other threads:[~2024-05-29  3:22 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-29  3:22 Riwen Lu [this message]
2024-05-29  5:36 ` Viresh Kumar
2024-05-29  6:53   ` Riwen Lu
2024-05-29  7:12     ` Viresh Kumar
2024-05-30  1:06       ` Riwen Lu
2024-05-30  5:56         ` Viresh Kumar
2024-05-30  6:02           ` Riwen Lu
2024-05-30  6:16             ` Viresh Kumar
2024-05-30 11:08               ` [PATCH v3] cpufreq/cppc: Remove the desired_perf compare " Riwen Lu
2024-06-06  9:07                 ` Viresh Kumar
2024-06-11  8:54                   ` Ionela Voinescu
2024-06-11  9:10                     ` Viresh Kumar
2024-06-12  2:52                       ` Riwen Lu
2024-06-12  6:24                         ` Viresh Kumar
2024-06-12  6:26                           ` Viresh Kumar
2024-06-14 12:12                           ` Riwen Lu
2024-06-12  9:08                 ` Pierre Gondois

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=TYCP286MB24861BA890594C119892FB3DB1F22@TYCP286MB2486.JPNP286.PROD.OUTLOOK.COM \
    --to=luriwen@hotmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=luriwen@kylinos.cn \
    --cc=rafael@kernel.org \
    --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®