From: Wolfram Sang <wsa@the-dreams.de>
To: linux-watchdog@vger.kernel.org
Cc: Wolfram Sang <wsa@the-dreams.de>,
linux-renesas-soc@vger.kernel.org,
Guenter Roeck <linux@roeck-us.net>,
Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>,
Robin Gong <b38343@freescale.com>
Subject: [PATCH 2/7] watchdog: pretimeout: add panic pretimeout governor
Date: Wed, 25 May 2016 15:32:26 +0200 [thread overview]
Message-ID: <1464183151-4912-3-git-send-email-wsa@the-dreams.de> (raw)
In-Reply-To: <1464183151-4912-1-git-send-email-wsa@the-dreams.de>
From: Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
Panic watchdog pretimeout governor, on watchdog pretimeout event the
kernel shall panic.
Signed-off-by: Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
Changes since Vladimir's last version:
* rebased
* shortened the panic message a little (removed redundancy)
drivers/watchdog/Kconfig | 29 +++++++++++++++++++++
drivers/watchdog/Makefile | 2 ++
drivers/watchdog/pretimeout_panic.c | 47 ++++++++++++++++++++++++++++++++++
drivers/watchdog/watchdog_pretimeout.h | 6 ++++-
4 files changed, 83 insertions(+), 1 deletion(-)
create mode 100644 drivers/watchdog/pretimeout_panic.c
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index 909d1021de5cbc..36b7d1f83b3c51 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -1782,4 +1782,33 @@ config WATCHDOG_PRETIMEOUT_GOV
help
The option allows to select watchdog pretimeout governors.
+if WATCHDOG_PRETIMEOUT_GOV
+
+choice
+ prompt "Default Watchdog Pretimeout Governor"
+ default WATCHDOG_PRETIMEOUT_DEFAULT_GOV_PANIC
+ help
+ This option selects a default watchdog pretimeout governor.
+ The governor takes its action, if a watchdog is capable
+ to report a pretimeout event.
+
+config WATCHDOG_PRETIMEOUT_DEFAULT_GOV_PANIC
+ bool "panic"
+ select WATCHDOG_PRETIMEOUT_GOV_PANIC
+ help
+ Use panic watchdog pretimeout governor by default, if
+ a watchdog pretimeout event happens, consider that
+ a watchdog feeder is dead and reboot is unavoidable.
+
+endchoice
+
+config WATCHDOG_PRETIMEOUT_GOV_PANIC
+ tristate "Panic watchdog pretimeout governor"
+ help
+ Select this option to enable panic watchdog pretimeout
+ governor, on a watchdog pretimeout event the kernel shall
+ panic before an expected system reboot.
+
+endif # WATCHDOG_PRETIMEOUT_GOV
+
endif # WATCHDOG
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
index 820860cf3e8d62..56dfadc0cee2a9 100644
--- a/drivers/watchdog/Makefile
+++ b/drivers/watchdog/Makefile
@@ -8,6 +8,8 @@ obj-$(CONFIG_WATCHDOG_CORE) += watchdog.o
watchdog-y += watchdog_core.o watchdog_dev.o
watchdog-$(CONFIG_WATCHDOG_PRETIMEOUT_GOV) += watchdog_pretimeout.o
+obj-$(CONFIG_WATCHDOG_PRETIMEOUT_GOV_PANIC) += pretimeout_panic.o
+
# Only one watchdog can succeed. We probe the ISA/PCI/USB based
# watchdog-cards first, then the architecture specific watchdog
# drivers and then the architecture independent "softdog" driver.
diff --git a/drivers/watchdog/pretimeout_panic.c b/drivers/watchdog/pretimeout_panic.c
new file mode 100644
index 00000000000000..f8c2410d993f02
--- /dev/null
+++ b/drivers/watchdog/pretimeout_panic.c
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2015 Mentor Graphics
+ *
+ * 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/watchdog.h>
+
+#include "watchdog_pretimeout.h"
+
+/**
+ * pretimeout_panic - Panic on watchdog pretimeout event
+ * @wdd - watchdog_device
+ *
+ * Panic, watchdog has not been fed till pretimeout event.
+ */
+static void pretimeout_panic(struct watchdog_device *wdd)
+{
+ panic("watchdog pretimeout event");
+}
+
+static struct watchdog_governor watchdog_gov_panic = {
+ .name = "panic",
+ .pretimeout = pretimeout_panic,
+ .owner = THIS_MODULE,
+};
+
+static int __init watchdog_gov_panic_register(void)
+{
+ return watchdog_register_governor(&watchdog_gov_panic);
+}
+module_init(watchdog_gov_panic_register);
+
+static void __exit watchdog_gov_panic_unregister(void)
+{
+ watchdog_unregister_governor(&watchdog_gov_panic);
+}
+module_exit(watchdog_gov_panic_unregister);
+
+MODULE_AUTHOR("Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>");
+MODULE_DESCRIPTION("Panic watchdog pretimeout governor");
+MODULE_LICENSE("GPL");
diff --git a/drivers/watchdog/watchdog_pretimeout.h b/drivers/watchdog/watchdog_pretimeout.h
index 38965cdd23bebe..8b03fd480cb533 100644
--- a/drivers/watchdog/watchdog_pretimeout.h
+++ b/drivers/watchdog/watchdog_pretimeout.h
@@ -19,7 +19,11 @@ void watchdog_unregister_governor(struct watchdog_governor *gov);
/* Interfaces to watchdog_core.c */
#ifdef CONFIG_WATCHDOG_PRETIMEOUT_GOV
-#define WATCHDOG_PRETIMEOUT_DEFAULT_GOV "none"
+#if IS_ENABLED(CONFIG_WATCHDOG_PRETIMEOUT_DEFAULT_GOV_PANIC)
+#define WATCHDOG_PRETIMEOUT_DEFAULT_GOV "panic"
+#else
+#error "Default watchdog pretimeout governor is not set."
+#endif
int watchdog_register_pretimeout(struct watchdog_device *wdd, struct device *dev);
void watchdog_unregister_pretimeout(struct watchdog_device *wdd);
--
2.8.1
next prev parent reply other threads:[~2016-05-25 13:32 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-25 13:32 [PATCH 0/7] watchdog: add pretimeout support Wolfram Sang
2016-05-25 13:32 ` [PATCH 1/7] watchdog: add watchdog pretimeout framework Wolfram Sang
2016-05-26 14:11 ` Vladimir Zapolskiy
2016-05-26 16:41 ` Wolfram Sang
2016-05-26 22:37 ` Guenter Roeck
2016-06-05 9:48 ` Wolfram Sang
2016-06-05 20:25 ` Vladimir Zapolskiy
2016-05-25 13:32 ` Wolfram Sang [this message]
2016-05-25 13:32 ` [PATCH 3/7] watchdog: pretimeout: add noop pretimeout governor Wolfram Sang
2016-05-25 13:32 ` [PATCH 4/7] watchdog: documentation: squash paragraphs about 'no set_timeout' Wolfram Sang
2016-05-25 13:32 ` [PATCH 5/7] watchdog: add pretimeout support to the core Wolfram Sang
2016-05-25 13:32 ` [PATCH 6/7] fs: compat_ioctl: add pretimeout functions for watchdogs Wolfram Sang
2016-05-25 13:32 ` [PATCH 7/7] watchdog: softdog: implement pretimeout support Wolfram Sang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1464183151-4912-3-git-send-email-wsa@the-dreams.de \
--to=wsa@the-dreams.de \
--cc=b38343@freescale.com \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=linux-watchdog@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=vladimir_zapolskiy@mentor.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).