Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

watchdog: pretimeout: add noop pretimeout governor

The change adds noop watchdog pretimeout governor, only an
informational message is printed to the kernel log buffer when a
watchdog triggers a pretimeout event.

While introducing the first pretimeout governor the selected design
assumes that the default pretimeout governor is selected by its name
and it is always built-in, thus the default pretimeout governor can
not be unregistered and the correspondent check can be removed from
the watchdog_unregister_governor() function.

Signed-off-by: Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>

authored by

Vladimir Zapolskiy and committed by
Wim Van Sebroeck
f77710c4 ff84136c

+81
+28
drivers/watchdog/Kconfig
··· 1838 1838 help 1839 1839 The option allows to select watchdog pretimeout governors. 1840 1840 1841 + if WATCHDOG_PRETIMEOUT_GOV 1842 + 1843 + choice 1844 + prompt "Default Watchdog Pretimeout Governor" 1845 + default WATCHDOG_PRETIMEOUT_DEFAULT_GOV_PANIC 1846 + help 1847 + This option selects a default watchdog pretimeout governor. 1848 + The governor takes its action, if a watchdog is capable 1849 + to report a pretimeout event. 1850 + 1851 + config WATCHDOG_PRETIMEOUT_DEFAULT_GOV_NOOP 1852 + bool "noop" 1853 + select WATCHDOG_PRETIMEOUT_GOV_NOOP 1854 + help 1855 + Use noop watchdog pretimeout governor by default. If noop 1856 + governor is selected by a user, write a short message to 1857 + the kernel log buffer and don't do any system changes. 1858 + 1859 + endchoice 1860 + 1861 + config WATCHDOG_PRETIMEOUT_GOV_NOOP 1862 + tristate "Noop watchdog pretimeout governor" 1863 + help 1864 + Noop watchdog pretimeout governor, only an informational 1865 + message is added to kernel log buffer. 1866 + 1867 + endif # WATCHDOG_PRETIMEOUT_GOV 1868 + 1841 1869 endif # WATCHDOG
+2
drivers/watchdog/Makefile
··· 9 9 10 10 watchdog-$(CONFIG_WATCHDOG_PRETIMEOUT_GOV) += watchdog_pretimeout.o 11 11 12 + obj-$(CONFIG_WATCHDOG_PRETIMEOUT_GOV_NOOP) += pretimeout_noop.o 13 + 12 14 # Only one watchdog can succeed. We probe the ISA/PCI/USB based 13 15 # watchdog-cards first, then the architecture specific watchdog 14 16 # drivers and then the architecture independent "softdog" driver.
+47
drivers/watchdog/pretimeout_noop.c
··· 1 + /* 2 + * Copyright (C) 2015-2016 Mentor Graphics 3 + * 4 + * This program is free software; you can redistribute it and/or modify 5 + * it under the terms of the GNU General Public License as published by 6 + * the Free Software Foundation; either version 2 of the License, or 7 + * (at your option) any later version. 8 + * 9 + */ 10 + 11 + #include <linux/module.h> 12 + #include <linux/printk.h> 13 + #include <linux/watchdog.h> 14 + 15 + #include "watchdog_pretimeout.h" 16 + 17 + /** 18 + * pretimeout_noop - No operation on watchdog pretimeout event 19 + * @wdd - watchdog_device 20 + * 21 + * This function prints a message about pretimeout to kernel log. 22 + */ 23 + static void pretimeout_noop(struct watchdog_device *wdd) 24 + { 25 + pr_alert("watchdog%d: pretimeout event\n", wdd->id); 26 + } 27 + 28 + static struct watchdog_governor watchdog_gov_noop = { 29 + .name = "noop", 30 + .pretimeout = pretimeout_noop, 31 + }; 32 + 33 + static int __init watchdog_gov_noop_register(void) 34 + { 35 + return watchdog_register_governor(&watchdog_gov_noop); 36 + } 37 + 38 + static void __exit watchdog_gov_noop_unregister(void) 39 + { 40 + watchdog_unregister_governor(&watchdog_gov_noop); 41 + } 42 + module_init(watchdog_gov_noop_register); 43 + module_exit(watchdog_gov_noop_unregister); 44 + 45 + MODULE_AUTHOR("Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>"); 46 + MODULE_DESCRIPTION("Panic watchdog pretimeout governor"); 47 + MODULE_LICENSE("GPL");
+4
drivers/watchdog/watchdog_pretimeout.h
··· 20 20 void watchdog_unregister_pretimeout(struct watchdog_device *wdd); 21 21 int watchdog_pretimeout_governor_get(struct watchdog_device *wdd, char *buf); 22 22 23 + #if IS_ENABLED(CONFIG_WATCHDOG_PRETIMEOUT_DEFAULT_GOV_NOOP) 24 + #define WATCHDOG_PRETIMEOUT_DEFAULT_GOV "noop" 25 + #endif 26 + 23 27 #else 24 28 static inline int watchdog_register_pretimeout(struct watchdog_device *wdd) 25 29 {