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