diff options
author | David Gibson <david@gibson.dropbear.id.au> | 2005-10-19 00:53:32 -0400 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2005-10-20 02:22:24 -0400 |
commit | f7f6f4fea68d9981d65f99a589ad85f510924d99 (patch) | |
tree | 99eea889bb2ec2967a2be883a63ef58507a25cf9 | |
parent | 3d904eef54fd145e2ae5fadb52d2c39bc49339ae (diff) |
[PATCH] powerpc: Merge ppc64 pmc.[ch] with ppc32 perfmon.[ch]
This patches the ppc32 and ppc64 versions of the headers and .c files
with helper functions for manipulating the performance counting
hardware. As a side effect, it removes use of the term "perfmon" from
ppc32, thus avoiding confusion with the unrelated performance counter
interface from HP Labs also called "perfmon".
Built, but not booted, for g5, pSeries, iSeries, and 32-bit Powermac
with both ARCH=powerpc and ARCH=ppc{,64} as appropriate.
Signed-off-by: David Gibson <dwg@au1.ibm.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
-rw-r--r-- | arch/powerpc/kernel/Makefile | 2 | ||||
-rw-r--r-- | arch/powerpc/kernel/pmc.c (renamed from arch/ppc64/kernel/pmc.c) | 26 | ||||
-rw-r--r-- | arch/powerpc/kernel/traps.c | 3 | ||||
-rw-r--r-- | arch/powerpc/oprofile/common.c | 4 | ||||
-rw-r--r-- | arch/powerpc/oprofile/op_model_fsl_booke.c | 2 | ||||
-rw-r--r-- | arch/ppc/kernel/Makefile | 4 | ||||
-rw-r--r-- | arch/ppc/kernel/perfmon.c | 96 | ||||
-rw-r--r-- | arch/ppc/kernel/perfmon_fsl_booke.c | 2 | ||||
-rw-r--r-- | arch/ppc/kernel/traps.c | 2 | ||||
-rw-r--r-- | arch/ppc64/kernel/Makefile | 2 | ||||
-rw-r--r-- | include/asm-powerpc/pmc.h (renamed from include/asm-ppc64/pmc.h) | 21 | ||||
-rw-r--r-- | include/asm-ppc/perfmon.h | 22 |
12 files changed, 51 insertions, 135 deletions
diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile index b347ac320252..6b0f176265e3 100644 --- a/arch/powerpc/kernel/Makefile +++ b/arch/powerpc/kernel/Makefile | |||
@@ -11,7 +11,7 @@ CFLAGS_btext.o += -fPIC | |||
11 | endif | 11 | endif |
12 | 12 | ||
13 | obj-y := semaphore.o cputable.o ptrace.o syscalls.o \ | 13 | obj-y := semaphore.o cputable.o ptrace.o syscalls.o \ |
14 | signal_32.o | 14 | signal_32.o pmc.o |
15 | obj-$(CONFIG_PPC64) += binfmt_elf32.o sys_ppc32.o ptrace32.o | 15 | obj-$(CONFIG_PPC64) += binfmt_elf32.o sys_ppc32.o ptrace32.o |
16 | obj-$(CONFIG_ALTIVEC) += vecemu.o vector.o | 16 | obj-$(CONFIG_ALTIVEC) += vecemu.o vector.o |
17 | obj-$(CONFIG_POWER4) += idle_power4.o | 17 | obj-$(CONFIG_POWER4) += idle_power4.o |
diff --git a/arch/ppc64/kernel/pmc.c b/arch/powerpc/kernel/pmc.c index 944d7df7935f..2d333cc84082 100644 --- a/arch/ppc64/kernel/pmc.c +++ b/arch/powerpc/kernel/pmc.c | |||
@@ -1,7 +1,10 @@ | |||
1 | /* | 1 | /* |
2 | * linux/arch/ppc64/kernel/pmc.c | 2 | * arch/powerpc/kernel/pmc.c |
3 | * | 3 | * |
4 | * Copyright (C) 2004 David Gibson, IBM Corporation. | 4 | * Copyright (C) 2004 David Gibson, IBM Corporation. |
5 | * Includes code formerly from arch/ppc/kernel/perfmon.c: | ||
6 | * Author: Andy Fleming | ||
7 | * Copyright (c) 2004 Freescale Semiconductor, Inc | ||
5 | * | 8 | * |
6 | * This program is free software; you can redistribute it and/or | 9 | * This program is free software; you can redistribute it and/or |
7 | * modify it under the terms of the GNU General Public License | 10 | * modify it under the terms of the GNU General Public License |
@@ -17,6 +20,20 @@ | |||
17 | #include <asm/processor.h> | 20 | #include <asm/processor.h> |
18 | #include <asm/pmc.h> | 21 | #include <asm/pmc.h> |
19 | 22 | ||
23 | #if defined(CONFIG_FSL_BOOKE) && !defined(CONFIG_E200) | ||
24 | static void dummy_perf(struct pt_regs *regs) | ||
25 | { | ||
26 | unsigned int pmgc0 = mfpmr(PMRN_PMGC0); | ||
27 | |||
28 | pmgc0 &= ~PMGC0_PMIE; | ||
29 | mtpmr(PMRN_PMGC0, pmgc0); | ||
30 | } | ||
31 | #elif defined(CONFIG_PPC64) || defined(CONFIG_6xx) | ||
32 | |||
33 | #ifndef MMCR0_PMAO | ||
34 | #define MMCR0_PMAO 0 | ||
35 | #endif | ||
36 | |||
20 | /* Ensure exceptions are disabled */ | 37 | /* Ensure exceptions are disabled */ |
21 | static void dummy_perf(struct pt_regs *regs) | 38 | static void dummy_perf(struct pt_regs *regs) |
22 | { | 39 | { |
@@ -25,6 +42,11 @@ static void dummy_perf(struct pt_regs *regs) | |||
25 | mmcr0 &= ~(MMCR0_PMXE|MMCR0_PMAO); | 42 | mmcr0 &= ~(MMCR0_PMXE|MMCR0_PMAO); |
26 | mtspr(SPRN_MMCR0, mmcr0); | 43 | mtspr(SPRN_MMCR0, mmcr0); |
27 | } | 44 | } |
45 | #else | ||
46 | static void dummy_perf(struct pt_regs *regs) | ||
47 | { | ||
48 | } | ||
49 | #endif | ||
28 | 50 | ||
29 | static DEFINE_SPINLOCK(pmc_owner_lock); | 51 | static DEFINE_SPINLOCK(pmc_owner_lock); |
30 | static void *pmc_owner_caller; /* mostly for debugging */ | 52 | static void *pmc_owner_caller; /* mostly for debugging */ |
@@ -66,6 +88,7 @@ void release_pmc_hardware(void) | |||
66 | } | 88 | } |
67 | EXPORT_SYMBOL_GPL(release_pmc_hardware); | 89 | EXPORT_SYMBOL_GPL(release_pmc_hardware); |
68 | 90 | ||
91 | #ifdef CONFIG_PPC64 | ||
69 | void power4_enable_pmcs(void) | 92 | void power4_enable_pmcs(void) |
70 | { | 93 | { |
71 | unsigned long hid0; | 94 | unsigned long hid0; |
@@ -86,3 +109,4 @@ void power4_enable_pmcs(void) | |||
86 | "isync" : "=&r" (hid0) : "i" (SPRN_HID0), "0" (hid0): | 109 | "isync" : "=&r" (hid0) : "i" (SPRN_HID0), "0" (hid0): |
87 | "memory"); | 110 | "memory"); |
88 | } | 111 | } |
112 | #endif /* CONFIG_PPC64 */ | ||
diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c index 6a881e3ea01d..f87580382da4 100644 --- a/arch/powerpc/kernel/traps.c +++ b/arch/powerpc/kernel/traps.c | |||
@@ -40,9 +40,9 @@ | |||
40 | #include <asm/machdep.h> | 40 | #include <asm/machdep.h> |
41 | #include <asm/rtas.h> | 41 | #include <asm/rtas.h> |
42 | #include <asm/xmon.h> | 42 | #include <asm/xmon.h> |
43 | #include <asm/pmc.h> | ||
43 | #ifdef CONFIG_PPC32 | 44 | #ifdef CONFIG_PPC32 |
44 | #include <asm/reg.h> | 45 | #include <asm/reg.h> |
45 | #include <asm/perfmon.h> | ||
46 | #endif | 46 | #endif |
47 | #ifdef CONFIG_PMAC_BACKLIGHT | 47 | #ifdef CONFIG_PMAC_BACKLIGHT |
48 | #include <asm/backlight.h> | 48 | #include <asm/backlight.h> |
@@ -51,7 +51,6 @@ | |||
51 | #include <asm/firmware.h> | 51 | #include <asm/firmware.h> |
52 | #include <asm/processor.h> | 52 | #include <asm/processor.h> |
53 | #include <asm/systemcfg.h> | 53 | #include <asm/systemcfg.h> |
54 | #include <asm/pmc.h> | ||
55 | #endif | 54 | #endif |
56 | 55 | ||
57 | #ifdef CONFIG_PPC64 /* XXX */ | 56 | #ifdef CONFIG_PPC64 /* XXX */ |
diff --git a/arch/powerpc/oprofile/common.c b/arch/powerpc/oprofile/common.c index 0ec12c8f2c01..af2c05d20ba5 100644 --- a/arch/powerpc/oprofile/common.c +++ b/arch/powerpc/oprofile/common.c | |||
@@ -22,11 +22,7 @@ | |||
22 | #include <linux/errno.h> | 22 | #include <linux/errno.h> |
23 | #include <asm/ptrace.h> | 23 | #include <asm/ptrace.h> |
24 | #include <asm/system.h> | 24 | #include <asm/system.h> |
25 | #ifdef __powerpc64__ | ||
26 | #include <asm/pmc.h> | 25 | #include <asm/pmc.h> |
27 | #else /* __powerpc64__ */ | ||
28 | #include <asm/perfmon.h> | ||
29 | #endif /* __powerpc64__ */ | ||
30 | #include <asm/cputable.h> | 26 | #include <asm/cputable.h> |
31 | #include <asm/oprofile_impl.h> | 27 | #include <asm/oprofile_impl.h> |
32 | 28 | ||
diff --git a/arch/powerpc/oprofile/op_model_fsl_booke.c b/arch/powerpc/oprofile/op_model_fsl_booke.c index 1917f8df8a8b..86124a94c9af 100644 --- a/arch/powerpc/oprofile/op_model_fsl_booke.c +++ b/arch/powerpc/oprofile/op_model_fsl_booke.c | |||
@@ -24,7 +24,7 @@ | |||
24 | #include <asm/cputable.h> | 24 | #include <asm/cputable.h> |
25 | #include <asm/reg_booke.h> | 25 | #include <asm/reg_booke.h> |
26 | #include <asm/page.h> | 26 | #include <asm/page.h> |
27 | #include <asm/perfmon.h> | 27 | #include <asm/pmc.h> |
28 | #include <asm/oprofile_impl.h> | 28 | #include <asm/oprofile_impl.h> |
29 | 29 | ||
30 | static unsigned long reset_value[OP_MAX_COUNTER]; | 30 | static unsigned long reset_value[OP_MAX_COUNTER]; |
diff --git a/arch/ppc/kernel/Makefile b/arch/ppc/kernel/Makefile index ccbc442c9ed3..b35346df1e37 100644 --- a/arch/ppc/kernel/Makefile +++ b/arch/ppc/kernel/Makefile | |||
@@ -15,7 +15,7 @@ extra-y += vmlinux.lds | |||
15 | obj-y := entry.o traps.o irq.o idle.o time.o misc.o \ | 15 | obj-y := entry.o traps.o irq.o idle.o time.o misc.o \ |
16 | process.o align.o \ | 16 | process.o align.o \ |
17 | setup.o \ | 17 | setup.o \ |
18 | ppc_htab.o perfmon.o | 18 | ppc_htab.o |
19 | obj-$(CONFIG_6xx) += l2cr.o cpu_setup_6xx.o | 19 | obj-$(CONFIG_6xx) += l2cr.o cpu_setup_6xx.o |
20 | obj-$(CONFIG_SOFTWARE_SUSPEND) += swsusp.o | 20 | obj-$(CONFIG_SOFTWARE_SUSPEND) += swsusp.o |
21 | obj-$(CONFIG_POWER4) += cpu_setup_power4.o | 21 | obj-$(CONFIG_POWER4) += cpu_setup_power4.o |
@@ -38,7 +38,7 @@ endif | |||
38 | 38 | ||
39 | else | 39 | else |
40 | obj-y := irq.o idle.o \ | 40 | obj-y := irq.o idle.o \ |
41 | align.o perfmon.o | 41 | align.o |
42 | obj-$(CONFIG_6xx) += l2cr.o cpu_setup_6xx.o | 42 | obj-$(CONFIG_6xx) += l2cr.o cpu_setup_6xx.o |
43 | obj-$(CONFIG_SOFTWARE_SUSPEND) += swsusp.o | 43 | obj-$(CONFIG_SOFTWARE_SUSPEND) += swsusp.o |
44 | obj-$(CONFIG_MODULES) += module.o | 44 | obj-$(CONFIG_MODULES) += module.o |
diff --git a/arch/ppc/kernel/perfmon.c b/arch/ppc/kernel/perfmon.c deleted file mode 100644 index c9a38dd0cdc4..000000000000 --- a/arch/ppc/kernel/perfmon.c +++ /dev/null | |||
@@ -1,96 +0,0 @@ | |||
1 | /* kernel/perfmon.c | ||
2 | * PPC 32 Performance Monitor Infrastructure | ||
3 | * | ||
4 | * Author: Andy Fleming | ||
5 | * Copyright (c) 2004 Freescale Semiconductor, Inc | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * as published by the Free Software Foundation; either version | ||
10 | * 2 of the License, or (at your option) any later version. | ||
11 | */ | ||
12 | |||
13 | #include <linux/errno.h> | ||
14 | #include <linux/sched.h> | ||
15 | #include <linux/kernel.h> | ||
16 | #include <linux/mm.h> | ||
17 | #include <linux/stddef.h> | ||
18 | #include <linux/unistd.h> | ||
19 | #include <linux/ptrace.h> | ||
20 | #include <linux/slab.h> | ||
21 | #include <linux/user.h> | ||
22 | #include <linux/a.out.h> | ||
23 | #include <linux/interrupt.h> | ||
24 | #include <linux/config.h> | ||
25 | #include <linux/init.h> | ||
26 | #include <linux/module.h> | ||
27 | #include <linux/prctl.h> | ||
28 | |||
29 | #include <asm/pgtable.h> | ||
30 | #include <asm/uaccess.h> | ||
31 | #include <asm/system.h> | ||
32 | #include <asm/io.h> | ||
33 | #include <asm/reg.h> | ||
34 | #include <asm/xmon.h> | ||
35 | |||
36 | /* A lock to regulate grabbing the interrupt */ | ||
37 | DEFINE_SPINLOCK(perfmon_lock); | ||
38 | |||
39 | #if defined (CONFIG_FSL_BOOKE) && !defined (CONFIG_E200) | ||
40 | static void dummy_perf(struct pt_regs *regs) | ||
41 | { | ||
42 | unsigned int pmgc0 = mfpmr(PMRN_PMGC0); | ||
43 | |||
44 | pmgc0 &= ~PMGC0_PMIE; | ||
45 | mtpmr(PMRN_PMGC0, pmgc0); | ||
46 | } | ||
47 | |||
48 | #elif defined(CONFIG_6xx) | ||
49 | /* Ensure exceptions are disabled */ | ||
50 | static void dummy_perf(struct pt_regs *regs) | ||
51 | { | ||
52 | unsigned int mmcr0 = mfspr(SPRN_MMCR0); | ||
53 | |||
54 | mmcr0 &= ~MMCR0_PMXE; | ||
55 | mtspr(SPRN_MMCR0, mmcr0); | ||
56 | } | ||
57 | #else | ||
58 | static void dummy_perf(struct pt_regs *regs) | ||
59 | { | ||
60 | } | ||
61 | #endif | ||
62 | |||
63 | void (*perf_irq)(struct pt_regs *) = dummy_perf; | ||
64 | |||
65 | /* Grab the interrupt, if it's free. | ||
66 | * Returns 0 on success, -1 if the interrupt is taken already */ | ||
67 | int reserve_pmc_hardware(void (*handler)(struct pt_regs *)) | ||
68 | { | ||
69 | int err = 0; | ||
70 | |||
71 | spin_lock(&perfmon_lock); | ||
72 | |||
73 | if (perf_irq == dummy_perf) | ||
74 | perf_irq = handler; | ||
75 | else { | ||
76 | pr_info("perfmon irq already handled by %p\n", perf_irq); | ||
77 | err = -EBUSY; | ||
78 | } | ||
79 | |||
80 | spin_unlock(&perfmon_lock); | ||
81 | |||
82 | return err; | ||
83 | } | ||
84 | |||
85 | void release_pmc_hardware(void) | ||
86 | { | ||
87 | spin_lock(&perfmon_lock); | ||
88 | |||
89 | perf_irq = dummy_perf; | ||
90 | |||
91 | spin_unlock(&perfmon_lock); | ||
92 | } | ||
93 | |||
94 | EXPORT_SYMBOL(perf_irq); | ||
95 | EXPORT_SYMBOL(reserve_pmc_hardware); | ||
96 | EXPORT_SYMBOL(release_pmc_hardware); | ||
diff --git a/arch/ppc/kernel/perfmon_fsl_booke.c b/arch/ppc/kernel/perfmon_fsl_booke.c index 03526bfb0840..32455dfcc36b 100644 --- a/arch/ppc/kernel/perfmon_fsl_booke.c +++ b/arch/ppc/kernel/perfmon_fsl_booke.c | |||
@@ -32,7 +32,7 @@ | |||
32 | #include <asm/io.h> | 32 | #include <asm/io.h> |
33 | #include <asm/reg.h> | 33 | #include <asm/reg.h> |
34 | #include <asm/xmon.h> | 34 | #include <asm/xmon.h> |
35 | #include <asm/perfmon.h> | 35 | #include <asm/pmc.h> |
36 | 36 | ||
37 | static inline u32 get_pmlca(int ctr); | 37 | static inline u32 get_pmlca(int ctr); |
38 | static inline void set_pmlca(int ctr, u32 pmlca); | 38 | static inline void set_pmlca(int ctr, u32 pmlca); |
diff --git a/arch/ppc/kernel/traps.c b/arch/ppc/kernel/traps.c index 3145e9773db9..5e4bf88a1ef5 100644 --- a/arch/ppc/kernel/traps.c +++ b/arch/ppc/kernel/traps.c | |||
@@ -41,7 +41,7 @@ | |||
41 | #ifdef CONFIG_PMAC_BACKLIGHT | 41 | #ifdef CONFIG_PMAC_BACKLIGHT |
42 | #include <asm/backlight.h> | 42 | #include <asm/backlight.h> |
43 | #endif | 43 | #endif |
44 | #include <asm/perfmon.h> | 44 | #include <asm/pmc.h> |
45 | 45 | ||
46 | #ifdef CONFIG_XMON | 46 | #ifdef CONFIG_XMON |
47 | extern int xmon_bpt(struct pt_regs *regs); | 47 | extern int xmon_bpt(struct pt_regs *regs); |
diff --git a/arch/ppc64/kernel/Makefile b/arch/ppc64/kernel/Makefile index 18f477fa1df2..6cce419f4b09 100644 --- a/arch/ppc64/kernel/Makefile +++ b/arch/ppc64/kernel/Makefile | |||
@@ -17,7 +17,7 @@ obj-y += irq.o idle.o dma.o \ | |||
17 | udbg.o ioctl32.o \ | 17 | udbg.o ioctl32.o \ |
18 | rtc.o \ | 18 | rtc.o \ |
19 | cpu_setup_power4.o \ | 19 | cpu_setup_power4.o \ |
20 | iommu.o sysfs.o vdso.o pmc.o firmware.o | 20 | iommu.o sysfs.o vdso.o firmware.o |
21 | obj-y += vdso32/ vdso64/ | 21 | obj-y += vdso32/ vdso64/ |
22 | 22 | ||
23 | pci-obj-$(CONFIG_PPC_MULTIPLATFORM) += pci_dn.o pci_direct_iommu.o | 23 | pci-obj-$(CONFIG_PPC_MULTIPLATFORM) += pci_dn.o pci_direct_iommu.o |
diff --git a/include/asm-ppc64/pmc.h b/include/asm-powerpc/pmc.h index d1d297dbccfe..2f3c3fc2b796 100644 --- a/include/asm-ppc64/pmc.h +++ b/include/asm-powerpc/pmc.h | |||
@@ -16,8 +16,8 @@ | |||
16 | * along with this program; if not, write to the Free Software | 16 | * along with this program; if not, write to the Free Software |
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 | */ | 18 | */ |
19 | #ifndef _PPC64_PMC_H | 19 | #ifndef _POWERPC_PMC_H |
20 | #define _PPC64_PMC_H | 20 | #define _POWERPC_PMC_H |
21 | 21 | ||
22 | #include <asm/ptrace.h> | 22 | #include <asm/ptrace.h> |
23 | 23 | ||
@@ -26,6 +26,21 @@ typedef void (*perf_irq_t)(struct pt_regs *); | |||
26 | int reserve_pmc_hardware(perf_irq_t new_perf_irq); | 26 | int reserve_pmc_hardware(perf_irq_t new_perf_irq); |
27 | void release_pmc_hardware(void); | 27 | void release_pmc_hardware(void); |
28 | 28 | ||
29 | #ifdef CONFIG_PPC64 | ||
29 | void power4_enable_pmcs(void); | 30 | void power4_enable_pmcs(void); |
31 | #endif | ||
30 | 32 | ||
31 | #endif /* _PPC64_PMC_H */ | 33 | #ifdef CONFIG_FSL_BOOKE |
34 | void init_pmc_stop(int ctr); | ||
35 | void set_pmc_event(int ctr, int event); | ||
36 | void set_pmc_user_kernel(int ctr, int user, int kernel); | ||
37 | void set_pmc_marked(int ctr, int mark0, int mark1); | ||
38 | void pmc_start_ctr(int ctr, int enable); | ||
39 | void pmc_start_ctrs(int enable); | ||
40 | void pmc_stop_ctrs(void); | ||
41 | void dump_pmcs(void); | ||
42 | |||
43 | extern struct op_powerpc_model op_model_fsl_booke; | ||
44 | #endif | ||
45 | |||
46 | #endif /* _POWERPC_PMC_H */ | ||
diff --git a/include/asm-ppc/perfmon.h b/include/asm-ppc/perfmon.h deleted file mode 100644 index 2ae031594a4e..000000000000 --- a/include/asm-ppc/perfmon.h +++ /dev/null | |||
@@ -1,22 +0,0 @@ | |||
1 | #ifndef __PERFMON_H | ||
2 | #define __PERFMON_H | ||
3 | |||
4 | extern void (*perf_irq)(struct pt_regs *); | ||
5 | |||
6 | int reserve_pmc_hardware(void (*handler)(struct pt_regs *)); | ||
7 | void release_pmc_hardware(void); | ||
8 | |||
9 | #ifdef CONFIG_FSL_BOOKE | ||
10 | void init_pmc_stop(int ctr); | ||
11 | void set_pmc_event(int ctr, int event); | ||
12 | void set_pmc_user_kernel(int ctr, int user, int kernel); | ||
13 | void set_pmc_marked(int ctr, int mark0, int mark1); | ||
14 | void pmc_start_ctr(int ctr, int enable); | ||
15 | void pmc_start_ctrs(int enable); | ||
16 | void pmc_stop_ctrs(void); | ||
17 | void dump_pmcs(void); | ||
18 | |||
19 | extern struct op_powerpc_model op_model_fsl_booke; | ||
20 | #endif | ||
21 | |||
22 | #endif /* __PERFMON_H */ | ||