From: minyard@acm.org
To: Guenter Roeck <linux@roeck-us.net>,
Wim Van Sebroeck <wim@linux-watchdog.org>
Cc: linux-watchdog@vger.kernel.org, Corey Minyard <cminyard@mvista.com>
Subject: [PATCH 09/10] ipmi:watchdog: Convert over to watchdog framework reboot handling
Date: Sat, 20 Jun 2020 12:49:06 -0500 [thread overview]
Message-ID: <20200620174907.20229-10-minyard@acm.org> (raw)
In-Reply-To: <20200620174907.20229-1-minyard@acm.org>
From: Corey Minyard <cminyard@mvista.com>
With the watchdog framework supporting a reboot timeout, we can switch
the IPMI driver over to use that and get rid of some redundance code.
Signed-off-by: Corey Minyard <cminyard@mvista.com>
---
drivers/char/ipmi/ipmi_watchdog.c | 47 ++-----------------------------
1 file changed, 3 insertions(+), 44 deletions(-)
diff --git a/drivers/char/ipmi/ipmi_watchdog.c b/drivers/char/ipmi/ipmi_watchdog.c
index 6e0c9faa6e6a..1ee884e6dcac 100644
--- a/drivers/char/ipmi/ipmi_watchdog.c
+++ b/drivers/char/ipmi/ipmi_watchdog.c
@@ -27,7 +27,6 @@
#include <linux/uaccess.h>
#include <linux/notifier.h>
#include <linux/nmi.h>
-#include <linux/reboot.h>
#include <linux/wait.h>
#include <linux/poll.h>
#include <linux/string.h>
@@ -140,9 +139,6 @@ static int pretimeout;
/* Default timeout to set on panic */
static int panic_wdt_timeout = 255;
-/* Default timeout to set on reboot */
-static int reboot_wdt_timeout = 120;
-
/* Default action is to reset the board on a timeout. */
static unsigned char action_val = WDOG_TIMEOUT_RESET;
@@ -321,7 +317,7 @@ MODULE_PARM_DESC(pretimeout, "Pretimeout value in seconds.");
module_param(panic_wdt_timeout, timeout, 0644);
MODULE_PARM_DESC(panic_wdt_timeout, "Timeout value on kernel panic in seconds.");
-module_param(reboot_wdt_timeout, timeout, 0644);
+module_param_named(reboot_wdt_timeout, ipmi_wdd.reboot_timeout, timeout, 0644);
MODULE_PARM_DESC(reboot_wdt_timeout, "Timeout value on a reboot in seconds.");
module_param_cb(action, ¶m_ops_str, action_op, 0644);
@@ -825,10 +821,12 @@ static struct watchdog_info ipmi_wdog_info = {
static struct watchdog_device ipmi_wdd = {
.ops = &ipmi_wdog_ops,
.info = &ipmi_wdog_info,
+ .status = 1 << WDOG_STOP_ON_REBOOT,
.min_timeout = 1,
.max_timeout = 6553,
.min_hw_heartbeat_ms = 1,
.max_hw_heartbeat_ms = 65535,
+ .reboot_timeout = 120,
};
static void ipmi_wdog_msg_handler(struct ipmi_recv_msg *msg,
@@ -1065,40 +1063,6 @@ ipmi_nmi(unsigned int val, struct pt_regs *regs)
}
#endif
-static int wdog_reboot_handler(struct notifier_block *this,
- unsigned long code,
- void *unused)
-{
- static int reboot_event_handled;
-
- if ((watchdog_user) && (!reboot_event_handled)) {
- /* Make sure we only do this once. */
- reboot_event_handled = 1;
-
- if (code == SYS_POWER_OFF || code == SYS_HALT) {
- /* Disable the WDT if we are shutting down. */
- ipmi_watchdog_state = WDOG_TIMEOUT_NONE;
- ipmi_set_timeout(&ipmi_wdd, IPMI_SET_TIMEOUT_NO_HB);
- } else if (ipmi_watchdog_state != WDOG_TIMEOUT_NONE) {
- /* Set a long timer to let the reboot happen or
- reset if it hangs, but only if the watchdog
- timer was already running. */
- if (timeout < reboot_wdt_timeout)
- timeout = reboot_wdt_timeout;
- pretimeout = 0;
- ipmi_watchdog_state = WDOG_TIMEOUT_RESET;
- ipmi_set_timeout(&ipmi_wdd, IPMI_SET_TIMEOUT_NO_HB);
- }
- }
- return NOTIFY_OK;
-}
-
-static struct notifier_block wdog_reboot_notifier = {
- .notifier_call = wdog_reboot_handler,
- .next = NULL,
- .priority = 0
-};
-
static void ipmi_new_smi(int if_num, struct device *device)
{
ipmi_register_watchdog(if_num);
@@ -1232,15 +1196,12 @@ static int __init ipmi_wdog_init(void)
check_parms();
- register_reboot_notifier(&wdog_reboot_notifier);
-
rv = ipmi_smi_watcher_register(&smi_watcher);
if (rv) {
#ifdef HAVE_DIE_NMI
if (nmi_handler_registered)
unregister_nmi_handler(NMI_UNKNOWN, "ipmi");
#endif
- unregister_reboot_notifier(&wdog_reboot_notifier);
pr_warn("can't register smi watcher\n");
return rv;
}
@@ -1259,8 +1220,6 @@ static void __exit ipmi_wdog_exit(void)
if (nmi_handler_registered)
unregister_nmi_handler(NMI_UNKNOWN, "ipmi");
#endif
-
- unregister_reboot_notifier(&wdog_reboot_notifier);
}
module_exit(ipmi_wdog_exit);
module_init(ipmi_wdog_init);
--
2.17.1
next prev parent reply other threads:[~2020-06-20 17:50 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-20 17:48 [PATCH 00/10] Convert the IPMI watchdog to use the watchdog minyard
2020-06-20 17:48 ` [PATCH 01/10] watchdog: Ignore stop_on_reboot if no stop function minyard
2020-07-19 14:11 ` Guenter Roeck
2020-06-20 17:48 ` [PATCH 02/10] watchdog: Add read capability minyard
2020-06-20 17:49 ` [PATCH 03/10] watchdog: Add documentation for " minyard
2020-07-01 2:49 ` Guenter Roeck
2020-06-20 17:49 ` [PATCH 04/10] watchdog: Add functions to set the timeout and pretimeout minyard
2020-07-01 2:45 ` Guenter Roeck
2020-06-20 17:49 ` [PATCH 05/10] watchdog: Export an interface to start the watchdog minyard
2020-07-01 2:46 ` Guenter Roeck
2020-06-20 17:49 ` [PATCH 06/10] ipmi:watchdog: Convert over to the watchdog framework minyard
2020-06-20 17:49 ` [PATCH 07/10] ipmi:watchdog: Allow the reboot timeout to be specified minyard
2020-06-20 17:49 ` [PATCH 08/10] watchdog: Add a way to extend the timeout on a reboot minyard
2020-07-19 14:25 ` Guenter Roeck
2020-06-20 17:49 ` minyard [this message]
2020-06-20 17:49 ` [PATCH 10/10] ipmi:watchdog: Add the op to get the current timeout minyard
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=20200620174907.20229-10-minyard@acm.org \
--to=minyard@acm.org \
--cc=cminyard@mvista.com \
--cc=linux-watchdog@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=wim@linux-watchdog.org \
/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).