Skip to content

Commit 2037da5

Browse files
rafaeljwgregkh
authored andcommitted
cpufreq: conservative: Take limits changes into account properly
commit da5e79b upstream. If the policy limits change between invocations of cs_dbs_update(), the requested frequency value stored in dbs_info may not be updated and the function may use a stale value of it next time. Moreover, if idle periods are takem into account by cs_dbs_update(), the requested frequency value stored in dbs_info may be below the min policy limit, which is incorrect. To fix these problems, always update the requested frequency value in dbs_info along with the local copy of it when the previous requested frequency is beyond the policy limits and avoid decreasing the requested frequency below the min policy limit when taking idle periods into account. Fixes: abb6627 (cpufreq: conservative: Fix next frequency selection) Fixes: 00bfe05 (cpufreq: conservative: Decrease frequency faster for deferred updates) Reported-by: Waldemar Rymarkiewicz <[email protected]> Cc: All applicable <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]> Acked-by: Waldemar Rymarkiewicz <[email protected]> Acked-by: Viresh Kumar <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 1ea5c40 commit 2037da5

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/cpufreq/cpufreq_conservative.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,10 @@ static unsigned int cs_dbs_update(struct cpufreq_policy *policy)
8080
* changed in the meantime, so fall back to current frequency in that
8181
* case.
8282
*/
83-
if (requested_freq > policy->max || requested_freq < policy->min)
83+
if (requested_freq > policy->max || requested_freq < policy->min) {
8484
requested_freq = policy->cur;
85+
dbs_info->requested_freq = requested_freq;
86+
}
8587

8688
freq_step = get_freq_step(cs_tuners, policy);
8789

@@ -92,7 +94,7 @@ static unsigned int cs_dbs_update(struct cpufreq_policy *policy)
9294
if (policy_dbs->idle_periods < UINT_MAX) {
9395
unsigned int freq_steps = policy_dbs->idle_periods * freq_step;
9496

95-
if (requested_freq > freq_steps)
97+
if (requested_freq > policy->min + freq_steps)
9698
requested_freq -= freq_steps;
9799
else
98100
requested_freq = policy->min;

0 commit comments

Comments
 (0)