aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel/sysfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/powerpc/kernel/sysfs.c')
-rw-r--r--arch/powerpc/kernel/sysfs.c119
1 files changed, 92 insertions, 27 deletions
diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c
index 56d172d16e56..86a2ffccef25 100644
--- a/arch/powerpc/kernel/sysfs.c
+++ b/arch/powerpc/kernel/sysfs.c
@@ -15,18 +15,24 @@
15#include <asm/firmware.h> 15#include <asm/firmware.h>
16#include <asm/hvcall.h> 16#include <asm/hvcall.h>
17#include <asm/prom.h> 17#include <asm/prom.h>
18#include <asm/paca.h>
19#include <asm/lppaca.h>
20#include <asm/machdep.h> 18#include <asm/machdep.h>
21#include <asm/smp.h> 19#include <asm/smp.h>
22 20
21#ifdef CONFIG_PPC64
22#include <asm/paca.h>
23#include <asm/lppaca.h>
24#endif
25
23static DEFINE_PER_CPU(struct cpu, cpu_devices); 26static DEFINE_PER_CPU(struct cpu, cpu_devices);
24 27
25static DEFINE_PER_CPU(struct kobject *, cache_toplevel); 28static DEFINE_PER_CPU(struct kobject *, cache_toplevel);
26 29
27/* SMT stuff */ 30/*
31 * SMT snooze delay stuff, 64-bit only for now
32 */
33
34#ifdef CONFIG_PPC64
28 35
29#ifdef CONFIG_PPC_MULTIPLATFORM
30/* Time in microseconds we delay before sleeping in the idle loop */ 36/* Time in microseconds we delay before sleeping in the idle loop */
31DEFINE_PER_CPU(unsigned long, smt_snooze_delay) = { 100 }; 37DEFINE_PER_CPU(unsigned long, smt_snooze_delay) = { 100 };
32 38
@@ -106,7 +112,7 @@ static int __init setup_smt_snooze_delay(char *str)
106} 112}
107__setup("smt-snooze-delay=", setup_smt_snooze_delay); 113__setup("smt-snooze-delay=", setup_smt_snooze_delay);
108 114
109#endif /* CONFIG_PPC_MULTIPLATFORM */ 115#endif /* CONFIG_PPC64 */
110 116
111/* 117/*
112 * Enabling PMCs will slow partition context switch times so we only do 118 * Enabling PMCs will slow partition context switch times so we only do
@@ -115,7 +121,7 @@ __setup("smt-snooze-delay=", setup_smt_snooze_delay);
115 121
116static DEFINE_PER_CPU(char, pmcs_enabled); 122static DEFINE_PER_CPU(char, pmcs_enabled);
117 123
118void ppc64_enable_pmcs(void) 124void ppc_enable_pmcs(void)
119{ 125{
120 /* Only need to enable them once */ 126 /* Only need to enable them once */
121 if (__get_cpu_var(pmcs_enabled)) 127 if (__get_cpu_var(pmcs_enabled))
@@ -126,8 +132,9 @@ void ppc64_enable_pmcs(void)
126 if (ppc_md.enable_pmcs) 132 if (ppc_md.enable_pmcs)
127 ppc_md.enable_pmcs(); 133 ppc_md.enable_pmcs();
128} 134}
129EXPORT_SYMBOL(ppc64_enable_pmcs); 135EXPORT_SYMBOL(ppc_enable_pmcs);
130 136
137#if defined(CONFIG_6xx) || defined(CONFIG_PPC64)
131/* XXX convert to rusty's on_one_cpu */ 138/* XXX convert to rusty's on_one_cpu */
132static unsigned long run_on_cpu(unsigned long cpu, 139static unsigned long run_on_cpu(unsigned long cpu,
133 unsigned long (*func)(unsigned long), 140 unsigned long (*func)(unsigned long),
@@ -146,6 +153,7 @@ static unsigned long run_on_cpu(unsigned long cpu,
146 153
147 return ret; 154 return ret;
148} 155}
156#endif
149 157
150#define SYSFS_PMCSETUP(NAME, ADDRESS) \ 158#define SYSFS_PMCSETUP(NAME, ADDRESS) \
151static unsigned long read_##NAME(unsigned long junk) \ 159static unsigned long read_##NAME(unsigned long junk) \
@@ -154,7 +162,7 @@ static unsigned long read_##NAME(unsigned long junk) \
154} \ 162} \
155static unsigned long write_##NAME(unsigned long val) \ 163static unsigned long write_##NAME(unsigned long val) \
156{ \ 164{ \
157 ppc64_enable_pmcs(); \ 165 ppc_enable_pmcs(); \
158 mtspr(ADDRESS, val); \ 166 mtspr(ADDRESS, val); \
159 return 0; \ 167 return 0; \
160} \ 168} \
@@ -184,28 +192,53 @@ static ssize_t __used \
184 * that are implemented on the current processor 192 * that are implemented on the current processor
185 */ 193 */
186 194
195#if defined(CONFIG_PPC64)
196#define HAS_PPC_PMC_CLASSIC 1
197#define HAS_PPC_PMC_IBM 1
198#define HAS_PPC_PMC_PA6T 1
199#elif defined(CONFIG_6xx)
200#define HAS_PPC_PMC_CLASSIC 1
201#define HAS_PPC_PMC_IBM 1
202#define HAS_PPC_PMC_G4 1
203#endif
204
205
206#ifdef HAS_PPC_PMC_CLASSIC
187SYSFS_PMCSETUP(mmcr0, SPRN_MMCR0); 207SYSFS_PMCSETUP(mmcr0, SPRN_MMCR0);
188SYSFS_PMCSETUP(mmcr1, SPRN_MMCR1); 208SYSFS_PMCSETUP(mmcr1, SPRN_MMCR1);
189SYSFS_PMCSETUP(mmcra, SPRN_MMCRA);
190SYSFS_PMCSETUP(pmc1, SPRN_PMC1); 209SYSFS_PMCSETUP(pmc1, SPRN_PMC1);
191SYSFS_PMCSETUP(pmc2, SPRN_PMC2); 210SYSFS_PMCSETUP(pmc2, SPRN_PMC2);
192SYSFS_PMCSETUP(pmc3, SPRN_PMC3); 211SYSFS_PMCSETUP(pmc3, SPRN_PMC3);
193SYSFS_PMCSETUP(pmc4, SPRN_PMC4); 212SYSFS_PMCSETUP(pmc4, SPRN_PMC4);
194SYSFS_PMCSETUP(pmc5, SPRN_PMC5); 213SYSFS_PMCSETUP(pmc5, SPRN_PMC5);
195SYSFS_PMCSETUP(pmc6, SPRN_PMC6); 214SYSFS_PMCSETUP(pmc6, SPRN_PMC6);
215
216#ifdef HAS_PPC_PMC_G4
217SYSFS_PMCSETUP(mmcr2, SPRN_MMCR2);
218#endif
219
220#ifdef CONFIG_PPC64
196SYSFS_PMCSETUP(pmc7, SPRN_PMC7); 221SYSFS_PMCSETUP(pmc7, SPRN_PMC7);
197SYSFS_PMCSETUP(pmc8, SPRN_PMC8); 222SYSFS_PMCSETUP(pmc8, SPRN_PMC8);
223
224SYSFS_PMCSETUP(mmcra, SPRN_MMCRA);
198SYSFS_PMCSETUP(purr, SPRN_PURR); 225SYSFS_PMCSETUP(purr, SPRN_PURR);
199SYSFS_PMCSETUP(spurr, SPRN_SPURR); 226SYSFS_PMCSETUP(spurr, SPRN_SPURR);
200SYSFS_PMCSETUP(dscr, SPRN_DSCR); 227SYSFS_PMCSETUP(dscr, SPRN_DSCR);
201 228
229static SYSDEV_ATTR(mmcra, 0600, show_mmcra, store_mmcra);
230static SYSDEV_ATTR(spurr, 0600, show_spurr, NULL);
231static SYSDEV_ATTR(dscr, 0600, show_dscr, store_dscr);
232static SYSDEV_ATTR(purr, 0600, show_purr, store_purr);
233#endif /* CONFIG_PPC64 */
234
235#ifdef HAS_PPC_PMC_PA6T
202SYSFS_PMCSETUP(pa6t_pmc0, SPRN_PA6T_PMC0); 236SYSFS_PMCSETUP(pa6t_pmc0, SPRN_PA6T_PMC0);
203SYSFS_PMCSETUP(pa6t_pmc1, SPRN_PA6T_PMC1); 237SYSFS_PMCSETUP(pa6t_pmc1, SPRN_PA6T_PMC1);
204SYSFS_PMCSETUP(pa6t_pmc2, SPRN_PA6T_PMC2); 238SYSFS_PMCSETUP(pa6t_pmc2, SPRN_PA6T_PMC2);
205SYSFS_PMCSETUP(pa6t_pmc3, SPRN_PA6T_PMC3); 239SYSFS_PMCSETUP(pa6t_pmc3, SPRN_PA6T_PMC3);
206SYSFS_PMCSETUP(pa6t_pmc4, SPRN_PA6T_PMC4); 240SYSFS_PMCSETUP(pa6t_pmc4, SPRN_PA6T_PMC4);
207SYSFS_PMCSETUP(pa6t_pmc5, SPRN_PA6T_PMC5); 241SYSFS_PMCSETUP(pa6t_pmc5, SPRN_PA6T_PMC5);
208
209#ifdef CONFIG_DEBUG_KERNEL 242#ifdef CONFIG_DEBUG_KERNEL
210SYSFS_PMCSETUP(hid0, SPRN_HID0); 243SYSFS_PMCSETUP(hid0, SPRN_HID0);
211SYSFS_PMCSETUP(hid1, SPRN_HID1); 244SYSFS_PMCSETUP(hid1, SPRN_HID1);
@@ -236,28 +269,37 @@ SYSFS_PMCSETUP(tsr1, SPRN_PA6T_TSR1);
236SYSFS_PMCSETUP(tsr2, SPRN_PA6T_TSR2); 269SYSFS_PMCSETUP(tsr2, SPRN_PA6T_TSR2);
237SYSFS_PMCSETUP(tsr3, SPRN_PA6T_TSR3); 270SYSFS_PMCSETUP(tsr3, SPRN_PA6T_TSR3);
238#endif /* CONFIG_DEBUG_KERNEL */ 271#endif /* CONFIG_DEBUG_KERNEL */
272#endif /* HAS_PPC_PMC_PA6T */
239 273
240static SYSDEV_ATTR(mmcra, 0600, show_mmcra, store_mmcra); 274#ifdef HAS_PPC_PMC_IBM
241static SYSDEV_ATTR(spurr, 0600, show_spurr, NULL);
242static SYSDEV_ATTR(dscr, 0600, show_dscr, store_dscr);
243static SYSDEV_ATTR(purr, 0600, show_purr, store_purr);
244
245static struct sysdev_attribute ibm_common_attrs[] = { 275static struct sysdev_attribute ibm_common_attrs[] = {
246 _SYSDEV_ATTR(mmcr0, 0600, show_mmcr0, store_mmcr0), 276 _SYSDEV_ATTR(mmcr0, 0600, show_mmcr0, store_mmcr0),
247 _SYSDEV_ATTR(mmcr1, 0600, show_mmcr1, store_mmcr1), 277 _SYSDEV_ATTR(mmcr1, 0600, show_mmcr1, store_mmcr1),
248}; 278};
279#endif /* HAS_PPC_PMC_G4 */
280
281#ifdef HAS_PPC_PMC_G4
282static struct sysdev_attribute g4_common_attrs[] = {
283 _SYSDEV_ATTR(mmcr0, 0600, show_mmcr0, store_mmcr0),
284 _SYSDEV_ATTR(mmcr1, 0600, show_mmcr1, store_mmcr1),
285 _SYSDEV_ATTR(mmcr2, 0600, show_mmcr2, store_mmcr2),
286};
287#endif /* HAS_PPC_PMC_G4 */
249 288
250static struct sysdev_attribute ibm_pmc_attrs[] = { 289static struct sysdev_attribute classic_pmc_attrs[] = {
251 _SYSDEV_ATTR(pmc1, 0600, show_pmc1, store_pmc1), 290 _SYSDEV_ATTR(pmc1, 0600, show_pmc1, store_pmc1),
252 _SYSDEV_ATTR(pmc2, 0600, show_pmc2, store_pmc2), 291 _SYSDEV_ATTR(pmc2, 0600, show_pmc2, store_pmc2),
253 _SYSDEV_ATTR(pmc3, 0600, show_pmc3, store_pmc3), 292 _SYSDEV_ATTR(pmc3, 0600, show_pmc3, store_pmc3),
254 _SYSDEV_ATTR(pmc4, 0600, show_pmc4, store_pmc4), 293 _SYSDEV_ATTR(pmc4, 0600, show_pmc4, store_pmc4),
255 _SYSDEV_ATTR(pmc5, 0600, show_pmc5, store_pmc5), 294 _SYSDEV_ATTR(pmc5, 0600, show_pmc5, store_pmc5),
256 _SYSDEV_ATTR(pmc6, 0600, show_pmc6, store_pmc6), 295 _SYSDEV_ATTR(pmc6, 0600, show_pmc6, store_pmc6),
296#ifdef CONFIG_PPC64
257 _SYSDEV_ATTR(pmc7, 0600, show_pmc7, store_pmc7), 297 _SYSDEV_ATTR(pmc7, 0600, show_pmc7, store_pmc7),
258 _SYSDEV_ATTR(pmc8, 0600, show_pmc8, store_pmc8), 298 _SYSDEV_ATTR(pmc8, 0600, show_pmc8, store_pmc8),
299#endif
259}; 300};
260 301
302#ifdef HAS_PPC_PMC_PA6T
261static struct sysdev_attribute pa6t_attrs[] = { 303static struct sysdev_attribute pa6t_attrs[] = {
262 _SYSDEV_ATTR(mmcr0, 0600, show_mmcr0, store_mmcr0), 304 _SYSDEV_ATTR(mmcr0, 0600, show_mmcr0, store_mmcr0),
263 _SYSDEV_ATTR(mmcr1, 0600, show_mmcr1, store_mmcr1), 305 _SYSDEV_ATTR(mmcr1, 0600, show_mmcr1, store_mmcr1),
@@ -298,6 +340,8 @@ static struct sysdev_attribute pa6t_attrs[] = {
298 _SYSDEV_ATTR(tsr3, 0600, show_tsr3, store_tsr3), 340 _SYSDEV_ATTR(tsr3, 0600, show_tsr3, store_tsr3),
299#endif /* CONFIG_DEBUG_KERNEL */ 341#endif /* CONFIG_DEBUG_KERNEL */
300}; 342};
343#endif /* HAS_PPC_PMC_PA6T */
344#endif /* HAS_PPC_PMC_CLASSIC */
301 345
302struct cache_desc { 346struct cache_desc {
303 struct kobject kobj; 347 struct kobject kobj;
@@ -588,23 +632,36 @@ static void __cpuinit register_cpu_online(unsigned int cpu)
588 struct sysdev_attribute *attrs, *pmc_attrs; 632 struct sysdev_attribute *attrs, *pmc_attrs;
589 int i, nattrs; 633 int i, nattrs;
590 634
635#ifdef CONFIG_PPC64
591 if (!firmware_has_feature(FW_FEATURE_ISERIES) && 636 if (!firmware_has_feature(FW_FEATURE_ISERIES) &&
592 cpu_has_feature(CPU_FTR_SMT)) 637 cpu_has_feature(CPU_FTR_SMT))
593 sysdev_create_file(s, &attr_smt_snooze_delay); 638 sysdev_create_file(s, &attr_smt_snooze_delay);
639#endif
594 640
595 /* PMC stuff */ 641 /* PMC stuff */
596 switch (cur_cpu_spec->pmc_type) { 642 switch (cur_cpu_spec->pmc_type) {
643#ifdef HAS_PPC_PMC_IBM
597 case PPC_PMC_IBM: 644 case PPC_PMC_IBM:
598 attrs = ibm_common_attrs; 645 attrs = ibm_common_attrs;
599 nattrs = sizeof(ibm_common_attrs) / sizeof(struct sysdev_attribute); 646 nattrs = sizeof(ibm_common_attrs) / sizeof(struct sysdev_attribute);
600 pmc_attrs = ibm_pmc_attrs; 647 pmc_attrs = classic_pmc_attrs;
601 break; 648 break;
649#endif /* HAS_PPC_PMC_IBM */
650#ifdef HAS_PPC_PMC_G4
651 case PPC_PMC_G4:
652 attrs = g4_common_attrs;
653 nattrs = sizeof(g4_common_attrs) / sizeof(struct sysdev_attribute);
654 pmc_attrs = classic_pmc_attrs;
655 break;
656#endif /* HAS_PPC_PMC_G4 */
657#ifdef HAS_PPC_PMC_PA6T
602 case PPC_PMC_PA6T: 658 case PPC_PMC_PA6T:
603 /* PA Semi starts counting at PMC0 */ 659 /* PA Semi starts counting at PMC0 */
604 attrs = pa6t_attrs; 660 attrs = pa6t_attrs;
605 nattrs = sizeof(pa6t_attrs) / sizeof(struct sysdev_attribute); 661 nattrs = sizeof(pa6t_attrs) / sizeof(struct sysdev_attribute);
606 pmc_attrs = NULL; 662 pmc_attrs = NULL;
607 break; 663 break;
664#endif /* HAS_PPC_PMC_PA6T */
608 default: 665 default:
609 attrs = NULL; 666 attrs = NULL;
610 nattrs = 0; 667 nattrs = 0;
@@ -618,6 +675,7 @@ static void __cpuinit register_cpu_online(unsigned int cpu)
618 for (i = 0; i < cur_cpu_spec->num_pmcs; i++) 675 for (i = 0; i < cur_cpu_spec->num_pmcs; i++)
619 sysdev_create_file(s, &pmc_attrs[i]); 676 sysdev_create_file(s, &pmc_attrs[i]);
620 677
678#ifdef CONFIG_PPC64
621 if (cpu_has_feature(CPU_FTR_MMCRA)) 679 if (cpu_has_feature(CPU_FTR_MMCRA))
622 sysdev_create_file(s, &attr_mmcra); 680 sysdev_create_file(s, &attr_mmcra);
623 681
@@ -629,6 +687,7 @@ static void __cpuinit register_cpu_online(unsigned int cpu)
629 687
630 if (cpu_has_feature(CPU_FTR_DSCR)) 688 if (cpu_has_feature(CPU_FTR_DSCR))
631 sysdev_create_file(s, &attr_dscr); 689 sysdev_create_file(s, &attr_dscr);
690#endif /* CONFIG_PPC64 */
632 691
633 create_cache_info(s); 692 create_cache_info(s);
634} 693}
@@ -641,16 +700,9 @@ static void remove_cache_info(struct sys_device *sysdev)
641 int cpu = sysdev->id; 700 int cpu = sysdev->id;
642 701
643 cache_desc = per_cpu(cache_desc, cpu); 702 cache_desc = per_cpu(cache_desc, cpu);
644 if (cache_desc != NULL) { 703 if (cache_desc != NULL)
645 sysfs_remove_file(&cache_desc->kobj, &cache_size_attr.attr);
646 sysfs_remove_file(&cache_desc->kobj, &cache_line_size_attr.attr);
647 sysfs_remove_file(&cache_desc->kobj, &cache_type_attr.attr);
648 sysfs_remove_file(&cache_desc->kobj, &cache_level_attr.attr);
649 sysfs_remove_file(&cache_desc->kobj, &cache_nr_sets_attr.attr);
650 sysfs_remove_file(&cache_desc->kobj, &cache_assoc_attr.attr);
651
652 kobject_put(&cache_desc->kobj); 704 kobject_put(&cache_desc->kobj);
653 } 705
654 cache_toplevel = per_cpu(cache_toplevel, cpu); 706 cache_toplevel = per_cpu(cache_toplevel, cpu);
655 if (cache_toplevel != NULL) 707 if (cache_toplevel != NULL)
656 kobject_put(cache_toplevel); 708 kobject_put(cache_toplevel);
@@ -671,17 +723,28 @@ static void unregister_cpu_online(unsigned int cpu)
671 723
672 /* PMC stuff */ 724 /* PMC stuff */
673 switch (cur_cpu_spec->pmc_type) { 725 switch (cur_cpu_spec->pmc_type) {
726#ifdef HAS_PPC_PMC_IBM
674 case PPC_PMC_IBM: 727 case PPC_PMC_IBM:
675 attrs = ibm_common_attrs; 728 attrs = ibm_common_attrs;
676 nattrs = sizeof(ibm_common_attrs) / sizeof(struct sysdev_attribute); 729 nattrs = sizeof(ibm_common_attrs) / sizeof(struct sysdev_attribute);
677 pmc_attrs = ibm_pmc_attrs; 730 pmc_attrs = classic_pmc_attrs;
731 break;
732#endif /* HAS_PPC_PMC_IBM */
733#ifdef HAS_PPC_PMC_G4
734 case PPC_PMC_G4:
735 attrs = g4_common_attrs;
736 nattrs = sizeof(g4_common_attrs) / sizeof(struct sysdev_attribute);
737 pmc_attrs = classic_pmc_attrs;
678 break; 738 break;
739#endif /* HAS_PPC_PMC_G4 */
740#ifdef HAS_PPC_PMC_PA6T
679 case PPC_PMC_PA6T: 741 case PPC_PMC_PA6T:
680 /* PA Semi starts counting at PMC0 */ 742 /* PA Semi starts counting at PMC0 */
681 attrs = pa6t_attrs; 743 attrs = pa6t_attrs;
682 nattrs = sizeof(pa6t_attrs) / sizeof(struct sysdev_attribute); 744 nattrs = sizeof(pa6t_attrs) / sizeof(struct sysdev_attribute);
683 pmc_attrs = NULL; 745 pmc_attrs = NULL;
684 break; 746 break;
747#endif /* HAS_PPC_PMC_PA6T */
685 default: 748 default:
686 attrs = NULL; 749 attrs = NULL;
687 nattrs = 0; 750 nattrs = 0;
@@ -695,6 +758,7 @@ static void unregister_cpu_online(unsigned int cpu)
695 for (i = 0; i < cur_cpu_spec->num_pmcs; i++) 758 for (i = 0; i < cur_cpu_spec->num_pmcs; i++)
696 sysdev_remove_file(s, &pmc_attrs[i]); 759 sysdev_remove_file(s, &pmc_attrs[i]);
697 760
761#ifdef CONFIG_PPC64
698 if (cpu_has_feature(CPU_FTR_MMCRA)) 762 if (cpu_has_feature(CPU_FTR_MMCRA))
699 sysdev_remove_file(s, &attr_mmcra); 763 sysdev_remove_file(s, &attr_mmcra);
700 764
@@ -706,6 +770,7 @@ static void unregister_cpu_online(unsigned int cpu)
706 770
707 if (cpu_has_feature(CPU_FTR_DSCR)) 771 if (cpu_has_feature(CPU_FTR_DSCR))
708 sysdev_remove_file(s, &attr_dscr); 772 sysdev_remove_file(s, &attr_dscr);
773#endif /* CONFIG_PPC64 */
709 774
710 remove_cache_info(s); 775 remove_cache_info(s);
711} 776}