|
@@ -15,18 +15,24 @@
|
|
|
#include <asm/firmware.h>
|
|
|
#include <asm/hvcall.h>
|
|
|
#include <asm/prom.h>
|
|
|
-#include <asm/paca.h>
|
|
|
-#include <asm/lppaca.h>
|
|
|
#include <asm/machdep.h>
|
|
|
#include <asm/smp.h>
|
|
|
|
|
|
+#ifdef CONFIG_PPC64
|
|
|
+#include <asm/paca.h>
|
|
|
+#include <asm/lppaca.h>
|
|
|
+#endif
|
|
|
+
|
|
|
static DEFINE_PER_CPU(struct cpu, cpu_devices);
|
|
|
|
|
|
static DEFINE_PER_CPU(struct kobject *, cache_toplevel);
|
|
|
|
|
|
-/* SMT stuff */
|
|
|
+/*
|
|
|
+ * SMT snooze delay stuff, 64-bit only for now
|
|
|
+ */
|
|
|
+
|
|
|
+#ifdef CONFIG_PPC64
|
|
|
|
|
|
-#ifdef CONFIG_PPC_MULTIPLATFORM
|
|
|
/* Time in microseconds we delay before sleeping in the idle loop */
|
|
|
DEFINE_PER_CPU(unsigned long, smt_snooze_delay) = { 100 };
|
|
|
|
|
@@ -106,7 +112,7 @@ static int __init setup_smt_snooze_delay(char *str)
|
|
|
}
|
|
|
__setup("smt-snooze-delay=", setup_smt_snooze_delay);
|
|
|
|
|
|
-#endif /* CONFIG_PPC_MULTIPLATFORM */
|
|
|
+#endif /* CONFIG_PPC64 */
|
|
|
|
|
|
/*
|
|
|
* Enabling PMCs will slow partition context switch times so we only do
|
|
@@ -115,7 +121,7 @@ __setup("smt-snooze-delay=", setup_smt_snooze_delay);
|
|
|
|
|
|
static DEFINE_PER_CPU(char, pmcs_enabled);
|
|
|
|
|
|
-void ppc64_enable_pmcs(void)
|
|
|
+void ppc_enable_pmcs(void)
|
|
|
{
|
|
|
/* Only need to enable them once */
|
|
|
if (__get_cpu_var(pmcs_enabled))
|
|
@@ -126,7 +132,7 @@ void ppc64_enable_pmcs(void)
|
|
|
if (ppc_md.enable_pmcs)
|
|
|
ppc_md.enable_pmcs();
|
|
|
}
|
|
|
-EXPORT_SYMBOL(ppc64_enable_pmcs);
|
|
|
+EXPORT_SYMBOL(ppc_enable_pmcs);
|
|
|
|
|
|
/* XXX convert to rusty's on_one_cpu */
|
|
|
static unsigned long run_on_cpu(unsigned long cpu,
|
|
@@ -154,7 +160,7 @@ static unsigned long read_##NAME(unsigned long junk) \
|
|
|
} \
|
|
|
static unsigned long write_##NAME(unsigned long val) \
|
|
|
{ \
|
|
|
- ppc64_enable_pmcs(); \
|
|
|
+ ppc_enable_pmcs(); \
|
|
|
mtspr(ADDRESS, val); \
|
|
|
return 0; \
|
|
|
} \
|
|
@@ -184,28 +190,53 @@ static ssize_t __used \
|
|
|
* that are implemented on the current processor
|
|
|
*/
|
|
|
|
|
|
+#ifdef CONFIG_PPC64
|
|
|
+#define HAS_PPC_PMC_CLASSIC 1
|
|
|
+#define HAS_PPC_PMC_IBM 1
|
|
|
+#define HAS_PPC_PMC_PA6T 1
|
|
|
+#elif CONFIG_6xx
|
|
|
+#define HAS_PPC_PMC_CLASSIC 1
|
|
|
+#define HAS_PPC_PMC_IBM 1
|
|
|
+#define HAS_PPC_PMC_G4 1
|
|
|
+#endif
|
|
|
+
|
|
|
+
|
|
|
+#ifdef HAS_PPC_PMC_CLASSIC
|
|
|
SYSFS_PMCSETUP(mmcr0, SPRN_MMCR0);
|
|
|
SYSFS_PMCSETUP(mmcr1, SPRN_MMCR1);
|
|
|
-SYSFS_PMCSETUP(mmcra, SPRN_MMCRA);
|
|
|
SYSFS_PMCSETUP(pmc1, SPRN_PMC1);
|
|
|
SYSFS_PMCSETUP(pmc2, SPRN_PMC2);
|
|
|
SYSFS_PMCSETUP(pmc3, SPRN_PMC3);
|
|
|
SYSFS_PMCSETUP(pmc4, SPRN_PMC4);
|
|
|
SYSFS_PMCSETUP(pmc5, SPRN_PMC5);
|
|
|
SYSFS_PMCSETUP(pmc6, SPRN_PMC6);
|
|
|
+
|
|
|
+#ifdef HAS_PPC_PMC_G4
|
|
|
+SYSFS_PMCSETUP(mmcr2, SPRN_MMCR2);
|
|
|
+#endif
|
|
|
+
|
|
|
+#ifdef CONFIG_PPC64
|
|
|
SYSFS_PMCSETUP(pmc7, SPRN_PMC7);
|
|
|
SYSFS_PMCSETUP(pmc8, SPRN_PMC8);
|
|
|
+
|
|
|
+SYSFS_PMCSETUP(mmcra, SPRN_MMCRA);
|
|
|
SYSFS_PMCSETUP(purr, SPRN_PURR);
|
|
|
SYSFS_PMCSETUP(spurr, SPRN_SPURR);
|
|
|
SYSFS_PMCSETUP(dscr, SPRN_DSCR);
|
|
|
|
|
|
+static SYSDEV_ATTR(mmcra, 0600, show_mmcra, store_mmcra);
|
|
|
+static SYSDEV_ATTR(spurr, 0600, show_spurr, NULL);
|
|
|
+static SYSDEV_ATTR(dscr, 0600, show_dscr, store_dscr);
|
|
|
+static SYSDEV_ATTR(purr, 0600, show_purr, store_purr);
|
|
|
+#endif /* CONFIG_PPC64 */
|
|
|
+
|
|
|
+#ifdef HAS_PPC_PMC_PA6T
|
|
|
SYSFS_PMCSETUP(pa6t_pmc0, SPRN_PA6T_PMC0);
|
|
|
SYSFS_PMCSETUP(pa6t_pmc1, SPRN_PA6T_PMC1);
|
|
|
SYSFS_PMCSETUP(pa6t_pmc2, SPRN_PA6T_PMC2);
|
|
|
SYSFS_PMCSETUP(pa6t_pmc3, SPRN_PA6T_PMC3);
|
|
|
SYSFS_PMCSETUP(pa6t_pmc4, SPRN_PA6T_PMC4);
|
|
|
SYSFS_PMCSETUP(pa6t_pmc5, SPRN_PA6T_PMC5);
|
|
|
-
|
|
|
#ifdef CONFIG_DEBUG_KERNEL
|
|
|
SYSFS_PMCSETUP(hid0, SPRN_HID0);
|
|
|
SYSFS_PMCSETUP(hid1, SPRN_HID1);
|
|
@@ -236,28 +267,37 @@ SYSFS_PMCSETUP(tsr1, SPRN_PA6T_TSR1);
|
|
|
SYSFS_PMCSETUP(tsr2, SPRN_PA6T_TSR2);
|
|
|
SYSFS_PMCSETUP(tsr3, SPRN_PA6T_TSR3);
|
|
|
#endif /* CONFIG_DEBUG_KERNEL */
|
|
|
+#endif /* HAS_PPC_PMC_PA6T */
|
|
|
|
|
|
-static SYSDEV_ATTR(mmcra, 0600, show_mmcra, store_mmcra);
|
|
|
-static SYSDEV_ATTR(spurr, 0600, show_spurr, NULL);
|
|
|
-static SYSDEV_ATTR(dscr, 0600, show_dscr, store_dscr);
|
|
|
-static SYSDEV_ATTR(purr, 0600, show_purr, store_purr);
|
|
|
-
|
|
|
+#ifdef HAS_PPC_PMC_IBM
|
|
|
static struct sysdev_attribute ibm_common_attrs[] = {
|
|
|
_SYSDEV_ATTR(mmcr0, 0600, show_mmcr0, store_mmcr0),
|
|
|
_SYSDEV_ATTR(mmcr1, 0600, show_mmcr1, store_mmcr1),
|
|
|
};
|
|
|
+#endif /* HAS_PPC_PMC_G4 */
|
|
|
+
|
|
|
+#ifdef HAS_PPC_PMC_G4
|
|
|
+static struct sysdev_attribute g4_common_attrs[] = {
|
|
|
+ _SYSDEV_ATTR(mmcr0, 0600, show_mmcr0, store_mmcr0),
|
|
|
+ _SYSDEV_ATTR(mmcr1, 0600, show_mmcr1, store_mmcr1),
|
|
|
+ _SYSDEV_ATTR(mmcr2, 0600, show_mmcr2, store_mmcr2),
|
|
|
+};
|
|
|
+#endif /* HAS_PPC_PMC_G4 */
|
|
|
|
|
|
-static struct sysdev_attribute ibm_pmc_attrs[] = {
|
|
|
+static struct sysdev_attribute classic_pmc_attrs[] = {
|
|
|
_SYSDEV_ATTR(pmc1, 0600, show_pmc1, store_pmc1),
|
|
|
_SYSDEV_ATTR(pmc2, 0600, show_pmc2, store_pmc2),
|
|
|
_SYSDEV_ATTR(pmc3, 0600, show_pmc3, store_pmc3),
|
|
|
_SYSDEV_ATTR(pmc4, 0600, show_pmc4, store_pmc4),
|
|
|
_SYSDEV_ATTR(pmc5, 0600, show_pmc5, store_pmc5),
|
|
|
_SYSDEV_ATTR(pmc6, 0600, show_pmc6, store_pmc6),
|
|
|
+#ifdef CONFIG_PPC64
|
|
|
_SYSDEV_ATTR(pmc7, 0600, show_pmc7, store_pmc7),
|
|
|
_SYSDEV_ATTR(pmc8, 0600, show_pmc8, store_pmc8),
|
|
|
+#endif
|
|
|
};
|
|
|
|
|
|
+#ifdef HAS_PPC_PMC_PA6T
|
|
|
static struct sysdev_attribute pa6t_attrs[] = {
|
|
|
_SYSDEV_ATTR(mmcr0, 0600, show_mmcr0, store_mmcr0),
|
|
|
_SYSDEV_ATTR(mmcr1, 0600, show_mmcr1, store_mmcr1),
|
|
@@ -298,6 +338,8 @@ static struct sysdev_attribute pa6t_attrs[] = {
|
|
|
_SYSDEV_ATTR(tsr3, 0600, show_tsr3, store_tsr3),
|
|
|
#endif /* CONFIG_DEBUG_KERNEL */
|
|
|
};
|
|
|
+#endif /* HAS_PPC_PMC_PA6T */
|
|
|
+#endif /* HAS_PPC_PMC_CLASSIC */
|
|
|
|
|
|
struct cache_desc {
|
|
|
struct kobject kobj;
|
|
@@ -588,23 +630,36 @@ static void __cpuinit register_cpu_online(unsigned int cpu)
|
|
|
struct sysdev_attribute *attrs, *pmc_attrs;
|
|
|
int i, nattrs;
|
|
|
|
|
|
+#ifdef CONFIG_PPC64
|
|
|
if (!firmware_has_feature(FW_FEATURE_ISERIES) &&
|
|
|
cpu_has_feature(CPU_FTR_SMT))
|
|
|
sysdev_create_file(s, &attr_smt_snooze_delay);
|
|
|
+#endif
|
|
|
|
|
|
/* PMC stuff */
|
|
|
switch (cur_cpu_spec->pmc_type) {
|
|
|
+#ifdef HAS_PPC_PMC_IBM
|
|
|
case PPC_PMC_IBM:
|
|
|
attrs = ibm_common_attrs;
|
|
|
nattrs = sizeof(ibm_common_attrs) / sizeof(struct sysdev_attribute);
|
|
|
- pmc_attrs = ibm_pmc_attrs;
|
|
|
+ pmc_attrs = classic_pmc_attrs;
|
|
|
break;
|
|
|
+#endif /* HAS_PPC_PMC_IBM */
|
|
|
+#ifdef HAS_PPC_PMC_G4
|
|
|
+ case PPC_PMC_G4:
|
|
|
+ attrs = g4_common_attrs;
|
|
|
+ nattrs = sizeof(g4_common_attrs) / sizeof(struct sysdev_attribute);
|
|
|
+ pmc_attrs = classic_pmc_attrs;
|
|
|
+ break;
|
|
|
+#endif /* HAS_PPC_PMC_G4 */
|
|
|
+#ifdef HAS_PPC_PMC_PA6T
|
|
|
case PPC_PMC_PA6T:
|
|
|
/* PA Semi starts counting at PMC0 */
|
|
|
attrs = pa6t_attrs;
|
|
|
nattrs = sizeof(pa6t_attrs) / sizeof(struct sysdev_attribute);
|
|
|
pmc_attrs = NULL;
|
|
|
break;
|
|
|
+#endif /* HAS_PPC_PMC_PA6T */
|
|
|
default:
|
|
|
attrs = NULL;
|
|
|
nattrs = 0;
|
|
@@ -618,6 +673,7 @@ static void __cpuinit register_cpu_online(unsigned int cpu)
|
|
|
for (i = 0; i < cur_cpu_spec->num_pmcs; i++)
|
|
|
sysdev_create_file(s, &pmc_attrs[i]);
|
|
|
|
|
|
+#ifdef CONFIG_PPC64
|
|
|
if (cpu_has_feature(CPU_FTR_MMCRA))
|
|
|
sysdev_create_file(s, &attr_mmcra);
|
|
|
|
|
@@ -629,6 +685,7 @@ static void __cpuinit register_cpu_online(unsigned int cpu)
|
|
|
|
|
|
if (cpu_has_feature(CPU_FTR_DSCR))
|
|
|
sysdev_create_file(s, &attr_dscr);
|
|
|
+#endif /* CONFIG_PPC64 */
|
|
|
|
|
|
create_cache_info(s);
|
|
|
}
|
|
@@ -664,17 +721,28 @@ static void unregister_cpu_online(unsigned int cpu)
|
|
|
|
|
|
/* PMC stuff */
|
|
|
switch (cur_cpu_spec->pmc_type) {
|
|
|
+#ifdef HAS_PPC_PMC_IBM
|
|
|
case PPC_PMC_IBM:
|
|
|
attrs = ibm_common_attrs;
|
|
|
nattrs = sizeof(ibm_common_attrs) / sizeof(struct sysdev_attribute);
|
|
|
- pmc_attrs = ibm_pmc_attrs;
|
|
|
+ pmc_attrs = classic_pmc_attrs;
|
|
|
+ break;
|
|
|
+#endif /* HAS_PPC_PMC_IBM */
|
|
|
+#ifdef HAS_PPC_PMC_G4
|
|
|
+ case PPC_PMC_G4:
|
|
|
+ attrs = g4_common_attrs;
|
|
|
+ nattrs = sizeof(g4_common_attrs) / sizeof(struct sysdev_attribute);
|
|
|
+ pmc_attrs = classic_pmc_attrs;
|
|
|
break;
|
|
|
+#endif /* HAS_PPC_PMC_G4 */
|
|
|
+#ifdef HAS_PPC_PMC_PA6T
|
|
|
case PPC_PMC_PA6T:
|
|
|
/* PA Semi starts counting at PMC0 */
|
|
|
attrs = pa6t_attrs;
|
|
|
nattrs = sizeof(pa6t_attrs) / sizeof(struct sysdev_attribute);
|
|
|
pmc_attrs = NULL;
|
|
|
break;
|
|
|
+#endif /* HAS_PPC_PMC_PA6T */
|
|
|
default:
|
|
|
attrs = NULL;
|
|
|
nattrs = 0;
|
|
@@ -688,6 +756,7 @@ static void unregister_cpu_online(unsigned int cpu)
|
|
|
for (i = 0; i < cur_cpu_spec->num_pmcs; i++)
|
|
|
sysdev_remove_file(s, &pmc_attrs[i]);
|
|
|
|
|
|
+#ifdef CONFIG_PPC64
|
|
|
if (cpu_has_feature(CPU_FTR_MMCRA))
|
|
|
sysdev_remove_file(s, &attr_mmcra);
|
|
|
|
|
@@ -699,6 +768,7 @@ static void unregister_cpu_online(unsigned int cpu)
|
|
|
|
|
|
if (cpu_has_feature(CPU_FTR_DSCR))
|
|
|
sysdev_remove_file(s, &attr_dscr);
|
|
|
+#endif /* CONFIG_PPC64 */
|
|
|
|
|
|
remove_cache_info(s);
|
|
|
}
|