]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - arch/sparc/oprofile/init.c
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-2.6
[mirror_ubuntu-artful-kernel.git] / arch / sparc / oprofile / init.c
CommitLineData
9550e59c
MH
1/**
2 * @file init.c
3 *
4 * @remark Copyright 2002 OProfile authors
5 * @remark Read the file COPYING
6 *
7 * @author John Levon <levon@movementarian.org>
8 */
9
10#include <linux/kernel.h>
11#include <linux/oprofile.h>
12#include <linux/errno.h>
13#include <linux/init.h>
c4a57435 14#include <linux/param.h> /* for HZ */
9550e59c 15
422e23ea 16#ifdef CONFIG_SPARC64
e5553a6d
DM
17#include <linux/notifier.h>
18#include <linux/rcupdate.h>
19#include <linux/kdebug.h>
20#include <asm/nmi.h>
422e23ea 21
e5553a6d
DM
22static int profile_timer_exceptions_notify(struct notifier_block *self,
23 unsigned long val, void *data)
422e23ea 24{
4e85f591 25 struct die_args *args = data;
e5553a6d 26 int ret = NOTIFY_DONE;
422e23ea 27
e5553a6d
DM
28 switch (val) {
29 case DIE_NMI:
30 oprofile_add_sample(args->regs, 0);
31 ret = NOTIFY_STOP;
32 break;
33 default:
34 break;
422e23ea 35 }
e5553a6d 36 return ret;
422e23ea
DM
37}
38
e5553a6d
DM
39static struct notifier_block profile_timer_exceptions_nb = {
40 .notifier_call = profile_timer_exceptions_notify,
41};
422e23ea 42
e5553a6d 43static int timer_start(void)
422e23ea 44{
e5553a6d
DM
45 if (register_die_notifier(&profile_timer_exceptions_nb))
46 return 1;
47 nmi_adjust_hz(HZ);
48 return 0;
422e23ea
DM
49}
50
422e23ea 51
e5553a6d 52static void timer_stop(void)
422e23ea 53{
e5553a6d
DM
54 nmi_adjust_hz(1);
55 unregister_die_notifier(&profile_timer_exceptions_nb);
56 synchronize_sched(); /* Allow already-started NMIs to complete. */
422e23ea
DM
57}
58
e5553a6d 59static int op_nmi_timer_init(struct oprofile_operations *ops)
422e23ea 60{
a8f22264 61 if (atomic_read(&nmi_active) <= 0)
422e23ea
DM
62 return -ENODEV;
63
e5553a6d
DM
64 ops->start = timer_start;
65 ops->stop = timer_stop;
422e23ea 66 ops->cpu_type = "timer";
e5553a6d 67 printk(KERN_INFO "oprofile: Using perfctr NMI timer interrupt.\n");
422e23ea
DM
68 return 0;
69}
70#endif
71
25ad2913 72int __init oprofile_arch_init(struct oprofile_operations *ops)
9550e59c 73{
422e23ea
DM
74 int ret = -ENODEV;
75
76#ifdef CONFIG_SPARC64
e5553a6d 77 ret = op_nmi_timer_init(ops);
422e23ea
DM
78 if (!ret)
79 return ret;
80#endif
81
82 return ret;
9550e59c
MH
83}
84
9550e59c
MH
85void oprofile_arch_exit(void)
86{
87}