nmi.c (83bc90e11576f9c100f8ef4ba2bcd0b89212e3fb) nmi.c (494fc42170bf0747ac28e12ef13a7d388d5ff2c7)
1/* Pseudo NMI support on sparc64 systems.
2 *
3 * Copyright (C) 2009 David S. Miller <davem@davemloft.net>
4 *
5 * The NMI watchdog support and infrastructure is based almost
6 * entirely upon the x86 NMI support code.
7 */
8#include <linux/kernel.h>

--- 86 unchanged lines hidden (view full) ---

95
96 if (notify_die(DIE_NMI, "nmi", regs, 0,
97 pt_regs_trap_type(regs), SIGINT) == NOTIFY_STOP)
98 touched = 1;
99 else
100 pcr_ops->write_pcr(0, pcr_ops->pcr_nmi_disable);
101
102 sum = local_cpu_data().irq0_irqs;
1/* Pseudo NMI support on sparc64 systems.
2 *
3 * Copyright (C) 2009 David S. Miller <davem@davemloft.net>
4 *
5 * The NMI watchdog support and infrastructure is based almost
6 * entirely upon the x86 NMI support code.
7 */
8#include <linux/kernel.h>

--- 86 unchanged lines hidden (view full) ---

95
96 if (notify_die(DIE_NMI, "nmi", regs, 0,
97 pt_regs_trap_type(regs), SIGINT) == NOTIFY_STOP)
98 touched = 1;
99 else
100 pcr_ops->write_pcr(0, pcr_ops->pcr_nmi_disable);
101
102 sum = local_cpu_data().irq0_irqs;
103 if (__get_cpu_var(nmi_touch)) {
104 __get_cpu_var(nmi_touch) = 0;
103 if (__this_cpu_read(nmi_touch)) {
104 __this_cpu_write(nmi_touch, 0);
105 touched = 1;
106 }
105 touched = 1;
106 }
107 if (!touched && __get_cpu_var(last_irq_sum) == sum) {
107 if (!touched && __this_cpu_read(last_irq_sum) == sum) {
108 __this_cpu_inc(alert_counter);
109 if (__this_cpu_read(alert_counter) == 30 * nmi_hz)
110 die_nmi("BUG: NMI Watchdog detected LOCKUP",
111 regs, panic_on_timeout);
112 } else {
108 __this_cpu_inc(alert_counter);
109 if (__this_cpu_read(alert_counter) == 30 * nmi_hz)
110 die_nmi("BUG: NMI Watchdog detected LOCKUP",
111 regs, panic_on_timeout);
112 } else {
113 __get_cpu_var(last_irq_sum) = sum;
113 __this_cpu_write(last_irq_sum, sum);
114 __this_cpu_write(alert_counter, 0);
115 }
114 __this_cpu_write(alert_counter, 0);
115 }
116 if (__get_cpu_var(wd_enabled)) {
116 if (__this_cpu_read(wd_enabled)) {
117 pcr_ops->write_pic(0, pcr_ops->nmi_picl_value(nmi_hz));
118 pcr_ops->write_pcr(0, pcr_ops->pcr_nmi_enable);
119 }
120
121 restore_hardirq_stack(orig_sp);
122
123 nmi_exit();
124}

--- 24 unchanged lines hidden (view full) ---

149
150 per_cpu(wd_enabled, cpu) = 0;
151 atomic_dec(&nmi_active);
152}
153
154void stop_nmi_watchdog(void *unused)
155{
156 pcr_ops->write_pcr(0, pcr_ops->pcr_nmi_disable);
117 pcr_ops->write_pic(0, pcr_ops->nmi_picl_value(nmi_hz));
118 pcr_ops->write_pcr(0, pcr_ops->pcr_nmi_enable);
119 }
120
121 restore_hardirq_stack(orig_sp);
122
123 nmi_exit();
124}

--- 24 unchanged lines hidden (view full) ---

149
150 per_cpu(wd_enabled, cpu) = 0;
151 atomic_dec(&nmi_active);
152}
153
154void stop_nmi_watchdog(void *unused)
155{
156 pcr_ops->write_pcr(0, pcr_ops->pcr_nmi_disable);
157 __get_cpu_var(wd_enabled) = 0;
157 __this_cpu_write(wd_enabled, 0);
158 atomic_dec(&nmi_active);
159}
160
161static int __init check_nmi_watchdog(void)
162{
163 unsigned int *prev_nmi_count;
164 int cpu, err;
165

--- 36 unchanged lines hidden (view full) ---

202 return 0;
203error:
204 on_each_cpu(stop_nmi_watchdog, NULL, 1);
205 return err;
206}
207
208void start_nmi_watchdog(void *unused)
209{
158 atomic_dec(&nmi_active);
159}
160
161static int __init check_nmi_watchdog(void)
162{
163 unsigned int *prev_nmi_count;
164 int cpu, err;
165

--- 36 unchanged lines hidden (view full) ---

202 return 0;
203error:
204 on_each_cpu(stop_nmi_watchdog, NULL, 1);
205 return err;
206}
207
208void start_nmi_watchdog(void *unused)
209{
210 __get_cpu_var(wd_enabled) = 1;
210 __this_cpu_write(wd_enabled, 1);
211 atomic_inc(&nmi_active);
212
213 pcr_ops->write_pcr(0, pcr_ops->pcr_nmi_disable);
214 pcr_ops->write_pic(0, pcr_ops->nmi_picl_value(nmi_hz));
215
216 pcr_ops->write_pcr(0, pcr_ops->pcr_nmi_enable);
217}
218
219static void nmi_adjust_hz_one(void *unused)
220{
211 atomic_inc(&nmi_active);
212
213 pcr_ops->write_pcr(0, pcr_ops->pcr_nmi_disable);
214 pcr_ops->write_pic(0, pcr_ops->nmi_picl_value(nmi_hz));
215
216 pcr_ops->write_pcr(0, pcr_ops->pcr_nmi_enable);
217}
218
219static void nmi_adjust_hz_one(void *unused)
220{
221 if (!__get_cpu_var(wd_enabled))
221 if (!__this_cpu_read(wd_enabled))
222 return;
223
224 pcr_ops->write_pcr(0, pcr_ops->pcr_nmi_disable);
225 pcr_ops->write_pic(0, pcr_ops->nmi_picl_value(nmi_hz));
226
227 pcr_ops->write_pcr(0, pcr_ops->pcr_nmi_enable);
228}
229

--- 43 unchanged lines hidden ---
222 return;
223
224 pcr_ops->write_pcr(0, pcr_ops->pcr_nmi_disable);
225 pcr_ops->write_pic(0, pcr_ops->nmi_picl_value(nmi_hz));
226
227 pcr_ops->write_pcr(0, pcr_ops->pcr_nmi_enable);
228}
229

--- 43 unchanged lines hidden ---