Message ID | 20230908031614.2262451-1-liaochang1@huawei.com |
---|---|
State | New |
Headers | show |
Series | cpufreq: ondemand: Allow powersave_bias_target() to bail out if freq_table is unsorted | expand |
On 08-09-23, 03:16, Liao Chang wrote: > The generic_powersave_bias_target() function uses the > cpufreq_table_find_index_[h/l]() functions to calculate the frequency > bounds for the powersave bias target. However, these two functions only > work on sorted frequency tables. Therefore, the > generic_powersave_bias_target() function should bail out early if the > frequency table is unsorted. > > Signed-off-by: Liao Chang <liaochang1@huawei.com> > --- > drivers/cpufreq/cpufreq_ondemand.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c > index c52d19d67557..f7ff94f71395 100644 > --- a/drivers/cpufreq/cpufreq_ondemand.c > +++ b/drivers/cpufreq/cpufreq_ondemand.c > @@ -71,7 +71,8 @@ static unsigned int generic_powersave_bias_target(struct cpufreq_policy *policy, > struct od_dbs_tuners *od_tuners = dbs_data->tuners; > struct cpufreq_frequency_table *freq_table = policy->freq_table; > > - if (!freq_table) { > + if (!freq_table || > + WARN_ON_ONCE(policy->freq_table_sorted == CPUFREQ_TABLE_UNSORTED)) { > dbs_info->freq_lo = 0; > dbs_info->freq_lo_delay_us = 0; > return freq_next; Shouldn't we make the governor use the generic functions then ? cpufreq_frequency_table_target() ? > -- > 2.34.1
diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c index c52d19d67557..f7ff94f71395 100644 --- a/drivers/cpufreq/cpufreq_ondemand.c +++ b/drivers/cpufreq/cpufreq_ondemand.c @@ -71,7 +71,8 @@ static unsigned int generic_powersave_bias_target(struct cpufreq_policy *policy, struct od_dbs_tuners *od_tuners = dbs_data->tuners; struct cpufreq_frequency_table *freq_table = policy->freq_table; - if (!freq_table) { + if (!freq_table || + WARN_ON_ONCE(policy->freq_table_sorted == CPUFREQ_TABLE_UNSORTED)) { dbs_info->freq_lo = 0; dbs_info->freq_lo_delay_us = 0; return freq_next;
The generic_powersave_bias_target() function uses the cpufreq_table_find_index_[h/l]() functions to calculate the frequency bounds for the powersave bias target. However, these two functions only work on sorted frequency tables. Therefore, the generic_powersave_bias_target() function should bail out early if the frequency table is unsorted. Signed-off-by: Liao Chang <liaochang1@huawei.com> --- drivers/cpufreq/cpufreq_ondemand.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)