summaryrefslogtreecommitdiffstats
path: root/drivers/watchdog
diff options
context:
space:
mode:
authorWolfram Sang <wsa+renesas@sang-engineering.com>2017-02-07 09:03:29 -0500
committerGuenter Roeck <linux@roeck-us.net>2017-02-24 17:00:23 -0500
commit4cbc69023a2129c271ed67da555d62eca42469d2 (patch)
treedfeff856480f7d1cd018f3e6b8c90b470fa53967 /drivers/watchdog
parent8ce6796dabb9f1f55b07cd032449a24b625f761e (diff)
watchdog: softdog: make pretimeout support a compile option
It occurred to me that the panic pretimeout governor will stall the softdog, because it is purely software which simply breaks when the kernel panics. Testing governors with the softdog on the other hand is really useful, so make this feature a compile time option which nees to be enabled explicitly. This also removes the overhead if pretimeout support is not used because it will now be compiled away (saving ~10% on ARM32). Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Reviewed-by: Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/watchdog')
-rw-r--r--drivers/watchdog/Kconfig8
-rw-r--r--drivers/watchdog/softdog.c21
2 files changed, 21 insertions, 8 deletions
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index 2d006d8cfb15..1a4d6ca8028d 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -71,6 +71,14 @@ config SOFT_WATCHDOG
71 To compile this driver as a module, choose M here: the 71 To compile this driver as a module, choose M here: the
72 module will be called softdog. 72 module will be called softdog.
73 73
74config SOFT_WATCHDOG_PRETIMEOUT
75 bool "Software watchdog pretimeout governor support"
76 depends on SOFT_WATCHDOG && WATCHDOG_PRETIMEOUT_GOV
77 help
78 Enable this if you want to use pretimeout governors with the software
79 watchdog. Be aware that governors might affect the watchdog because it
80 is purely software, e.g. the panic governor will stall it!
81
74config DA9052_WATCHDOG 82config DA9052_WATCHDOG
75 tristate "Dialog DA9052 Watchdog" 83 tristate "Dialog DA9052 Watchdog"
76 depends on PMIC_DA9052 || COMPILE_TEST 84 depends on PMIC_DA9052 || COMPILE_TEST
diff --git a/drivers/watchdog/softdog.c b/drivers/watchdog/softdog.c
index c7bdc986dca1..7983029852ab 100644
--- a/drivers/watchdog/softdog.c
+++ b/drivers/watchdog/softdog.c
@@ -87,11 +87,13 @@ static int softdog_ping(struct watchdog_device *w)
87 if (!mod_timer(&softdog_ticktock, jiffies + (w->timeout * HZ))) 87 if (!mod_timer(&softdog_ticktock, jiffies + (w->timeout * HZ)))
88 __module_get(THIS_MODULE); 88 __module_get(THIS_MODULE);
89 89
90 if (w->pretimeout) 90 if (IS_ENABLED(CONFIG_SOFT_WATCHDOG_PRETIMEOUT)) {
91 mod_timer(&softdog_preticktock, jiffies + 91 if (w->pretimeout)
92 (w->timeout - w->pretimeout) * HZ); 92 mod_timer(&softdog_preticktock, jiffies +
93 else 93 (w->timeout - w->pretimeout) * HZ);
94 del_timer(&softdog_preticktock); 94 else
95 del_timer(&softdog_preticktock);
96 }
95 97
96 return 0; 98 return 0;
97} 99}
@@ -101,15 +103,15 @@ static int softdog_stop(struct watchdog_device *w)
101 if (del_timer(&softdog_ticktock)) 103 if (del_timer(&softdog_ticktock))
102 module_put(THIS_MODULE); 104 module_put(THIS_MODULE);
103 105
104 del_timer(&softdog_preticktock); 106 if (IS_ENABLED(CONFIG_SOFT_WATCHDOG_PRETIMEOUT))
107 del_timer(&softdog_preticktock);
105 108
106 return 0; 109 return 0;
107} 110}
108 111
109static struct watchdog_info softdog_info = { 112static struct watchdog_info softdog_info = {
110 .identity = "Software Watchdog", 113 .identity = "Software Watchdog",
111 .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE | 114 .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE,
112 WDIOF_PRETIMEOUT,
113}; 115};
114 116
115static const struct watchdog_ops softdog_ops = { 117static const struct watchdog_ops softdog_ops = {
@@ -134,6 +136,9 @@ static int __init softdog_init(void)
134 watchdog_set_nowayout(&softdog_dev, nowayout); 136 watchdog_set_nowayout(&softdog_dev, nowayout);
135 watchdog_stop_on_reboot(&softdog_dev); 137 watchdog_stop_on_reboot(&softdog_dev);
136 138
139 if (IS_ENABLED(CONFIG_SOFT_WATCHDOG_PRETIMEOUT))
140 softdog_info.options |= WDIOF_PRETIMEOUT;
141
137 ret = watchdog_register_device(&softdog_dev); 142 ret = watchdog_register_device(&softdog_dev);
138 if (ret) 143 if (ret)
139 return ret; 144 return ret;