aboutsummaryrefslogtreecommitdiff
path: root/kernel/watchdogtest.c
blob: db31c116ed1f1244f71ff4a118b573fa50d9550f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
 * Simple softlockup watchdog regression test module
 *
 * Copyright (C) 2012 Motorola Mobility LLC.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; version 2
 * of the License.
 */

#include <linux/completion.h>
#include <linux/workqueue.h>
#include <linux/irq.h>
#include <linux/preempt.h>
#include <linux/module.h>
#include <linux/debugfs.h>
#include <soc/qcom/mmi_watchdog.h>
#include <soc/qcom/watchdog.h>

#ifndef CONFIG_MSM_WATCHDOG_V2
struct completion wdt_timeout_complete;
static void wdt_timeout_work(struct work_struct *work)
{
	local_irq_disable();
	while (1)
	;
	local_irq_enable();
	complete(&wdt_timeout_complete);
}
static DECLARE_WORK(wdt_timeout_work_struct, wdt_timeout_work);
#endif

static int fire_watchdog_reset_set(void *data, u64 val)
{

	printk(KERN_WARNING "Fire hardware watchdog reset.\n");
	printk(KERN_WARNING "Please wait ...\n");
#ifdef CONFIG_MSM_WATCHDOG_V2
	msm_trigger_wdog_bite();
#else
	init_completion(&wdt_timeout_complete);
	schedule_work_on(0, &wdt_timeout_work_struct);
	wait_for_completion(&wdt_timeout_complete);
#endif
	return 0;
}
DEFINE_SIMPLE_ATTRIBUTE(fire_watchdog_reset_fops,
	NULL, fire_watchdog_reset_set, "%llu\n");

static int fire_softlockup_reset_set(void *data, u64 val)
{
	touch_hw_watchdog();

	printk(KERN_WARNING "Fire softlockup watchdog reset.\n");
	printk(KERN_WARNING "Please wait ...\n");
	preempt_disable();
	while (1)
	;

	return 0;
}
DEFINE_SIMPLE_ATTRIBUTE(fire_softlockup_reset_fops,
	NULL, fire_softlockup_reset_set, "%llu\n");

static int watchdog_test_init(void)
{
	debugfs_create_file("fire_softlockup_reset", 0200,
		NULL, NULL, &fire_softlockup_reset_fops);
	debugfs_create_file("fire_watchdog_reset", 0200,
		NULL, NULL, &fire_watchdog_reset_fops);
	return 0;
}

static void watchdog_test_exit(void)
{
}

module_init(watchdog_test_init);
module_exit(watchdog_test_exit);
MODULE_LICENSE("GPL");