Skip to content

Commit 180a336

Browse files
mpepaulusmack
authored andcommitted
[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 <[email protected]> Signed-off-by: Paul Mackerras <[email protected]>
1 parent b13cfd1 commit 180a336

File tree

7 files changed

+55
-50
lines changed

7 files changed

+55
-50
lines changed

arch/ppc64/kernel/iSeries_setup.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -964,6 +964,8 @@ void __init iSeries_early_setup(void)
964964
ppc_md.calibrate_decr = iSeries_calibrate_decr;
965965
ppc_md.progress = iSeries_progress;
966966

967+
/* XXX Implement enable_pmcs for iSeries */
968+
967969
if (get_paca()->lppaca.shared_proc) {
968970
ppc_md.idle_loop = iseries_shared_idle;
969971
printk(KERN_INFO "Using shared processor idle loop\n");

arch/ppc64/kernel/pSeries_setup.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
#include <asm/plpar_wrappers.h>
6262
#include <asm/xics.h>
6363
#include <asm/firmware.h>
64+
#include <asm/pmc.h>
6465

6566
#include "i8259.h"
6667
#include "mpic.h"
@@ -187,6 +188,21 @@ static void __init pSeries_setup_mpic(void)
187188
" MPIC ");
188189
}
189190

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+
190206
static void __init pSeries_setup_arch(void)
191207
{
192208
/* Fixup ppc_md depending on the type of interrupt controller */
@@ -245,6 +261,11 @@ static void __init pSeries_setup_arch(void)
245261
printk(KERN_INFO "Using default idle loop\n");
246262
ppc_md.idle_loop = default_idle;
247263
}
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;
248269
}
249270

250271
static int __init pSeries_init_panel(void)

arch/ppc64/kernel/pmac_setup.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
#include <asm/of_device.h>
7272
#include <asm/lmb.h>
7373
#include <asm/smu.h>
74+
#include <asm/pmc.h>
7475

7576
#include "pmac.h"
7677
#include "mpic.h"
@@ -511,4 +512,5 @@ struct machdep_calls __initdata pmac_md = {
511512
.progress = pmac_progress,
512513
.check_legacy_ioport = pmac_check_legacy_ioport,
513514
.idle_loop = native_idle,
515+
.enable_pmcs = power4_enable_pmcs,
514516
};

arch/ppc64/kernel/pmc.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,24 @@ void release_pmc_hardware(void)
6565
spin_unlock(&pmc_owner_lock);
6666
}
6767
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

Lines changed: 4 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ static int __init setup_smt_snooze_delay(char *str)
101101
}
102102
__setup("smt-snooze-delay=", setup_smt_snooze_delay);
103103

104+
#endif /* CONFIG_PPC_MULTIPLATFORM */
105+
104106
/*
105107
* Enabling PMCs will slow partition context switch times so we only do
106108
* it the first time we write to the PMCs.
@@ -110,63 +112,15 @@ static DEFINE_PER_CPU(char, pmcs_enabled);
110112

111113
void ppc64_enable_pmcs(void)
112114
{
113-
unsigned long hid0;
114-
#ifdef CONFIG_PPC_PSERIES
115-
unsigned long set, reset;
116-
#endif /* CONFIG_PPC_PSERIES */
117-
118115
/* Only need to enable them once */
119116
if (__get_cpu_var(pmcs_enabled))
120117
return;
121118

122119
__get_cpu_var(pmcs_enabled) = 1;
123120

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();
159123
}
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-
170124
EXPORT_SYMBOL(ppc64_enable_pmcs);
171125

172126
/* XXX convert to rusty's on_one_cpu */

include/asm-ppc64/machdep.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ struct machdep_calls {
140140

141141
/* Idle loop for this platform, leave empty for default idle loop */
142142
int (*idle_loop)(void);
143+
144+
/* Function to enable pmcs for this platform, called once per cpu. */
145+
void (*enable_pmcs)(void);
143146
};
144147

145148
extern int default_idle(void);

include/asm-ppc64/pmc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,6 @@ typedef void (*perf_irq_t)(struct pt_regs *);
2626
int reserve_pmc_hardware(perf_irq_t new_perf_irq);
2727
void release_pmc_hardware(void);
2828

29+
void power4_enable_pmcs(void);
30+
2931
#endif /* _PPC64_PMC_H */

0 commit comments

Comments
 (0)