aboutsummaryrefslogtreecommitdiffstats
path: root/arch/ppc64/kernel/pmc.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/ppc64/kernel/pmc.c
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'arch/ppc64/kernel/pmc.c')
-rw-r--r--arch/ppc64/kernel/pmc.c67
1 files changed, 67 insertions, 0 deletions
diff --git a/arch/ppc64/kernel/pmc.c b/arch/ppc64/kernel/pmc.c
new file mode 100644
index 000000000000..67be773f9c00
--- /dev/null
+++ b/arch/ppc64/kernel/pmc.c
@@ -0,0 +1,67 @@
1/*
2 * linux/arch/ppc64/kernel/pmc.c
3 *
4 * Copyright (C) 2004 David Gibson, IBM Corporation.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#include <linux/config.h>
13#include <linux/errno.h>
14#include <linux/spinlock.h>
15#include <linux/module.h>
16
17#include <asm/processor.h>
18#include <asm/pmc.h>
19
20/* Ensure exceptions are disabled */
21static void dummy_perf(struct pt_regs *regs)
22{
23 unsigned int mmcr0 = mfspr(SPRN_MMCR0);
24
25 mmcr0 &= ~(MMCR0_PMXE|MMCR0_PMAO);
26 mtspr(SPRN_MMCR0, mmcr0);
27}
28
29static spinlock_t pmc_owner_lock = SPIN_LOCK_UNLOCKED;
30static void *pmc_owner_caller; /* mostly for debugging */
31perf_irq_t perf_irq = dummy_perf;
32
33int reserve_pmc_hardware(perf_irq_t new_perf_irq)
34{
35 int err = 0;
36
37 spin_lock(&pmc_owner_lock);
38
39 if (pmc_owner_caller) {
40 printk(KERN_WARNING "reserve_pmc_hardware: "
41 "PMC hardware busy (reserved by caller %p)\n",
42 pmc_owner_caller);
43 err = -EBUSY;
44 goto out;
45 }
46
47 pmc_owner_caller = __builtin_return_address(0);
48 perf_irq = new_perf_irq ? : dummy_perf;
49
50 out:
51 spin_unlock(&pmc_owner_lock);
52 return err;
53}
54EXPORT_SYMBOL_GPL(reserve_pmc_hardware);
55
56void release_pmc_hardware(void)
57{
58 spin_lock(&pmc_owner_lock);
59
60 WARN_ON(! pmc_owner_caller);
61
62 pmc_owner_caller = NULL;
63 perf_irq = dummy_perf;
64
65 spin_unlock(&pmc_owner_lock);
66}
67EXPORT_SYMBOL_GPL(release_pmc_hardware);