watchdog: Add an IPMI watchdog driver in the watchdog framework
Subsystems (3)
PATCH 1/1 watchdog: Add an IPMI watchdog driver in the watchdog framework
From: Corey Minyard <[email protected]>
This basically strips out the things from the old watchdog driver that the standard watchdog doesn't support and ties into the watchdog framework. The old driver is left alone, but will be deprecated.
---
Something I should have done a long time ago (and was hoping someone else would do). Here's the first cut at this.
This creates a new watchdog driver for IPMI in addition to the old one. It is missing some of the features not supported by the watchdog framework, but few people if anybody probably use those features. However, it will integrate with other watchdog drivers cleanly.
Documentation/driver-api/ipmi.rst | 58 +- MAINTAINERS | 1 + drivers/char/ipmi/Kconfig | 5 +- drivers/watchdog/Kconfig | 11 + drivers/watchdog/Makefile | 1 + drivers/watchdog/ipmi_wdt.c | 908 ++++++++++++++++++++++++++++++ 6 files changed, 942 insertions(+), 42 deletions(-) create mode 100644 drivers/watchdog/ipmi_wdt.c
Documentation/driver-api/ipmi.rst +18 -40
@@ -114,9 +114,8 @@ over the SMBus. ipmi_powernv - A driver for access BMCs on POWERNV systems. -ipmi_watchdog - IPMI requires systems to have a very capable watchdog -timer. This driver implements the standard Linux watchdog timer -interface on top of the IPMI message handler. +ipmi_watchdog - This is the old IPMI watchdog driver, the new one is +in the watchdog directory and is in driver/watchdog/ipmi_wdt.c. ipmi_poweroff - Some systems support the ability to be turned off via IPMI commands.
@@ -664,12 +663,11 @@ Watchdog -------- A watchdog timer is provided that implements the Linux-standard -watchdog timer interface. It has three module parameters that can be +watchdog timer interface. It has module parameters that can be used to control it:: - modprobe ipmi_watchdog timeout=<t> pretimeout=<t> action=<action type> - preaction=<preaction type> preop=<preop type> start_now=x - nowayout=x ifnum_to_use=n panic_wdt_timeout=<t> + modprobe ipmi_wdt timeout=<t> pretimeout=<t> nowayout[=x] + ifnum_to_use=n panic_wdt_timeout=<t> test_pretimeout[=x] ifnum_to_use specifies which interface the watchdog timer should use. The default is -1, which means to pick the first one registered.
@@ -679,46 +677,26 @@ is the amount of seconds before the reset that the pre-timeout panic will occur (if pretimeout is zero, then pretimeout will not be enabled). Note that the pretimeout is the time before the final timeout. So if the timeout is 50 seconds and the pretimeout is 10 seconds, then the pretimeout -will occur in 40 second (10 seconds before the timeout). The panic_wdt_timeout -is the value of timeout which is set on kernel panic, in order to let actions -such as kdump to occur during panic. +will occur in 40 second (10 seconds before the timeout). -The action may be "reset", "power_cycle", or "power_off", and -specifies what to do when the timer times out, and defaults to -"reset". - -The preaction may be "pre_smi" for an indication through the SMI -interface, "pre_int" for an indication through the SMI with an -interrupts, and "pre_nmi" for a NMI on a preaction. This is how -the driver is informed of the pretimeout. - -The preop may be set to "preop_none" for no operation on a pretimeout, -"preop_panic" to set the preoperation to panic, or "preop_give_data" -to provide data to read from the watchdog device when the pretimeout -occurs. A "pre_nmi" setting CANNOT be used with "preop_give_data" -because you can't do data operations from an NMI. - -When preop is set to "preop_give_data", one byte comes ready to read -on the device when the pretimeout occurs. Select and fasync work on -the device, as well. - -If start_now is set to 1, the watchdog timer will start running as -soon as the driver is loaded. - -If nowayout is set to 1, the watchdog timer will not stop when the +If nowayout is enabled, the watchdog timer will not stop when the watchdog device is closed. The default value of nowayout is true if the CONFIG_WATCHDOG_NOWAYOUT option is enabled, or false if not. +panic_wdt_timeout is the value of timeout which is set on kernel +panic, in order to let actions such as kernel dump to occur during +panic. It defaults to 255 seconds. + +If test_pretimeout is enabled, then a test is done on the NMI timeout +to verify that it works. The results are printed to the system log. + When compiled into the kernel, the kernel command line is available for configuring the watchdog:: - ipmi_watchdog.timeout=<t> ipmi_watchdog.pretimeout=<t> - ipmi_watchdog.action=<action type> - ipmi_watchdog.preaction=<preaction type> - ipmi_watchdog.preop=<preop type> - ipmi_watchdog.start_now=x - ipmi_watchdog.nowayout=x - ipmi_watchdog.panic_wdt_timeout=<t> + ipmi_wdt.timeout=<t> ipmi_wdt.pretimeout=<t> + ipmi_wdt.nowayout=x + ipmi_wdt.panic_wdt_timeout=<t> + ipmi_wdt.test_pretimeout=<t> The options are the same as the module parameter options.
MAINTAINERS +1 -0
@@ -10796,6 +10796,7 @@ T: git https://github.com/cminyard/linux-ipmi.git for-next F: Documentation/driver-api/ipmi.rst F: Documentation/devicetree/bindings/ipmi/ F: drivers/char/ipmi/ +F: drivers/watchdog/ipmi_wdt.c F: include/linux/ipmi* F: include/uapi/linux/ipmi*
drivers/char/ipmi/Kconfig +3 -2
@@ -91,9 +91,10 @@ config IPMI_POWERNV Provides a driver for OPAL firmware-based IPMI interfaces. config IPMI_WATCHDOG - tristate 'IPMI Watchdog Timer' + tristate 'Old IPMI Watchdog Timer' help - This enables the IPMI watchdog timer. + This enables the IPMI watchdog timer. This is deprecated, use + IPMI_WDT in the watchdog area. config IPMI_POWEROFF tristate 'IPMI Poweroff'
drivers/watchdog/Kconfig +11 -0
@@ -350,6 +350,17 @@ config SL28CPLD_WATCHDOG To compile this driver as a module, choose M here: the module will be called sl28cpld_wdt. +config IPMI_WDT + tristate "IPMI Watchdog Timer" + depends on IPMI_HANDLER + select WATCHDOG_CORE + help + IPMI watchdog timer integrated into the watchdog framework. + Note that you cannot use this driver with the old IPMI watchdog + driver (IPMI_WATCHDOG). + + If unsure, say Y. + # ALPHA Architecture # ARM Architecture
drivers/watchdog/Makefile +1 -0
@@ -230,3 +230,4 @@ obj-$(CONFIG_MENZ069_WATCHDOG) += menz69_wdt.o obj-$(CONFIG_RAVE_SP_WATCHDOG) += rave-sp-wdt.o obj-$(CONFIG_STPMIC1_WATCHDOG) += stpmic1_wdt.o obj-$(CONFIG_SL28CPLD_WATCHDOG) += sl28cpld_wdt.o +obj-$(CONFIG_IPMI_WDT) += ipmi_wdt.o
drivers/watchdog/ipmi_wdt.c new file +908 -0
908 lines not on this page · raw message
Signature · 1 line
2.34.1
kernel test robot
build botkernel test robot noticed the following build warnings:
Hi,
kernel test robot noticed the following build warnings:
[auto build test WARNING on cminyard-ipmi/for-next]
[also build test WARNING on groeck-staging/hwmon-next linus/master v6.3 next-20230428] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/minyard-acm-org/watchdog-Add-an-IPMI-watchdog-driver-in-the-watchdog-framework/20230502-230545 base: https://github.com/cminyard/linux-ipmi for-next patch link: https://lore.kernel.org/r/20230502150215.1266526-1-minyard%40acm.org patch subject: [PATCH] watchdog: Add an IPMI watchdog driver in the watchdog framework config: sparc-allyesconfig (https://download.01.org/0day-ci/archive/20230503/[email protected]/config) compiler: sparc64-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/3138708f587acacac7e95f3098e7a9587866a66e
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review minyard-acm-org/watchdog-Add-an-IPMI-watchdog-driver-in-the-watchdog-framework/20230502-230545 git checkout 3138708f587acacac7e95f3098e7a9587866a66e
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=sparc olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=sparc SHELL=/bin/bash drivers/
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
>> drivers/watchdog/ipmi_wdt.c:515:5: warning: no previous prototype for 'ipmi_wdt_start' [-Wmissing-prototypes]
515 | int ipmi_wdt_start(struct watchdog_device *wd)
| ^~~~~~~~~~~~~~
>> drivers/watchdog/ipmi_wdt.c:529:5: warning: no previous prototype for 'ipmi_wdt_stop' [-Wmissing-prototypes]
529 | int ipmi_wdt_stop(struct watchdog_device *wd)
| ^~~~~~~~~~~~~
>> drivers/watchdog/ipmi_wdt.c:539:5: warning: no previous prototype for 'ipmi_wdt_ping' [-Wmissing-prototypes]
539 | int ipmi_wdt_ping(struct watchdog_device *wd)
| ^~~~~~~~~~~~~
>> drivers/watchdog/ipmi_wdt.c:550:5: warning: no previous prototype for 'ipmi_wdt_set_timeout' [-Wmissing-prototypes]
550 | int ipmi_wdt_set_timeout(struct watchdog_device *wd, unsigned int to)
| ^~~~~~~~~~~~~~~~~~~~
drivers/watchdog/ipmi_wdt.c:204:17: warning: 'preop_panic_excl' defined but not used [-Wunused-variable]
204 | static atomic_t preop_panic_excl = ATOMIC_INIT(-1);
| ^~~~~~~~~~~~~~~~vim +/ipmi_wdt_start +515 drivers/watchdog/ipmi_wdt.c
514
> 515 int ipmi_wdt_start(struct watchdog_device *wd)
516 {
517 int rv;
518
519 mutex_lock(&ipmi_watchdog_mutex);
520 ipmi_watchdog_state = action_val;
521 rv = _ipmi_set_timeout(IPMI_SET_TIMEOUT_FORCE_HB);
522 if (rv)
523 ipmi_watchdog_state = WDOG_TIMEOUT_NONE;
524 mutex_unlock(&ipmi_watchdog_mutex);
525
526 return rv;
527 }
528
> 529 int ipmi_wdt_stop(struct watchdog_device *wd)
530 {
531 mutex_lock(&ipmi_watchdog_mutex);
532 ipmi_watchdog_state = WDOG_TIMEOUT_NONE;
533 _ipmi_set_timeout(IPMI_SET_TIMEOUT_NO_HB);
534 mutex_unlock(&ipmi_watchdog_mutex);
535
536 return 0;
537 }
538
> 539 int ipmi_wdt_ping(struct watchdog_device *wd)
540 {
541 int rv;
542
543 mutex_lock(&ipmi_watchdog_mutex);
544 rv = _ipmi_heartbeat();
545 mutex_unlock(&ipmi_watchdog_mutex);
546
547 return rv;
548 }
549
> 550 int ipmi_wdt_set_timeout(struct watchdog_device *wd, unsigned int to) 551 {
552 int rv;
553
554 mutex_lock(&ipmi_watchdog_mutex);
555 timeout = to;
556 rv = _ipmi_set_timeout(IPMI_SET_TIMEOUT_HB_IF_NECESSARY);
557 mutex_unlock(&ipmi_watchdog_mutex);
558
559 return rv;
560 }
561
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests
kernel test robot
build botkernel test robot noticed the following build warnings:
Hi,
kernel test robot noticed the following build warnings:
[auto build test WARNING on cminyard-ipmi/for-next]
[also build test WARNING on groeck-staging/hwmon-next linus/master v6.3 next-20230428] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/minyard-acm-org/watchdog-Add-an-IPMI-watchdog-driver-in-the-watchdog-framework/20230502-230545 base: https://github.com/cminyard/linux-ipmi for-next patch link: https://lore.kernel.org/r/20230502150215.1266526-1-minyard%40acm.org patch subject: [PATCH] watchdog: Add an IPMI watchdog driver in the watchdog framework config: i386-allyesconfig (https://download.01.org/0day-ci/archive/20230503/[email protected]/config) compiler: gcc-11 (Debian 11.3.0-12) 11.3.0
reproduce (this is a W=1 build):
# https://github.com/intel-lab-lkp/linux/commit/3138708f587acacac7e95f3098e7a9587866a66e
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review minyard-acm-org/watchdog-Add-an-IPMI-watchdog-driver-in-the-watchdog-framework/20230502-230545 git checkout 3138708f587acacac7e95f3098e7a9587866a66e
# save the config file
mkdir build_dir && cp config build_dir/.config
make W=1 O=build_dir ARCH=i386 olddefconfig
make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash drivers/watchdog/
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
drivers/watchdog/ipmi_wdt.c:515:5: warning: no previous prototype for 'ipmi_wdt_start' [-Wmissing-prototypes]
515 | int ipmi_wdt_start(struct watchdog_device *wd)
| ^~~~~~~~~~~~~~
drivers/watchdog/ipmi_wdt.c:529:5: warning: no previous prototype for 'ipmi_wdt_stop' [-Wmissing-prototypes]
529 | int ipmi_wdt_stop(struct watchdog_device *wd)
| ^~~~~~~~~~~~~
drivers/watchdog/ipmi_wdt.c:539:5: warning: no previous prototype for 'ipmi_wdt_ping' [-Wmissing-prototypes]
539 | int ipmi_wdt_ping(struct watchdog_device *wd)
| ^~~~~~~~~~~~~
drivers/watchdog/ipmi_wdt.c:550:5: warning: no previous prototype for 'ipmi_wdt_set_timeout' [-Wmissing-prototypes]
550 | int ipmi_wdt_set_timeout(struct watchdog_device *wd, unsigned int to)
| ^~~~~~~~~~~~~~~~~~~~
>> drivers/watchdog/ipmi_wdt.c:563:5: warning: no previous prototype for 'ipmi_wdt_set_pretimeout' [-Wmissing-prototypes]
563 | int ipmi_wdt_set_pretimeout(struct watchdog_device *wd, unsigned int pto)
| ^~~~~~~~~~~~~~~~~~~~~~~
vim +/ipmi_wdt_set_pretimeout +563 drivers/watchdog/ipmi_wdt.c
561
562 #ifdef HAVE_DIE_NMI
> 563 int ipmi_wdt_set_pretimeout(struct watchdog_device *wd, unsigned int pto)
564 {
565 int rv;
566
567 mutex_lock(&ipmi_watchdog_mutex);
568 pretimeout = pto;
569 if (pto)
570 pretimeout_state = WDOG_PRETIMEOUT_NMI;
571 else
572 pretimeout_state = WDOG_PRETIMEOUT_NONE;
573
574 rv = _ipmi_set_timeout(IPMI_SET_TIMEOUT_HB_IF_NECESSARY);
575 mutex_unlock(&ipmi_watchdog_mutex);
576
577 return rv;
578 }
579 #endif
580
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests