mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v1] cpufreq: Return current frequency when frequency table is unavailable
@ 2025-08-14  8:52 Zihuan Zhang
  2025-08-14  9:02 ` Viresh Kumar
  2025-08-18  6:54 ` kernel test robot
  0 siblings, 2 replies; 6+ messages in thread
From: Zihuan Zhang @ 2025-08-14  8:52 UTC (permalink / raw)
  To: rafael J . wysocki, Viresh Kumar
  Cc: zhenglifeng, linux-pm, linux-kernel, Zihuan Zhang

In cases where the CPU frequency table (freq_table) is not available,
the __resolve_freq() function will now return the current frequency
(policy->cur) instead of the requested target frequency. This ensures
that the system doesn't return an invalid or uninitialized frequency
value when frequency scaling is not supported or not initialized.

This change improves the stability of the frequency scaling logic when
the CPU frequency table is not populated, preventing errors related
to unavailable frequency tables.

Signed-off-by: Zihuan Zhang <zhangzihuan@kylinos.cn>
---
 drivers/cpufreq/cpufreq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index fc7eace8b65b..ca9b7807a288 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -502,7 +502,7 @@ static unsigned int __resolve_freq(struct cpufreq_policy *policy,
 	target_freq = clamp_val(target_freq, min, max);
 
 	if (!policy->freq_table)
-		return target_freq;
+		return policy->cur;
 
 	idx = cpufreq_frequency_table_target(policy, target_freq, min, max, relation);
 	policy->cached_resolved_idx = idx;
-- 
2.25.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-08-18  6:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-08-14  8:52 [PATCH v1] cpufreq: Return current frequency when frequency table is unavailable Zihuan Zhang
2025-08-14  9:02 ` Viresh Kumar
2025-08-14  9:24   ` Zihuan Zhang
2025-08-14  9:31     ` Viresh Kumar
2025-08-14  9:57       ` Zihuan Zhang
2025-08-18  6:54 ` kernel test robot

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®