aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86_64/kernel
diff options
context:
space:
mode:
authorDon Zickus <dzickus@redhat.com>2006-09-26 04:52:27 -0400
committerAndi Kleen <andi@basil.nowhere.org>2006-09-26 04:52:27 -0400
commit2fbe7b25c8edaf2d10e6c1a4cc9f8afe714c4764 (patch)
treee4012ae3cd4519cba1836668237f077c60fb1086 /arch/x86_64/kernel
parent957dc87c1bd849440f0eef27e2ade67387001e13 (diff)
[PATCH] i386/x86-64: Remove un/set_nmi_callback and reserve/release_lapic_nmi functions
Removes the un/set_nmi_callback and reserve/release_lapic_nmi functions as they are no longer needed. The various subsystems are modified to register with the die_notifier instead. Also includes compile fixes by Andrew Morton. Signed-off-by: Don Zickus <dzickus@redhat.com> Signed-off-by: Andi Kleen <ak@suse.de>
Diffstat (limited to 'arch/x86_64/kernel')
-rw-r--r--arch/x86_64/kernel/crash.c20
-rw-r--r--arch/x86_64/kernel/nmi.c102
2 files changed, 25 insertions, 97 deletions
diff --git a/arch/x86_64/kernel/crash.c b/arch/x86_64/kernel/crash.c
index d8d5750d6106..44c8af65325e 100644
--- a/arch/x86_64/kernel/crash.c
+++ b/arch/x86_64/kernel/crash.c
@@ -23,6 +23,7 @@
23#include <asm/nmi.h> 23#include <asm/nmi.h>
24#include <asm/hw_irq.h> 24#include <asm/hw_irq.h>
25#include <asm/mach_apic.h> 25#include <asm/mach_apic.h>
26#include <asm/kdebug.h>
26 27
27/* This keeps a track of which one is crashing cpu. */ 28/* This keeps a track of which one is crashing cpu. */
28static int crashing_cpu; 29static int crashing_cpu;
@@ -95,8 +96,18 @@ static void crash_save_self(struct pt_regs *regs)
95#ifdef CONFIG_SMP 96#ifdef CONFIG_SMP
96static atomic_t waiting_for_crash_ipi; 97static atomic_t waiting_for_crash_ipi;
97 98
98static int crash_nmi_callback(struct pt_regs *regs, int cpu) 99static int crash_nmi_callback(struct notifier_block *self,
100 unsigned long val, void *data)
99{ 101{
102 struct pt_regs *regs;
103 int cpu;
104
105 if (val != DIE_NMI)
106 return NOTIFY_OK;
107
108 regs = ((struct die_args *)data)->regs;
109 cpu = raw_smp_processor_id();
110
100 /* 111 /*
101 * Don't do anything if this handler is invoked on crashing cpu. 112 * Don't do anything if this handler is invoked on crashing cpu.
102 * Otherwise, system will completely hang. Crashing cpu can get 113 * Otherwise, system will completely hang. Crashing cpu can get
@@ -127,12 +138,17 @@ static void smp_send_nmi_allbutself(void)
127 * cpu hotplug shouldn't matter. 138 * cpu hotplug shouldn't matter.
128 */ 139 */
129 140
141static struct notifier_block crash_nmi_nb = {
142 .notifier_call = crash_nmi_callback,
143};
144
130static void nmi_shootdown_cpus(void) 145static void nmi_shootdown_cpus(void)
131{ 146{
132 unsigned long msecs; 147 unsigned long msecs;
133 148
134 atomic_set(&waiting_for_crash_ipi, num_online_cpus() - 1); 149 atomic_set(&waiting_for_crash_ipi, num_online_cpus() - 1);
135 set_nmi_callback(crash_nmi_callback); 150 if (register_die_notifier(&crash_nmi_nb))
151 return; /* return what? */
136 152
137 /* 153 /*
138 * Ensure the new callback function is set before sending 154 * Ensure the new callback function is set before sending
diff --git a/arch/x86_64/kernel/nmi.c b/arch/x86_64/kernel/nmi.c
index f6b881b23a70..9d175dcf3a2d 100644
--- a/arch/x86_64/kernel/nmi.c
+++ b/arch/x86_64/kernel/nmi.c
@@ -41,20 +41,6 @@ static DEFINE_PER_CPU(unsigned, evntsel_nmi_owner[2]);
41 */ 41 */
42#define NMI_MAX_COUNTER_BITS 66 42#define NMI_MAX_COUNTER_BITS 66
43 43
44/*
45 * lapic_nmi_owner tracks the ownership of the lapic NMI hardware:
46 * - it may be reserved by some other driver, or not
47 * - when not reserved by some other driver, it may be used for
48 * the NMI watchdog, or not
49 *
50 * This is maintained separately from nmi_active because the NMI
51 * watchdog may also be driven from the I/O APIC timer.
52 */
53static DEFINE_SPINLOCK(lapic_nmi_owner_lock);
54static unsigned int lapic_nmi_owner;
55#define LAPIC_NMI_WATCHDOG (1<<0)
56#define LAPIC_NMI_RESERVED (1<<1)
57
58/* nmi_active: 44/* nmi_active:
59 * >0: the lapic NMI watchdog is active, but can be disabled 45 * >0: the lapic NMI watchdog is active, but can be disabled
60 * <0: the lapic NMI watchdog has not been set up, and cannot 46 * <0: the lapic NMI watchdog has not been set up, and cannot
@@ -321,33 +307,6 @@ static void enable_lapic_nmi_watchdog(void)
321 touch_nmi_watchdog(); 307 touch_nmi_watchdog();
322} 308}
323 309
324int reserve_lapic_nmi(void)
325{
326 unsigned int old_owner;
327
328 spin_lock(&lapic_nmi_owner_lock);
329 old_owner = lapic_nmi_owner;
330 lapic_nmi_owner |= LAPIC_NMI_RESERVED;
331 spin_unlock(&lapic_nmi_owner_lock);
332 if (old_owner & LAPIC_NMI_RESERVED)
333 return -EBUSY;
334 if (old_owner & LAPIC_NMI_WATCHDOG)
335 disable_lapic_nmi_watchdog();
336 return 0;
337}
338
339void release_lapic_nmi(void)
340{
341 unsigned int new_owner;
342
343 spin_lock(&lapic_nmi_owner_lock);
344 new_owner = lapic_nmi_owner & ~LAPIC_NMI_RESERVED;
345 lapic_nmi_owner = new_owner;
346 spin_unlock(&lapic_nmi_owner_lock);
347 if (new_owner & LAPIC_NMI_WATCHDOG)
348 enable_lapic_nmi_watchdog();
349}
350
351void disable_timer_nmi_watchdog(void) 310void disable_timer_nmi_watchdog(void)
352{ 311{
353 BUG_ON(nmi_watchdog != NMI_IO_APIC); 312 BUG_ON(nmi_watchdog != NMI_IO_APIC);
@@ -762,13 +721,6 @@ done:
762 return rc; 721 return rc;
763} 722}
764 723
765static __kprobes int dummy_nmi_callback(struct pt_regs * regs, int cpu)
766{
767 return 0;
768}
769
770static nmi_callback_t nmi_callback = dummy_nmi_callback;
771
772asmlinkage __kprobes void do_nmi(struct pt_regs * regs, long error_code) 724asmlinkage __kprobes void do_nmi(struct pt_regs * regs, long error_code)
773{ 725{
774 nmi_enter(); 726 nmi_enter();
@@ -779,21 +731,12 @@ asmlinkage __kprobes void do_nmi(struct pt_regs * regs, long error_code)
779 731
780int do_nmi_callback(struct pt_regs * regs, int cpu) 732int do_nmi_callback(struct pt_regs * regs, int cpu)
781{ 733{
782 return rcu_dereference(nmi_callback)(regs, cpu); 734#ifdef CONFIG_SYSCTL
783} 735 if (unknown_nmi_panic)
784 736 return unknown_nmi_panic_callback(regs, cpu);
785void set_nmi_callback(nmi_callback_t callback) 737#endif
786{ 738 return 0;
787 vmalloc_sync_all();
788 rcu_assign_pointer(nmi_callback, callback);
789}
790EXPORT_SYMBOL_GPL(set_nmi_callback);
791
792void unset_nmi_callback(void)
793{
794 nmi_callback = dummy_nmi_callback;
795} 739}
796EXPORT_SYMBOL_GPL(unset_nmi_callback);
797 740
798#ifdef CONFIG_SYSCTL 741#ifdef CONFIG_SYSCTL
799 742
@@ -802,37 +745,8 @@ static int unknown_nmi_panic_callback(struct pt_regs *regs, int cpu)
802 unsigned char reason = get_nmi_reason(); 745 unsigned char reason = get_nmi_reason();
803 char buf[64]; 746 char buf[64];
804 747
805 if (!(reason & 0xc0)) { 748 sprintf(buf, "NMI received for unknown reason %02x\n", reason);
806 sprintf(buf, "NMI received for unknown reason %02x\n", reason); 749 die_nmi(buf,regs);
807 die_nmi(buf,regs);
808 }
809 return 0;
810}
811
812/*
813 * proc handler for /proc/sys/kernel/unknown_nmi_panic
814 */
815int proc_unknown_nmi_panic(struct ctl_table *table, int write, struct file *file,
816 void __user *buffer, size_t *length, loff_t *ppos)
817{
818 int old_state;
819
820 old_state = unknown_nmi_panic;
821 proc_dointvec(table, write, file, buffer, length, ppos);
822 if (!!old_state == !!unknown_nmi_panic)
823 return 0;
824
825 if (unknown_nmi_panic) {
826 if (reserve_lapic_nmi() < 0) {
827 unknown_nmi_panic = 0;
828 return -EBUSY;
829 } else {
830 set_nmi_callback(unknown_nmi_panic_callback);
831 }
832 } else {
833 release_lapic_nmi();
834 unset_nmi_callback();
835 }
836 return 0; 750 return 0;
837} 751}
838 752
@@ -846,8 +760,6 @@ EXPORT_SYMBOL(reserve_perfctr_nmi);
846EXPORT_SYMBOL(release_perfctr_nmi); 760EXPORT_SYMBOL(release_perfctr_nmi);
847EXPORT_SYMBOL(reserve_evntsel_nmi); 761EXPORT_SYMBOL(reserve_evntsel_nmi);
848EXPORT_SYMBOL(release_evntsel_nmi); 762EXPORT_SYMBOL(release_evntsel_nmi);
849EXPORT_SYMBOL(reserve_lapic_nmi);
850EXPORT_SYMBOL(release_lapic_nmi);
851EXPORT_SYMBOL(disable_timer_nmi_watchdog); 763EXPORT_SYMBOL(disable_timer_nmi_watchdog);
852EXPORT_SYMBOL(enable_timer_nmi_watchdog); 764EXPORT_SYMBOL(enable_timer_nmi_watchdog);
853EXPORT_SYMBOL(touch_nmi_watchdog); 765EXPORT_SYMBOL(touch_nmi_watchdog);