[OpenWrt-Devel] [PATCH procd] watchdog: shutdown the kernel watchdog when stopping

Helmut Schaa helmut.schaa at googlemail.com
Mon Sep 28 08:14:51 EDT 2015


On Mon, Sep 28, 2015 at 12:58 AM, Alexander Couzens <lynxis at fe80.eu> wrote:
> The kernel wdt counting down even when not pinged.
> Shutdown the filehandler to /dev/watchdog with magic cookie
> to prevent this.
>
> Signed-off-by: Alexander Couzens <lynxis at fe80.eu>
> ---
>  watchdog.c | 17 ++++++++++++++---
>  1 file changed, 14 insertions(+), 3 deletions(-)
>
>
> I'm not certainly clear, the previous behaviour was a bug or feature.
> If stop=True should really only stop the pinging thread, I really would like
> to shutdown the watchdog gracefully on another way. E.g. with another argument
> shutdown.
>

I've always interpreted the call that it just stops triggering the
watchdog and might
force a hw reset. So IMO it would make sense to add a parameter to specify the
exact action that should be taken.

Helmut

> Best lynxis
>
> diff --git a/watchdog.c b/watchdog.c
> index 592ae7e..025942b 100644
> --- a/watchdog.c
> +++ b/watchdog.c
> @@ -45,11 +45,23 @@ static void watchdog_timeout_cb(struct uloop_timeout *t)
>         uloop_timeout_set(t, wdt_frequency * 1000);
>  }
>
> +static void watchdog_stop()
> +{
> +       if (wdt_fd >= 0 && write(wdt_fd, "V", 1) < 0)
> +               ERROR("WDT failed to write magic close sequence: %s\n"
> +                     "WDT may not stopped properly.\n", strerror(errno));
> +       if (close(wdt_fd) < 0)
> +               ERROR("WDT failed to close watchdog fd: %s\n"
> +                     "WDT may not stopped properly.\n", strerror(errno));
> +       wdt_fd = -1;
> +}
> +
>  void watchdog_set_stopped(bool val)
>  {
> -       if (val)
> +       if (val) {
>                 uloop_timeout_cancel(&wdt_timeout);
> -       else
> +               watchdog_stop();
> +       } else
>                 watchdog_timeout_cb(&wdt_timeout);
>  }
>
> @@ -125,7 +137,6 @@ void watchdog_init(int preinit)
>         DEBUG(4, "Opened watchdog with timeout %ds\n", watchdog_timeout(0));
>  }
>
> -
>  void watchdog_no_cloexec(void)
>  {
>         if (wdt_fd < 0)
> --
> 2.5.3
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel at lists.openwrt.org
> https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list