From 54aaec6d4997963db3054e60df21a05d0a2385b6 Mon Sep 17 00:00:00 2001 From: yonghaih Date: Thu, 22 Aug 2019 13:48:20 +0800 Subject: [PATCH] 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 [shalagra@codeaurora.org: Fixed trivial merge conflicts in port to 5.x] Signed-off-by: Shaleen Agrawal --- drivers/cpufreq/cpufreq.c | 4 +++- drivers/cpufreq/cpufreq_stats.c | 16 ++++++---------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 9a2a51ec68b4..0516721758a1 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -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; } diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c index f9bcf0f3ea30..0dce72b3fd91 100644 --- a/drivers/cpufreq/cpufreq_stats.c +++ b/drivers/cpufreq/cpufreq_stats.c @@ -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); }