|
@@ -277,7 +277,7 @@ static void cpufreq_stats_update_policy_cpu(struct cpufreq_policy *policy)
|
|
|
static int cpufreq_stat_notifier_policy(struct notifier_block *nb,
|
|
|
unsigned long val, void *data)
|
|
|
{
|
|
|
- int ret;
|
|
|
+ int ret = 0;
|
|
|
struct cpufreq_policy *policy = data;
|
|
|
struct cpufreq_frequency_table *table;
|
|
|
unsigned int cpu = policy->cpu;
|
|
@@ -287,15 +287,21 @@ static int cpufreq_stat_notifier_policy(struct notifier_block *nb,
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
- if (val != CPUFREQ_NOTIFY)
|
|
|
- return 0;
|
|
|
table = cpufreq_frequency_get_table(cpu);
|
|
|
if (!table)
|
|
|
return 0;
|
|
|
- ret = cpufreq_stats_create_table(policy, table);
|
|
|
- if (ret)
|
|
|
- return ret;
|
|
|
- return 0;
|
|
|
+
|
|
|
+ if (val == CPUFREQ_CREATE_POLICY)
|
|
|
+ ret = cpufreq_stats_create_table(policy, table);
|
|
|
+ else if (val == CPUFREQ_REMOVE_POLICY) {
|
|
|
+ /* This might already be freed by cpu hotplug notifier */
|
|
|
+ if (per_cpu(cpufreq_stats_table, cpu)) {
|
|
|
+ cpufreq_stats_free_sysfs(cpu);
|
|
|
+ cpufreq_stats_free_table(cpu);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return ret;
|
|
|
}
|
|
|
|
|
|
static int cpufreq_stat_notifier_trans(struct notifier_block *nb,
|
|
@@ -340,6 +346,10 @@ static int cpufreq_stat_cpu_callback(struct notifier_block *nfb,
|
|
|
{
|
|
|
unsigned int cpu = (unsigned long)hcpu;
|
|
|
|
|
|
+ /* Don't free/allocate stats during suspend/resume */
|
|
|
+ if (action & CPU_TASKS_FROZEN)
|
|
|
+ return 0;
|
|
|
+
|
|
|
switch (action) {
|
|
|
case CPU_DOWN_PREPARE:
|
|
|
cpufreq_stats_free_sysfs(cpu);
|