]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
watchdog: softdog: make pretimeout support a compile option
authorWolfram Sang <wsa+renesas@sang-engineering.com>
Tue, 7 Feb 2017 14:03:29 +0000 (15:03 +0100)
committerGuenter Roeck <linux@roeck-us.net>
Fri, 24 Feb 2017 22:00:23 +0000 (14:00 -0800)
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>
drivers/watchdog/Kconfig
drivers/watchdog/softdog.c

index 2d006d8cfb158dce45d217e2fc7f90dc15a73176..1a4d6ca8028d39a8c5578ccd530a73fea142e017 100644 (file)
@@ -71,6 +71,14 @@ config SOFT_WATCHDOG
          To compile this driver as a module, choose M here: the
          module will be called softdog.
 
+config SOFT_WATCHDOG_PRETIMEOUT
+       bool "Software watchdog pretimeout governor support"
+       depends on SOFT_WATCHDOG && WATCHDOG_PRETIMEOUT_GOV
+       help
+         Enable this if you want to use pretimeout governors with the software
+         watchdog. Be aware that governors might affect the watchdog because it
+         is purely software, e.g. the panic governor will stall it!
+
 config DA9052_WATCHDOG
        tristate "Dialog DA9052 Watchdog"
        depends on PMIC_DA9052 || COMPILE_TEST
index c7bdc986dca1c249c2b61ad902504cdd1df4fb2d..7983029852ab0dc7e688b0766337fd0bb9da8c54 100644 (file)
@@ -87,11 +87,13 @@ static int softdog_ping(struct watchdog_device *w)
        if (!mod_timer(&softdog_ticktock, jiffies + (w->timeout * HZ)))
                __module_get(THIS_MODULE);
 
-       if (w->pretimeout)
-               mod_timer(&softdog_preticktock, jiffies +
-                         (w->timeout - w->pretimeout) * HZ);
-       else
-               del_timer(&softdog_preticktock);
+       if (IS_ENABLED(CONFIG_SOFT_WATCHDOG_PRETIMEOUT)) {
+               if (w->pretimeout)
+                       mod_timer(&softdog_preticktock, jiffies +
+                                 (w->timeout - w->pretimeout) * HZ);
+               else
+                       del_timer(&softdog_preticktock);
+       }
 
        return 0;
 }
@@ -101,15 +103,15 @@ static int softdog_stop(struct watchdog_device *w)
        if (del_timer(&softdog_ticktock))
                module_put(THIS_MODULE);
 
-       del_timer(&softdog_preticktock);
+       if (IS_ENABLED(CONFIG_SOFT_WATCHDOG_PRETIMEOUT))
+               del_timer(&softdog_preticktock);
 
        return 0;
 }
 
 static struct watchdog_info softdog_info = {
        .identity = "Software Watchdog",
-       .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE |
-                  WDIOF_PRETIMEOUT,
+       .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE,
 };
 
 static const struct watchdog_ops softdog_ops = {
@@ -134,6 +136,9 @@ static int __init softdog_init(void)
        watchdog_set_nowayout(&softdog_dev, nowayout);
        watchdog_stop_on_reboot(&softdog_dev);
 
+       if (IS_ENABLED(CONFIG_SOFT_WATCHDOG_PRETIMEOUT))
+               softdog_info.options |= WDIOF_PRETIMEOUT;
+
        ret = watchdog_register_device(&softdog_dev);
        if (ret)
                return ret;