diff options
author | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2013-02-15 07:59:07 -0500 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2013-02-15 07:59:07 -0500 |
commit | 4419fbd4b408c3a8634b3a8dd952055d0f0b601f (patch) | |
tree | dfa48db949d2b092a92a5adb3c070db6287a37be /drivers/cpufreq/cpufreq_stats.c | |
parent | 95ecb407699825278f4031f153dbbe0f0713ff28 (diff) | |
parent | 191e5edf96dc4939f5db0605cc65de9f4d88d155 (diff) |
Merge branch 'pm-cpufreq'
* pm-cpufreq: (55 commits)
cpufreq / intel_pstate: Fix 32 bit build
cpufreq: conservative: Fix typos in comments
cpufreq: ondemand: Fix typos in comments
cpufreq: exynos: simplify .init() for setting policy->cpus
cpufreq: kirkwood: Add a cpufreq driver for Marvell Kirkwood SoCs
cpufreq/x86: Add P-state driver for sandy bridge.
cpufreq_stats: do not remove sysfs files if frequency table is not present
cpufreq: Do not track governor name for scaling drivers with internal governors.
cpufreq: Only call cpufreq_out_of_sync() for driver that implement cpufreq_driver.target()
cpufreq: Retrieve current frequency from scaling drivers with internal governors
cpufreq: Fix locking issues
cpufreq: Create a macro for unlock_policy_rwsem{read,write}
cpufreq: Remove unused HOTPLUG_CPU code
cpufreq: governors: Fix WARN_ON() for multi-policy platforms
cpufreq: ondemand: Replace down_differential tuner with adj_up_threshold
cpufreq / stats: Get rid of CPUFREQ_STATDEVICE_ATTR
cpufreq: Don't check cpu_online(policy->cpu)
cpufreq: add imx6q-cpufreq driver
cpufreq: Don't remove sysfs link for policy->cpu
cpufreq: Remove unnecessary use of policy->shared_type
...
Diffstat (limited to 'drivers/cpufreq/cpufreq_stats.c')
-rw-r--r-- | drivers/cpufreq/cpufreq_stats.c | 49 |
1 files changed, 35 insertions, 14 deletions
diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c index 9d7732b81044..2fd779eb1ed1 100644 --- a/drivers/cpufreq/cpufreq_stats.c +++ b/drivers/cpufreq/cpufreq_stats.c | |||
@@ -24,12 +24,6 @@ | |||
24 | 24 | ||
25 | static spinlock_t cpufreq_stats_lock; | 25 | static spinlock_t cpufreq_stats_lock; |
26 | 26 | ||
27 | #define CPUFREQ_STATDEVICE_ATTR(_name, _mode, _show) \ | ||
28 | static struct freq_attr _attr_##_name = {\ | ||
29 | .attr = {.name = __stringify(_name), .mode = _mode, }, \ | ||
30 | .show = _show,\ | ||
31 | }; | ||
32 | |||
33 | struct cpufreq_stats { | 27 | struct cpufreq_stats { |
34 | unsigned int cpu; | 28 | unsigned int cpu; |
35 | unsigned int total_trans; | 29 | unsigned int total_trans; |
@@ -136,17 +130,17 @@ static ssize_t show_trans_table(struct cpufreq_policy *policy, char *buf) | |||
136 | return PAGE_SIZE; | 130 | return PAGE_SIZE; |
137 | return len; | 131 | return len; |
138 | } | 132 | } |
139 | CPUFREQ_STATDEVICE_ATTR(trans_table, 0444, show_trans_table); | 133 | cpufreq_freq_attr_ro(trans_table); |
140 | #endif | 134 | #endif |
141 | 135 | ||
142 | CPUFREQ_STATDEVICE_ATTR(total_trans, 0444, show_total_trans); | 136 | cpufreq_freq_attr_ro(total_trans); |
143 | CPUFREQ_STATDEVICE_ATTR(time_in_state, 0444, show_time_in_state); | 137 | cpufreq_freq_attr_ro(time_in_state); |
144 | 138 | ||
145 | static struct attribute *default_attrs[] = { | 139 | static struct attribute *default_attrs[] = { |
146 | &_attr_total_trans.attr, | 140 | &total_trans.attr, |
147 | &_attr_time_in_state.attr, | 141 | &time_in_state.attr, |
148 | #ifdef CONFIG_CPU_FREQ_STAT_DETAILS | 142 | #ifdef CONFIG_CPU_FREQ_STAT_DETAILS |
149 | &_attr_trans_table.attr, | 143 | &trans_table.attr, |
150 | #endif | 144 | #endif |
151 | NULL | 145 | NULL |
152 | }; | 146 | }; |
@@ -170,11 +164,13 @@ static int freq_table_get_index(struct cpufreq_stats *stat, unsigned int freq) | |||
170 | static void cpufreq_stats_free_table(unsigned int cpu) | 164 | static void cpufreq_stats_free_table(unsigned int cpu) |
171 | { | 165 | { |
172 | struct cpufreq_stats *stat = per_cpu(cpufreq_stats_table, cpu); | 166 | struct cpufreq_stats *stat = per_cpu(cpufreq_stats_table, cpu); |
167 | |||
173 | if (stat) { | 168 | if (stat) { |
169 | pr_debug("%s: Free stat table\n", __func__); | ||
174 | kfree(stat->time_in_state); | 170 | kfree(stat->time_in_state); |
175 | kfree(stat); | 171 | kfree(stat); |
172 | per_cpu(cpufreq_stats_table, cpu) = NULL; | ||
176 | } | 173 | } |
177 | per_cpu(cpufreq_stats_table, cpu) = NULL; | ||
178 | } | 174 | } |
179 | 175 | ||
180 | /* must be called early in the CPU removal sequence (before | 176 | /* must be called early in the CPU removal sequence (before |
@@ -183,8 +179,14 @@ static void cpufreq_stats_free_table(unsigned int cpu) | |||
183 | static void cpufreq_stats_free_sysfs(unsigned int cpu) | 179 | static void cpufreq_stats_free_sysfs(unsigned int cpu) |
184 | { | 180 | { |
185 | struct cpufreq_policy *policy = cpufreq_cpu_get(cpu); | 181 | struct cpufreq_policy *policy = cpufreq_cpu_get(cpu); |
186 | if (policy && policy->cpu == cpu) | 182 | |
183 | if (!cpufreq_frequency_get_table(cpu)) | ||
184 | return; | ||
185 | |||
186 | if (policy && !policy_is_shared(policy)) { | ||
187 | pr_debug("%s: Free sysfs stat\n", __func__); | ||
187 | sysfs_remove_group(&policy->kobj, &stats_attr_group); | 188 | sysfs_remove_group(&policy->kobj, &stats_attr_group); |
189 | } | ||
188 | if (policy) | 190 | if (policy) |
189 | cpufreq_cpu_put(policy); | 191 | cpufreq_cpu_put(policy); |
190 | } | 192 | } |
@@ -262,6 +264,19 @@ error_get_fail: | |||
262 | return ret; | 264 | return ret; |
263 | } | 265 | } |
264 | 266 | ||
267 | static void cpufreq_stats_update_policy_cpu(struct cpufreq_policy *policy) | ||
268 | { | ||
269 | struct cpufreq_stats *stat = per_cpu(cpufreq_stats_table, | ||
270 | policy->last_cpu); | ||
271 | |||
272 | pr_debug("Updating stats_table for new_cpu %u from last_cpu %u\n", | ||
273 | policy->cpu, policy->last_cpu); | ||
274 | per_cpu(cpufreq_stats_table, policy->cpu) = per_cpu(cpufreq_stats_table, | ||
275 | policy->last_cpu); | ||
276 | per_cpu(cpufreq_stats_table, policy->last_cpu) = NULL; | ||
277 | stat->cpu = policy->cpu; | ||
278 | } | ||
279 | |||
265 | static int cpufreq_stat_notifier_policy(struct notifier_block *nb, | 280 | static int cpufreq_stat_notifier_policy(struct notifier_block *nb, |
266 | unsigned long val, void *data) | 281 | unsigned long val, void *data) |
267 | { | 282 | { |
@@ -269,6 +284,12 @@ static int cpufreq_stat_notifier_policy(struct notifier_block *nb, | |||
269 | struct cpufreq_policy *policy = data; | 284 | struct cpufreq_policy *policy = data; |
270 | struct cpufreq_frequency_table *table; | 285 | struct cpufreq_frequency_table *table; |
271 | unsigned int cpu = policy->cpu; | 286 | unsigned int cpu = policy->cpu; |
287 | |||
288 | if (val == CPUFREQ_UPDATE_POLICY_CPU) { | ||
289 | cpufreq_stats_update_policy_cpu(policy); | ||
290 | return 0; | ||
291 | } | ||
292 | |||
272 | if (val != CPUFREQ_NOTIFY) | 293 | if (val != CPUFREQ_NOTIFY) |
273 | return 0; | 294 | return 0; |
274 | table = cpufreq_frequency_get_table(cpu); | 295 | table = cpufreq_frequency_get_table(cpu); |