]> rtime.felk.cvut.cz Git - zynq/linux.git/blobdiff - kernel/watchdog.c
Apply preempt_rt patch-4.9-rt1.patch.xz
[zynq/linux.git] / kernel / watchdog.c
index 9acb29f280ec95813612a913307e4dcaec8b7e03..caba6208041163c9a555229c603537d4bff5a38a 100644 (file)
@@ -315,6 +315,8 @@ static int is_softlockup(unsigned long touch_ts)
 
 #ifdef CONFIG_HARDLOCKUP_DETECTOR
 
+static DEFINE_RAW_SPINLOCK(watchdog_output_lock);
+
 static struct perf_event_attr wd_hw_attr = {
        .type           = PERF_TYPE_HARDWARE,
        .config         = PERF_COUNT_HW_CPU_CYCLES,
@@ -349,6 +351,13 @@ static void watchdog_overflow_callback(struct perf_event *event,
                /* only print hardlockups once */
                if (__this_cpu_read(hard_watchdog_warn) == true)
                        return;
+               /*
+                * If early-printk is enabled then make sure we do not
+                * lock up in printk() and kill console logging:
+                */
+               printk_kill();
+
+               raw_spin_lock(&watchdog_output_lock);
 
                pr_emerg("Watchdog detected hard LOCKUP on cpu %d", this_cpu);
                print_modules();
@@ -366,6 +375,7 @@ static void watchdog_overflow_callback(struct perf_event *event,
                                !test_and_set_bit(0, &hardlockup_allcpu_dumped))
                        trigger_allbutself_cpu_backtrace();
 
+               raw_spin_unlock(&watchdog_output_lock);
                if (hardlockup_panic)
                        nmi_panic(regs, "Hard LOCKUP");
 
@@ -513,6 +523,7 @@ static void watchdog_enable(unsigned int cpu)
        /* kick off the timer for the hardlockup detector */
        hrtimer_init(hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
        hrtimer->function = watchdog_timer_fn;
+       hrtimer->irqsafe = 1;
 
        /* Enable the perf event */
        watchdog_nmi_enable(cpu);