Who is refreshing hardware watchdog in Linux?

前端 未结 5 2194
攒了一身酷
攒了一身酷 2020-12-15 06:54

I have a processor AT91SAM9G20 running a 2.6 kernel. Watchdog is enabled at bootstrap level and configured for 16 seconds. Watchdog mode register can be configured only once

相关标签:
5条回答
  • 2020-12-15 07:01

    This may give you a hint: http://www.mjmwired.net/kernel/Documentation/watchdog/watchdog-api.txt

    It makes perfect sense to have a user space daemon handling the watchdog. It probably defaults to a 15 minute timeout.

    0 讨论(0)
  • 2020-12-15 07:01

    Wouldn't the kernel be refreshing the watchdog timer? The watchdog is designed to reset the board if the whole system hangs, not just a single application.

    0 讨论(0)
  • 2020-12-15 07:02

    we had a similar problem regarding WDT on AT91SAM9263. Problem was with bit 29 WDIDLEHLT of WDT_MR (Address: 0xFFFFFD44) register. This bit was set to 1 but it should be 0 for our application needs.

    Bit explanation from datasheet documentation:

    • WDIDLEHLT: Watchdog Idle Halt

    1. 0: The Watchdog runs when the system is in idle mode.
    2. 1: The Watchdog stops when the system is in idle state.

    This means that WDT counter does not increment when kernel is in idle state, hence the 15 or more delay until reset happens.

    You can try "dd if=/dev/zero of=/dev/null" which will prevent kernel from entering idle state and you should get a reset in 16 seconds (or whatever period you have set in WDT_MR register).

    So, the solution is to update u-boot code or other piece of code that sets WDT_MR register. Remember this register is write once...

    0 讨论(0)
  • 2020-12-15 07:03

    If you enabled the watchdog driver in your kernel, the watchdog driver sets up a kernel timer, in charge of resetting the watchdog. The corresponding code is here. So it works like this:

    If no application opens the /dev/watchdog file, then the kernel takes care of resetting the watchdog. Since it is a timer, it won't appear as a dedicated kernel thread, but handled by the soft IRQ thread. Now, if an application opens this file, it becomes responsible of the watchdog, and can reset it by writing to the file, as documented by the documentation linked in Richard's post.

    Is the watchdog driver configured in your kernel? If not, you should configure it, and see if the reset still happens. If it still happens, it is likely that your reset comes from somewhere else.

    If your kernel is too old to have a proper watchdog driver (not present in 2.6.25) you should backport it from 2.6.28. Or you can try to disable the watchdog in your bootloader and see if the reset still occurs.

    0 讨论(0)
  • 2020-12-15 07:07

    In July 2016 a commit in the 4.7 kernel to watchdog_dev.c enabled the same behavior as shodanex's answer for all watchdog timer drivers. This doesn't seem to be documented anywhere other than this thread and the source code.

    /*
    * A worker to generate heartbeat requests is needed if all of the
    * following conditions are true.
    * - Userspace activated the watchdog.
    * - The driver provided a value for the maximum hardware timeout, and
    *   thus is aware that the framework supports generating heartbeat
    *   requests.
    * - Userspace requests a longer timeout than the hardware can handle.
    *
    * Alternatively, if userspace has not opened the watchdog
    * device, we take care of feeding the watchdog if it is
    * running.
    */
    
    return (hm && watchdog_active(wdd) && t > hm) ||
           (t && !watchdog_active(wdd) && watchdog_hw_running(wdd));
    
    0 讨论(0)
提交回复
热议问题