@@ -12,10 +12,11 @@
#include <linux/cpu.h>
#include <linux/cpufreq.h>
#include <linux/module.h>
+#include <linux/mutex.h>
#include <linux/slab.h>
#include <linux/cputime.h>
-static spinlock_t cpufreq_stats_lock;
+static DEFINE_MUTEX(cpufreq_stats_lock);
struct cpufreq_stats {
unsigned int total_trans;
@@ -39,12 +40,12 @@ static int cpufreq_stats_update(struct cpufreq_stats *stat)
{
unsigned long long cur_time = get_jiffies_64();
- spin_lock(&cpufreq_stats_lock);
+ mutex_lock(&cpufreq_stats_lock);
if (stat->time_in_state)
stat->time_in_state[stat->last_index] +=
cur_time - stat->last_time;
stat->last_time = cur_time;
- spin_unlock(&cpufreq_stats_lock);
+ mutex_unlock(&cpufreq_stats_lock);
return 0;
}
@@ -218,10 +219,10 @@ static int __cpufreq_stats_create_table(struct cpufreq_policy *policy)
stat->freq_table[i++] = pos->frequency;
stat->state_num = i;
- spin_lock(&cpufreq_stats_lock);
+ mutex_lock(&cpufreq_stats_lock);
stat->last_time = get_jiffies_64();
stat->last_index = freq_table_get_index(stat, policy->cur);
- spin_unlock(&cpufreq_stats_lock);
+ mutex_unlock(&cpufreq_stats_lock);
policy->stats_data = stat;
ret = sysfs_create_group(&policy->kobj, &stats_attr_group);
@@ -298,13 +299,13 @@ static int cpufreq_stat_notifier_trans(struct notifier_block *nb,
cpufreq_stats_update(stat);
- spin_lock(&cpufreq_stats_lock);
+ mutex_lock(&cpufreq_stats_lock);
stat->last_index = new_index;
#ifdef CONFIG_CPU_FREQ_STAT_DETAILS
stat->trans_table[old_index * stat->max_state + new_index]++;
#endif
stat->total_trans++;
- spin_unlock(&cpufreq_stats_lock);
+ mutex_unlock(&cpufreq_stats_lock);
cpufreq_cpu_put(policy);
return 0;
}
@@ -322,7 +323,6 @@ static int __init cpufreq_stats_init(void)
int ret;
unsigned int cpu;
- spin_lock_init(&cpufreq_stats_lock);
ret = cpufreq_register_notifier(¬ifier_policy_block,
CPUFREQ_POLICY_NOTIFIER);
if (ret)