11 #define KMSG_COMPONENT "vmwatchdog"
12 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
16 #include <linux/kernel.h>
18 #include <linux/module.h>
20 #include <linux/slab.h>
22 #include <linux/watchdog.h>
26 #include <asm/uaccess.h>
28 #define MAX_CMDLEN 240
29 #define MIN_INTERVAL 15
31 static bool vmwdt_conceal;
45 " (default=CONFIG_WATCHDOG_NOWAYOUT)");
48 static unsigned int vmwdt_interval = 60;
49 static unsigned long vmwdt_is_open;
50 static int vmwdt_expect_close;
55 #define VMWDT_RUNNING 1
67 char *
cmd,
size_t len)
69 register unsigned long __func
asm(
"2") = func;
70 register unsigned long __timeout
asm(
"3") = timeout;
71 register unsigned long __cmdp
asm(
"4") =
virt_to_phys(cmd);
72 register unsigned long __cmdl
asm(
"5") = len;
81 :
"+d" (
err) :
"d"(__func),
"d"(__timeout),
82 "d"(__cmdp),
"d"(__cmdl) :
"1",
"cc");
86 static int vmwdt_keepalive(
void)
107 ret = __diag288(func, vmwdt_interval, ebc_cmd, len);
113 static int vmwdt_disable(
void)
121 static int __init vmwdt_probe(
void)
128 194, 197, 199, 201, 213
130 if (__diag288(
wdt_init, 15, ebc_begin,
sizeof(ebc_begin)) != 0)
132 return vmwdt_disable();
135 static int vmwdt_open(
struct inode *
i,
struct file *
f)
140 ret = vmwdt_keepalive();
146 static int vmwdt_close(
struct inode *i,
struct file *f)
148 if (vmwdt_expect_close == 42)
150 vmwdt_expect_close = 0;
157 .firmware_version = 0,
158 .identity =
"z/VM Watchdog Timer",
161 static int __vmwdt_ioctl(
unsigned int cmd,
unsigned long arg)
171 return put_user(0, (
int __user *)arg);
177 if (
get_user(options, (
int __user *)arg))
181 ret = vmwdt_disable();
186 ret = vmwdt_keepalive();
191 return put_user(vmwdt_interval, (
int __user *)arg);
195 if (
get_user(interval, (
int __user *)arg))
201 return vmwdt_keepalive();
203 return vmwdt_keepalive();
208 static long vmwdt_ioctl(
struct file *f,
unsigned int cmd,
unsigned long arg)
213 rc = __vmwdt_ioctl(cmd, arg);
218 static ssize_t vmwdt_write(
struct file *f,
const char __user *
buf,
219 size_t count, loff_t *ppos)
222 if (!vmwdt_nowayout) {
227 vmwdt_expect_close = 0;
229 for (i = 0; i !=
count; i++) {
234 vmwdt_expect_close = 42;
243 static int vmwdt_resume(
void)
256 static int vmwdt_suspend(
void)
259 pr_err(
"The system cannot be suspended while the watchdog"
261 return notifier_from_errno(-
EBUSY);
265 pr_err(
"The system cannot be suspended while the watchdog"
267 return notifier_from_errno(-
EBUSY);
281 return vmwdt_resume();
284 return vmwdt_suspend();
291 .notifier_call = vmwdt_power_event,
296 .release = &vmwdt_close,
297 .unlocked_ioctl = &vmwdt_ioctl,
298 .write = &vmwdt_write,
309 static int __init vmwdt_init(
void)
316 ret = register_pm_notifier(&vmwdt_power_notifier);
325 unregister_pm_notifier(&vmwdt_power_notifier);
332 static void __exit vmwdt_exit(
void)
334 unregister_pm_notifier(&vmwdt_power_notifier);