cpufreq: record CPUFREQ stat for fast switch path

Original CPUFREQ stat recording is only for slow path, add it for
fast path.

Change-Id: I6f66cd686e6e96c4381db332600da60cbd399033
Signed-off-by: yonghaih <yonghaih@codeaurora.org>
[shalagra@codeaurora.org: Fixed trivial merge conflicts in port to 5.x]
Signed-off-by: Shaleen Agrawal <shalagra@codeaurora.org>
This commit is contained in:
yonghaih 2019-08-22 13:48:20 +08:00 committed by Jonathan Avila
parent dcb879fbf7
commit 54aaec6d49
2 changed files with 9 additions and 11 deletions

View File

@ -2057,8 +2057,10 @@ unsigned int cpufreq_driver_fast_switch(struct cpufreq_policy *policy,
target_freq = clamp_val(target_freq, policy->min, policy->max);
ret = cpufreq_driver->fast_switch(policy, target_freq);
if (ret)
if (ret) {
cpufreq_times_record_transition(policy, ret);
cpufreq_stats_record_transition(policy, ret);
}
return ret;
}

View File

@ -55,13 +55,11 @@ static ssize_t show_time_in_state(struct cpufreq_policy *policy, char *buf)
struct cpufreq_stats *stats = policy->stats;
ssize_t len = 0;
int i;
unsigned long flags;
if (policy->fast_switch_enabled)
return 0;
spin_lock(&stats->lock);
spin_lock_irqsave(&stats->lock, flags);
cpufreq_stats_update(stats);
spin_unlock(&stats->lock);
spin_unlock_irqrestore(&stats->lock, flags);
for (i = 0; i < stats->state_num; i++) {
len += sprintf(buf + len, "%u %llu\n", stats->freq_table[i],
@ -87,9 +85,6 @@ static ssize_t show_trans_table(struct cpufreq_policy *policy, char *buf)
ssize_t len = 0;
int i, j;
if (policy->fast_switch_enabled)
return 0;
len += snprintf(buf + len, PAGE_SIZE - len, " From : To\n");
len += snprintf(buf + len, PAGE_SIZE - len, " : ");
for (i = 0; i < stats->state_num; i++) {
@ -227,6 +222,7 @@ void cpufreq_stats_record_transition(struct cpufreq_policy *policy,
{
struct cpufreq_stats *stats = policy->stats;
int old_index, new_index;
unsigned long flags;
if (!stats) {
pr_debug("%s: No stats found\n", __func__);
@ -240,11 +236,11 @@ void cpufreq_stats_record_transition(struct cpufreq_policy *policy,
if (old_index == -1 || new_index == -1 || old_index == new_index)
return;
spin_lock(&stats->lock);
spin_lock_irqsave(&stats->lock, flags);
cpufreq_stats_update(stats);
stats->last_index = new_index;
stats->trans_table[old_index * stats->max_state + new_index]++;
stats->total_trans++;
spin_unlock(&stats->lock);
spin_unlock_irqrestore(&stats->lock, flags);
}