Commit 180a33627d958d5d9d3602dde6ac74b315e136f0
Committed by
Paul Mackerras
1 parent
b13cfd173f
Exists in
master
and in
4 other branches
[PATCH] ppc64: Move ppc64_enable_pmcs() logic into a ppc_md function
This patch moves power4_enable_pmcs() to arch/ppc64/kernel/pmc.c. I've tested it on P5 LPAR and P4. It does what it used to. Signed-off-by: Michael Ellerman <michael@ellerman.id.au> Signed-off-by: Paul Mackerras <paulus@samba.org>
Showing 7 changed files with 55 additions and 50 deletions Side-by-side Diff
arch/ppc64/kernel/iSeries_setup.c
| ... | ... | @@ -964,6 +964,8 @@ |
| 964 | 964 | ppc_md.calibrate_decr = iSeries_calibrate_decr; |
| 965 | 965 | ppc_md.progress = iSeries_progress; |
| 966 | 966 | |
| 967 | + /* XXX Implement enable_pmcs for iSeries */ | |
| 968 | + | |
| 967 | 969 | if (get_paca()->lppaca.shared_proc) { |
| 968 | 970 | ppc_md.idle_loop = iseries_shared_idle; |
| 969 | 971 | printk(KERN_INFO "Using shared processor idle loop\n"); |
arch/ppc64/kernel/pSeries_setup.c
| ... | ... | @@ -61,6 +61,7 @@ |
| 61 | 61 | #include <asm/plpar_wrappers.h> |
| 62 | 62 | #include <asm/xics.h> |
| 63 | 63 | #include <asm/firmware.h> |
| 64 | +#include <asm/pmc.h> | |
| 64 | 65 | |
| 65 | 66 | #include "i8259.h" |
| 66 | 67 | #include "mpic.h" |
| ... | ... | @@ -187,6 +188,21 @@ |
| 187 | 188 | " MPIC "); |
| 188 | 189 | } |
| 189 | 190 | |
| 191 | +static void pseries_lpar_enable_pmcs(void) | |
| 192 | +{ | |
| 193 | + unsigned long set, reset; | |
| 194 | + | |
| 195 | + power4_enable_pmcs(); | |
| 196 | + | |
| 197 | + set = 1UL << 63; | |
| 198 | + reset = 0; | |
| 199 | + plpar_hcall_norets(H_PERFMON, set, reset); | |
| 200 | + | |
| 201 | + /* instruct hypervisor to maintain PMCs */ | |
| 202 | + if (firmware_has_feature(FW_FEATURE_SPLPAR)) | |
| 203 | + get_paca()->lppaca.pmcregs_in_use = 1; | |
| 204 | +} | |
| 205 | + | |
| 190 | 206 | static void __init pSeries_setup_arch(void) |
| 191 | 207 | { |
| 192 | 208 | /* Fixup ppc_md depending on the type of interrupt controller */ |
| ... | ... | @@ -245,6 +261,11 @@ |
| 245 | 261 | printk(KERN_INFO "Using default idle loop\n"); |
| 246 | 262 | ppc_md.idle_loop = default_idle; |
| 247 | 263 | } |
| 264 | + | |
| 265 | + if (systemcfg->platform & PLATFORM_LPAR) | |
| 266 | + ppc_md.enable_pmcs = pseries_lpar_enable_pmcs; | |
| 267 | + else | |
| 268 | + ppc_md.enable_pmcs = power4_enable_pmcs; | |
| 248 | 269 | } |
| 249 | 270 | |
| 250 | 271 | static int __init pSeries_init_panel(void) |
arch/ppc64/kernel/pmac_setup.c
| ... | ... | @@ -71,6 +71,7 @@ |
| 71 | 71 | #include <asm/of_device.h> |
| 72 | 72 | #include <asm/lmb.h> |
| 73 | 73 | #include <asm/smu.h> |
| 74 | +#include <asm/pmc.h> | |
| 74 | 75 | |
| 75 | 76 | #include "pmac.h" |
| 76 | 77 | #include "mpic.h" |
| ... | ... | @@ -511,5 +512,6 @@ |
| 511 | 512 | .progress = pmac_progress, |
| 512 | 513 | .check_legacy_ioport = pmac_check_legacy_ioport, |
| 513 | 514 | .idle_loop = native_idle, |
| 515 | + .enable_pmcs = power4_enable_pmcs, | |
| 514 | 516 | }; |
arch/ppc64/kernel/pmc.c
| ... | ... | @@ -65,4 +65,25 @@ |
| 65 | 65 | spin_unlock(&pmc_owner_lock); |
| 66 | 66 | } |
| 67 | 67 | EXPORT_SYMBOL_GPL(release_pmc_hardware); |
| 68 | + | |
| 69 | +void power4_enable_pmcs(void) | |
| 70 | +{ | |
| 71 | + unsigned long hid0; | |
| 72 | + | |
| 73 | + hid0 = mfspr(HID0); | |
| 74 | + hid0 |= 1UL << (63 - 20); | |
| 75 | + | |
| 76 | + /* POWER4 requires the following sequence */ | |
| 77 | + asm volatile( | |
| 78 | + "sync\n" | |
| 79 | + "mtspr %1, %0\n" | |
| 80 | + "mfspr %0, %1\n" | |
| 81 | + "mfspr %0, %1\n" | |
| 82 | + "mfspr %0, %1\n" | |
| 83 | + "mfspr %0, %1\n" | |
| 84 | + "mfspr %0, %1\n" | |
| 85 | + "mfspr %0, %1\n" | |
| 86 | + "isync" : "=&r" (hid0) : "i" (HID0), "0" (hid0): | |
| 87 | + "memory"); | |
| 88 | +} |
arch/ppc64/kernel/sysfs.c
| ... | ... | @@ -101,6 +101,8 @@ |
| 101 | 101 | } |
| 102 | 102 | __setup("smt-snooze-delay=", setup_smt_snooze_delay); |
| 103 | 103 | |
| 104 | +#endif /* CONFIG_PPC_MULTIPLATFORM */ | |
| 105 | + | |
| 104 | 106 | /* |
| 105 | 107 | * Enabling PMCs will slow partition context switch times so we only do |
| 106 | 108 | * it the first time we write to the PMCs. |
| 107 | 109 | |
| 108 | 110 | |
| ... | ... | @@ -110,63 +112,15 @@ |
| 110 | 112 | |
| 111 | 113 | void ppc64_enable_pmcs(void) |
| 112 | 114 | { |
| 113 | - unsigned long hid0; | |
| 114 | -#ifdef CONFIG_PPC_PSERIES | |
| 115 | - unsigned long set, reset; | |
| 116 | -#endif /* CONFIG_PPC_PSERIES */ | |
| 117 | - | |
| 118 | 115 | /* Only need to enable them once */ |
| 119 | 116 | if (__get_cpu_var(pmcs_enabled)) |
| 120 | 117 | return; |
| 121 | 118 | |
| 122 | 119 | __get_cpu_var(pmcs_enabled) = 1; |
| 123 | 120 | |
| 124 | - switch (systemcfg->platform) { | |
| 125 | - case PLATFORM_PSERIES: | |
| 126 | - case PLATFORM_POWERMAC: | |
| 127 | - hid0 = mfspr(HID0); | |
| 128 | - hid0 |= 1UL << (63 - 20); | |
| 129 | - | |
| 130 | - /* POWER4 requires the following sequence */ | |
| 131 | - asm volatile( | |
| 132 | - "sync\n" | |
| 133 | - "mtspr %1, %0\n" | |
| 134 | - "mfspr %0, %1\n" | |
| 135 | - "mfspr %0, %1\n" | |
| 136 | - "mfspr %0, %1\n" | |
| 137 | - "mfspr %0, %1\n" | |
| 138 | - "mfspr %0, %1\n" | |
| 139 | - "mfspr %0, %1\n" | |
| 140 | - "isync" : "=&r" (hid0) : "i" (HID0), "0" (hid0): | |
| 141 | - "memory"); | |
| 142 | - break; | |
| 143 | - | |
| 144 | -#ifdef CONFIG_PPC_PSERIES | |
| 145 | - case PLATFORM_PSERIES_LPAR: | |
| 146 | - set = 1UL << 63; | |
| 147 | - reset = 0; | |
| 148 | - plpar_hcall_norets(H_PERFMON, set, reset); | |
| 149 | - break; | |
| 150 | -#endif /* CONFIG_PPC_PSERIES */ | |
| 151 | - | |
| 152 | - default: | |
| 153 | - break; | |
| 154 | - } | |
| 155 | - | |
| 156 | - /* instruct hypervisor to maintain PMCs */ | |
| 157 | - if (firmware_has_feature(FW_FEATURE_SPLPAR)) | |
| 158 | - get_paca()->lppaca.pmcregs_in_use = 1; | |
| 121 | + if (ppc_md.enable_pmcs) | |
| 122 | + ppc_md.enable_pmcs(); | |
| 159 | 123 | } |
| 160 | - | |
| 161 | -#else | |
| 162 | - | |
| 163 | -/* PMC stuff */ | |
| 164 | -void ppc64_enable_pmcs(void) | |
| 165 | -{ | |
| 166 | - /* XXX Implement for iseries */ | |
| 167 | -} | |
| 168 | -#endif /* CONFIG_PPC_MULTIPLATFORM */ | |
| 169 | - | |
| 170 | 124 | EXPORT_SYMBOL(ppc64_enable_pmcs); |
| 171 | 125 | |
| 172 | 126 | /* XXX convert to rusty's on_one_cpu */ |
include/asm-ppc64/machdep.h
| ... | ... | @@ -140,6 +140,9 @@ |
| 140 | 140 | |
| 141 | 141 | /* Idle loop for this platform, leave empty for default idle loop */ |
| 142 | 142 | int (*idle_loop)(void); |
| 143 | + | |
| 144 | + /* Function to enable pmcs for this platform, called once per cpu. */ | |
| 145 | + void (*enable_pmcs)(void); | |
| 143 | 146 | }; |
| 144 | 147 | |
| 145 | 148 | extern int default_idle(void); |