diff options
Diffstat (limited to 'arch/powerpc/kernel/sysfs.c')
-rw-r--r-- | arch/powerpc/kernel/sysfs.c | 100 |
1 files changed, 90 insertions, 10 deletions
diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c index d45a168bdaca..400ab2b946e7 100644 --- a/arch/powerpc/kernel/sysfs.c +++ b/arch/powerpc/kernel/sysfs.c | |||
@@ -181,6 +181,8 @@ SYSFS_PMCSETUP(pmc6, SPRN_PMC6); | |||
181 | SYSFS_PMCSETUP(pmc7, SPRN_PMC7); | 181 | SYSFS_PMCSETUP(pmc7, SPRN_PMC7); |
182 | SYSFS_PMCSETUP(pmc8, SPRN_PMC8); | 182 | SYSFS_PMCSETUP(pmc8, SPRN_PMC8); |
183 | SYSFS_PMCSETUP(purr, SPRN_PURR); | 183 | SYSFS_PMCSETUP(purr, SPRN_PURR); |
184 | SYSFS_PMCSETUP(spurr, SPRN_SPURR); | ||
185 | SYSFS_PMCSETUP(dscr, SPRN_DSCR); | ||
184 | 186 | ||
185 | static SYSDEV_ATTR(mmcr0, 0600, show_mmcr0, store_mmcr0); | 187 | static SYSDEV_ATTR(mmcr0, 0600, show_mmcr0, store_mmcr0); |
186 | static SYSDEV_ATTR(mmcr1, 0600, show_mmcr1, store_mmcr1); | 188 | static SYSDEV_ATTR(mmcr1, 0600, show_mmcr1, store_mmcr1); |
@@ -194,16 +196,17 @@ static SYSDEV_ATTR(pmc6, 0600, show_pmc6, store_pmc6); | |||
194 | static SYSDEV_ATTR(pmc7, 0600, show_pmc7, store_pmc7); | 196 | static SYSDEV_ATTR(pmc7, 0600, show_pmc7, store_pmc7); |
195 | static SYSDEV_ATTR(pmc8, 0600, show_pmc8, store_pmc8); | 197 | static SYSDEV_ATTR(pmc8, 0600, show_pmc8, store_pmc8); |
196 | static SYSDEV_ATTR(purr, 0600, show_purr, NULL); | 198 | static SYSDEV_ATTR(purr, 0600, show_purr, NULL); |
199 | static SYSDEV_ATTR(spurr, 0600, show_spurr, NULL); | ||
200 | static SYSDEV_ATTR(dscr, 0600, show_dscr, store_dscr); | ||
197 | 201 | ||
198 | static void register_cpu_online(unsigned int cpu) | 202 | static void register_cpu_online(unsigned int cpu) |
199 | { | 203 | { |
200 | struct cpu *c = &per_cpu(cpu_devices, cpu); | 204 | struct cpu *c = &per_cpu(cpu_devices, cpu); |
201 | struct sys_device *s = &c->sysdev; | 205 | struct sys_device *s = &c->sysdev; |
202 | 206 | ||
203 | #ifndef CONFIG_PPC_ISERIES | 207 | if (!firmware_has_feature(FW_FEATURE_ISERIES) && |
204 | if (cpu_has_feature(CPU_FTR_SMT)) | 208 | cpu_has_feature(CPU_FTR_SMT)) |
205 | sysdev_create_file(s, &attr_smt_snooze_delay); | 209 | sysdev_create_file(s, &attr_smt_snooze_delay); |
206 | #endif | ||
207 | 210 | ||
208 | /* PMC stuff */ | 211 | /* PMC stuff */ |
209 | 212 | ||
@@ -232,6 +235,12 @@ static void register_cpu_online(unsigned int cpu) | |||
232 | 235 | ||
233 | if (cpu_has_feature(CPU_FTR_PURR)) | 236 | if (cpu_has_feature(CPU_FTR_PURR)) |
234 | sysdev_create_file(s, &attr_purr); | 237 | sysdev_create_file(s, &attr_purr); |
238 | |||
239 | if (cpu_has_feature(CPU_FTR_SPURR)) | ||
240 | sysdev_create_file(s, &attr_spurr); | ||
241 | |||
242 | if (cpu_has_feature(CPU_FTR_DSCR)) | ||
243 | sysdev_create_file(s, &attr_dscr); | ||
235 | } | 244 | } |
236 | 245 | ||
237 | #ifdef CONFIG_HOTPLUG_CPU | 246 | #ifdef CONFIG_HOTPLUG_CPU |
@@ -240,12 +249,11 @@ static void unregister_cpu_online(unsigned int cpu) | |||
240 | struct cpu *c = &per_cpu(cpu_devices, cpu); | 249 | struct cpu *c = &per_cpu(cpu_devices, cpu); |
241 | struct sys_device *s = &c->sysdev; | 250 | struct sys_device *s = &c->sysdev; |
242 | 251 | ||
243 | BUG_ON(c->no_control); | 252 | BUG_ON(!c->hotpluggable); |
244 | 253 | ||
245 | #ifndef CONFIG_PPC_ISERIES | 254 | if (!firmware_has_feature(FW_FEATURE_ISERIES) && |
246 | if (cpu_has_feature(CPU_FTR_SMT)) | 255 | cpu_has_feature(CPU_FTR_SMT)) |
247 | sysdev_remove_file(s, &attr_smt_snooze_delay); | 256 | sysdev_remove_file(s, &attr_smt_snooze_delay); |
248 | #endif | ||
249 | 257 | ||
250 | /* PMC stuff */ | 258 | /* PMC stuff */ |
251 | 259 | ||
@@ -274,6 +282,12 @@ static void unregister_cpu_online(unsigned int cpu) | |||
274 | 282 | ||
275 | if (cpu_has_feature(CPU_FTR_PURR)) | 283 | if (cpu_has_feature(CPU_FTR_PURR)) |
276 | sysdev_remove_file(s, &attr_purr); | 284 | sysdev_remove_file(s, &attr_purr); |
285 | |||
286 | if (cpu_has_feature(CPU_FTR_SPURR)) | ||
287 | sysdev_remove_file(s, &attr_spurr); | ||
288 | |||
289 | if (cpu_has_feature(CPU_FTR_DSCR)) | ||
290 | sysdev_remove_file(s, &attr_dscr); | ||
277 | } | 291 | } |
278 | #endif /* CONFIG_HOTPLUG_CPU */ | 292 | #endif /* CONFIG_HOTPLUG_CPU */ |
279 | 293 | ||
@@ -299,6 +313,72 @@ static struct notifier_block __cpuinitdata sysfs_cpu_nb = { | |||
299 | .notifier_call = sysfs_cpu_notify, | 313 | .notifier_call = sysfs_cpu_notify, |
300 | }; | 314 | }; |
301 | 315 | ||
316 | static DEFINE_MUTEX(cpu_mutex); | ||
317 | |||
318 | int cpu_add_sysdev_attr(struct sysdev_attribute *attr) | ||
319 | { | ||
320 | int cpu; | ||
321 | |||
322 | mutex_lock(&cpu_mutex); | ||
323 | |||
324 | for_each_possible_cpu(cpu) { | ||
325 | sysdev_create_file(get_cpu_sysdev(cpu), attr); | ||
326 | } | ||
327 | |||
328 | mutex_unlock(&cpu_mutex); | ||
329 | return 0; | ||
330 | } | ||
331 | EXPORT_SYMBOL_GPL(cpu_add_sysdev_attr); | ||
332 | |||
333 | int cpu_add_sysdev_attr_group(struct attribute_group *attrs) | ||
334 | { | ||
335 | int cpu; | ||
336 | struct sys_device *sysdev; | ||
337 | |||
338 | mutex_lock(&cpu_mutex); | ||
339 | |||
340 | for_each_possible_cpu(cpu) { | ||
341 | sysdev = get_cpu_sysdev(cpu); | ||
342 | sysfs_create_group(&sysdev->kobj, attrs); | ||
343 | } | ||
344 | |||
345 | mutex_unlock(&cpu_mutex); | ||
346 | return 0; | ||
347 | } | ||
348 | EXPORT_SYMBOL_GPL(cpu_add_sysdev_attr_group); | ||
349 | |||
350 | |||
351 | void cpu_remove_sysdev_attr(struct sysdev_attribute *attr) | ||
352 | { | ||
353 | int cpu; | ||
354 | |||
355 | mutex_lock(&cpu_mutex); | ||
356 | |||
357 | for_each_possible_cpu(cpu) { | ||
358 | sysdev_remove_file(get_cpu_sysdev(cpu), attr); | ||
359 | } | ||
360 | |||
361 | mutex_unlock(&cpu_mutex); | ||
362 | } | ||
363 | EXPORT_SYMBOL_GPL(cpu_remove_sysdev_attr); | ||
364 | |||
365 | void cpu_remove_sysdev_attr_group(struct attribute_group *attrs) | ||
366 | { | ||
367 | int cpu; | ||
368 | struct sys_device *sysdev; | ||
369 | |||
370 | mutex_lock(&cpu_mutex); | ||
371 | |||
372 | for_each_possible_cpu(cpu) { | ||
373 | sysdev = get_cpu_sysdev(cpu); | ||
374 | sysfs_remove_group(&sysdev->kobj, attrs); | ||
375 | } | ||
376 | |||
377 | mutex_unlock(&cpu_mutex); | ||
378 | } | ||
379 | EXPORT_SYMBOL_GPL(cpu_remove_sysdev_attr_group); | ||
380 | |||
381 | |||
302 | /* NUMA stuff */ | 382 | /* NUMA stuff */ |
303 | 383 | ||
304 | #ifdef CONFIG_NUMA | 384 | #ifdef CONFIG_NUMA |
@@ -360,10 +440,10 @@ static int __init topology_init(void) | |||
360 | * CPU. For instance, the boot cpu might never be valid | 440 | * CPU. For instance, the boot cpu might never be valid |
361 | * for hotplugging. | 441 | * for hotplugging. |
362 | */ | 442 | */ |
363 | if (!ppc_md.cpu_die) | 443 | if (ppc_md.cpu_die) |
364 | c->no_control = 1; | 444 | c->hotpluggable = 1; |
365 | 445 | ||
366 | if (cpu_online(cpu) || (c->no_control == 0)) { | 446 | if (cpu_online(cpu) || c->hotpluggable) { |
367 | register_cpu(c, cpu); | 447 | register_cpu(c, cpu); |
368 | 448 | ||
369 | sysdev_create_file(&c->sysdev, &attr_physical_id); | 449 | sysdev_create_file(&c->sysdev, &attr_physical_id); |