]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/blob - arch/arm/common/fiq_watchdog.c
FIQ: Implement WDT FIQ debugger
[sojka/nv-tegra/linux-3.10.git] / arch / arm / common / fiq_watchdog.c
1 /*
2  * Copyright (C) 2014 Google, Inc.
3  * Copyright (C) 2010-2015 NVIDIA Corporation.  All rights reserved.
4  *
5  * This software is licensed under the terms of the GNU General Public
6  * License version 2, as published by the Free Software Foundation, and
7  * may be copied, distributed, and modified under those terms.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  */
15
16 #include <linux/kernel.h>
17 #include <linux/spinlock.h>
18 #include <linux/pstore_ram.h>
19
20 #include "fiq_watchdog.h"
21 #include "fiq_debugger_priv.h"
22
23 static DEFINE_RAW_SPINLOCK(fiq_watchdog_lock);
24
25 static void fiq_watchdog_printf(struct fiq_debugger_output *output,
26                                 const char *fmt, ...)
27 {
28         char buf[256];
29         va_list ap;
30         int len;
31
32         va_start(ap, fmt);
33         len = vscnprintf(buf, sizeof(buf), fmt, ap);
34         va_end(ap);
35
36         ramoops_console_write_buf(buf, len);
37 }
38
39 struct fiq_debugger_output fiq_watchdog_output = {
40         .printf = fiq_watchdog_printf,
41 };
42
43 void fiq_watchdog_triggered(const struct pt_regs *regs, void *svc_sp)
44 {
45         char msg[24];
46         int len;
47
48         raw_spin_lock(&fiq_watchdog_lock);
49
50         len = scnprintf(msg, sizeof(msg), "watchdog fiq cpu %d\n",
51                         THREAD_INFO(svc_sp)->cpu);
52         ramoops_console_write_buf(msg, len);
53
54         fiq_debugger_dump_stacktrace(&fiq_watchdog_output, regs, 100, svc_sp);
55
56         raw_spin_unlock(&fiq_watchdog_lock);
57 }