1 #include <linux/device.h>
6 #include <linux/sched.h>
7 #include <linux/export.h>
12 #include <asm/current.h>
13 #include <asm/processor.h>
14 #include <asm/cputable.h>
17 #include <asm/machdep.h>
48 ret =
sscanf(buf,
"%ld", &snooze);
52 per_cpu(smt_snooze_delay, cpu->
dev.id) = snooze;
67 static DEVICE_ATTR(smt_snooze_delay, 0644, show_smt_snooze_delay,
68 store_smt_snooze_delay);
70 static int __init setup_smt_snooze_delay(
char *
str)
80 per_cpu(smt_snooze_delay, cpu) = snooze;
110 #define SYSFS_PMCSETUP(NAME, ADDRESS) \
111 static void read_##NAME(void *val) \
113 *(unsigned long *)val = mfspr(ADDRESS); \
115 static void write_##NAME(void *val) \
118 mtspr(ADDRESS, *(unsigned long *)val); \
120 static ssize_t show_##NAME(struct device *dev, \
121 struct device_attribute *attr, \
124 struct cpu *cpu = container_of(dev, struct cpu, dev); \
126 smp_call_function_single(cpu->dev.id, read_##NAME, &val, 1); \
127 return sprintf(buf, "%lx\n", val); \
129 static ssize_t __used \
130 store_##NAME(struct device *dev, struct device_attribute *attr, \
131 const char *buf, size_t count) \
133 struct cpu *cpu = container_of(dev, struct cpu, dev); \
135 int ret = sscanf(buf, "%lx", &val); \
138 smp_call_function_single(cpu->dev.id, write_##NAME, &val, 1); \
147 #if defined(CONFIG_PPC64)
148 #define HAS_PPC_PMC_CLASSIC 1
149 #define HAS_PPC_PMC_IBM 1
150 #define HAS_PPC_PMC_PA6T 1
151 #elif defined(CONFIG_6xx)
152 #define HAS_PPC_PMC_CLASSIC 1
153 #define HAS_PPC_PMC_IBM 1
154 #define HAS_PPC_PMC_G4 1
158 #ifdef HAS_PPC_PMC_CLASSIC
168 #ifdef HAS_PPC_PMC_G4
182 static DEVICE_ATTR(mmcra, 0600, show_mmcra, store_mmcra);
184 static DEVICE_ATTR(dscr, 0600, show_dscr, store_dscr);
185 static DEVICE_ATTR(purr, 0600, show_purr, store_purr);
194 return sprintf(buf,
"%lx\n", dscr_default);
197 static void update_dscr(
void *
dummy)
199 if (!
current->thread.dscr_inherit) {
200 current->thread.dscr = dscr_default;
201 mtspr(SPRN_DSCR, dscr_default);
212 ret =
sscanf(buf,
"%lx", &val);
223 show_dscr_default, store_dscr_default);
225 static void sysfs_create_dscr_default(
void)
233 #ifdef HAS_PPC_PMC_PA6T
240 #ifdef CONFIG_DEBUG_KERNEL
272 #ifdef HAS_PPC_PMC_IBM
274 __ATTR(mmcr0, 0600, show_mmcr0, store_mmcr0),
275 __ATTR(mmcr1, 0600, show_mmcr1, store_mmcr1),
279 #ifdef HAS_PPC_PMC_G4
281 __ATTR(mmcr0, 0600, show_mmcr0, store_mmcr0),
282 __ATTR(mmcr1, 0600, show_mmcr1, store_mmcr1),
283 __ATTR(mmcr2, 0600, show_mmcr2, store_mmcr2),
288 __ATTR(pmc1, 0600, show_pmc1, store_pmc1),
289 __ATTR(pmc2, 0600, show_pmc2, store_pmc2),
290 __ATTR(pmc3, 0600, show_pmc3, store_pmc3),
291 __ATTR(pmc4, 0600, show_pmc4, store_pmc4),
292 __ATTR(pmc5, 0600, show_pmc5, store_pmc5),
293 __ATTR(pmc6, 0600, show_pmc6, store_pmc6),
295 __ATTR(pmc7, 0600, show_pmc7, store_pmc7),
296 __ATTR(pmc8, 0600, show_pmc8, store_pmc8),
300 #ifdef HAS_PPC_PMC_PA6T
302 __ATTR(mmcr0, 0600, show_mmcr0, store_mmcr0),
303 __ATTR(mmcr1, 0600, show_mmcr1, store_mmcr1),
304 __ATTR(pmc0, 0600, show_pa6t_pmc0, store_pa6t_pmc0),
305 __ATTR(pmc1, 0600, show_pa6t_pmc1, store_pa6t_pmc1),
306 __ATTR(pmc2, 0600, show_pa6t_pmc2, store_pa6t_pmc2),
307 __ATTR(pmc3, 0600, show_pa6t_pmc3, store_pa6t_pmc3),
308 __ATTR(pmc4, 0600, show_pa6t_pmc4, store_pa6t_pmc4),
309 __ATTR(pmc5, 0600, show_pa6t_pmc5, store_pa6t_pmc5),
310 #ifdef CONFIG_DEBUG_KERNEL
311 __ATTR(hid0, 0600, show_hid0, store_hid0),
312 __ATTR(hid1, 0600, show_hid1, store_hid1),
313 __ATTR(hid4, 0600, show_hid4, store_hid4),
314 __ATTR(hid5, 0600, show_hid5, store_hid5),
315 __ATTR(ima0, 0600, show_ima0, store_ima0),
316 __ATTR(ima1, 0600, show_ima1, store_ima1),
317 __ATTR(ima2, 0600, show_ima2, store_ima2),
318 __ATTR(ima3, 0600, show_ima3, store_ima3),
319 __ATTR(ima4, 0600, show_ima4, store_ima4),
320 __ATTR(ima5, 0600, show_ima5, store_ima5),
321 __ATTR(ima6, 0600, show_ima6, store_ima6),
322 __ATTR(ima7, 0600, show_ima7, store_ima7),
323 __ATTR(ima8, 0600, show_ima8, store_ima8),
324 __ATTR(ima9, 0600, show_ima9, store_ima9),
325 __ATTR(imaat, 0600, show_imaat, store_imaat),
326 __ATTR(btcr, 0600, show_btcr, store_btcr),
327 __ATTR(pccr, 0600, show_pccr, store_pccr),
328 __ATTR(rpccr, 0600, show_rpccr, store_rpccr),
329 __ATTR(der, 0600, show_der, store_der),
330 __ATTR(mer, 0600, show_mer, store_mer),
331 __ATTR(ber, 0600, show_ber, store_ber),
333 __ATTR(sier, 0600, show_sier, store_sier),
334 __ATTR(siar, 0600, show_siar, store_siar),
335 __ATTR(tsr0, 0600, show_tsr0, store_tsr0),
336 __ATTR(tsr1, 0600, show_tsr1, store_tsr1),
337 __ATTR(tsr2, 0600, show_tsr2, store_tsr2),
338 __ATTR(tsr3, 0600, show_tsr3, store_tsr3),
344 static void __cpuinit register_cpu_online(
unsigned int cpu)
346 struct cpu *
c = &
per_cpu(cpu_devices, cpu);
358 #ifdef HAS_PPC_PMC_IBM
360 attrs = ibm_common_attrs;
362 pmc_attrs = classic_pmc_attrs;
365 #ifdef HAS_PPC_PMC_G4
367 attrs = g4_common_attrs;
369 pmc_attrs = classic_pmc_attrs;
372 #ifdef HAS_PPC_PMC_PA6T
386 for (i = 0; i < nattrs; i++)
413 #ifdef CONFIG_HOTPLUG_CPU
414 static void unregister_cpu_online(
unsigned int cpu)
416 struct cpu *c = &
per_cpu(cpu_devices, cpu);
430 #ifdef HAS_PPC_PMC_IBM
432 attrs = ibm_common_attrs;
434 pmc_attrs = classic_pmc_attrs;
437 #ifdef HAS_PPC_PMC_G4
439 attrs = g4_common_attrs;
441 pmc_attrs = classic_pmc_attrs;
444 #ifdef HAS_PPC_PMC_PA6T
458 for (i = 0; i < nattrs; i++)
485 #ifdef CONFIG_ARCH_CPU_PROBE_RELEASE
486 ssize_t arch_cpu_probe(
const char *buf,
size_t count)
489 return ppc_md.cpu_probe(buf, count);
494 ssize_t arch_cpu_release(
const char *buf,
size_t count)
497 return ppc_md.cpu_release(buf, count);
506 unsigned long action,
void *hcpu)
508 unsigned int cpu = (
unsigned int)(
long)hcpu;
513 register_cpu_online(cpu);
515 #ifdef CONFIG_HOTPLUG_CPU
518 unregister_cpu_online(cpu);
526 .notifier_call = sysfs_cpu_notify,
600 static void register_nodes(
void)
608 int sysfs_add_device_to_node(
struct device *dev,
int nid)
612 kobject_name(&dev->
kobj));
616 void sysfs_remove_device_from_node(
struct device *dev,
int nid)
624 static void register_nodes(
void)
637 return sprintf(buf,
"%d\n", get_hard_smp_processor_id(cpu->
dev.id));
641 static int __init topology_init(
void)
646 register_cpu_notifier(&sysfs_cpu_nb);
649 struct cpu *c = &
per_cpu(cpu_devices, cpu);
668 register_cpu_online(cpu);
671 sysfs_create_dscr_default();