19 Jul, 2016

1 commit

  • Up to now, the watchdog status function called a driver function,
    which was supposed to return the watchdog status. All but one
    driver using the watchdog core did not implement this function,
    and the driver implementing it did not implement it correctly
    (the function is supposed to return WDIOF_ flags). At the same time,
    at least some of the status information can be provided by the watchdog
    core.

    Provide the available status bits directly from the watchdog driver core.
    Call the driver status function if it exists to get the boot status, but
    always provide WDIOF_MAGICCLOSE and WDIOF_KEEPALIVEPING internally.
    This patch makes the 'status' sysfs attribute always available.
    This attribute is now displayed as hex number with 0x prepended to be
    easier to decode.

    Signed-off-by: Guenter Roeck
    Signed-off-by: Wim Van Sebroeck

    Guenter Roeck
     

18 Jul, 2016

1 commit


17 Mar, 2016

5 commits

  • Some watchdogs require a minimum time between heartbeats.
    Examples are the watchdogs in DA9062 and AT91SAM9x.

    Signed-off-by: Guenter Roeck
    Signed-off-by: Wim Van Sebroeck

    Guenter Roeck
     
  • Not all hardware watchdogs can be stopped. The driver for
    such watchdogs would typically only set the WATCHDOG_HW_RUNNING
    flag in its stop function. Make the stop function optional and set
    WATCHDOG_HW_RUNNING in the watchdog core if it is not provided.

    Signed-off-by: Guenter Roeck
    Signed-off-by: Wim Van Sebroeck

    Guenter Roeck
     
  • The WDOG_HW_RUNNING flag is expected to be set by watchdog drivers if
    the hardware watchdog is running. If the flag is set, the watchdog
    subsystem will ping the watchdog even if the watchdog device is closed.

    The watchdog driver stop function is now optional and may be omitted
    if the watchdog can not be stopped. If stopping the watchdog is not
    possible but the driver implements a stop function, it is responsible
    to set the WDOG_HW_RUNNING flag in its stop function.

    Signed-off-by: Guenter Roeck
    Signed-off-by: Wim Van Sebroeck

    Guenter Roeck
     
  • Introduce an optional hardware maximum heartbeat in the watchdog core.
    The hardware maximum heartbeat can be lower than the maximum timeout.

    Drivers can set the maximum hardware heartbeat value in the watchdog data
    structure. If the configured timeout exceeds the maximum hardware heartbeat,
    the watchdog core enables a timer function to assist sending keepalive
    requests to the watchdog driver.

    Signed-off-by: Guenter Roeck
    Signed-off-by: Wim Van Sebroeck

    Guenter Roeck
     
  • For some watchdogs, the watchdog driver handles timeout changes without
    explicitly setting any registers. In this situation, the watchdog driver
    might only set the 'timeout' variable but do nothing else.
    This can as well be handled by the infrastructure, so make the set_timeout
    callback optional. If WDIOF_SETTIMEOUT is configured but the .set_timeout
    callback is not available, update the timeout variable in the
    infrastructure code.

    Signed-off-by: Guenter Roeck
    Signed-off-by: Wim Van Sebroeck

    Guenter Roeck
     

12 Jan, 2016

2 commits

  • The lifetime of the watchdog device pointer is different from the lifetime
    of its character device. Remove it entirely to avoid race conditions.

    Signed-off-by: Guenter Roeck
    Signed-off-by: Guenter Roeck
    Signed-off-by: Wim Van Sebroeck

    Guenter Roeck
     
  • The Zodiac watchdog driver attaches additional sysfs attributes to the
    watchdog device. This has a number of problems: The watchdog device
    lifetime differs from the driver lifetime, and the device structure
    should therefore not be accessed from drivers. Also, creating sysfs
    attributes after driver registration results in a potential race condition
    if user space expects the attributes to exist but they don't exist yet.

    Add support for creating driver specific sysfs attributes to the watchdog
    core to solve the problems.

    Signed-off-by: Guenter Roeck
    Signed-off-by: Guenter Roeck
    Signed-off-by: Wim Van Sebroeck

    Guenter Roeck
     

30 Dec, 2015

1 commit

  • All variables required by the watchdog core to manage a watchdog are
    currently stored in struct watchdog_device. The lifetime of those
    variables is determined by the watchdog driver. However, the lifetime
    of variables used by the watchdog core differs from the lifetime of
    struct watchdog_device. To remedy this situation, watchdog drivers
    can implement ref and unref callbacks, to be used by the watchdog
    core to lock struct watchdog_device in memory.

    While this solves the immediate problem, it depends on watchdog drivers
    to actually implement the ref/unref callbacks. This is error prone,
    often not implemented in the first place, or not implemented correctly.

    To solve the problem without requiring driver support, split the variables
    in struct watchdog_device into two data structures - one for variables
    associated with the watchdog driver, one for variables associated with
    the watchdog core. With this approach, the watchdog core can keep track
    of its variable lifetime and no longer depends on ref/unref callbacks
    in the driver. As a side effect, some of the variables originally in
    struct watchdog_driver are now private to the watchdog core and no longer
    visible in watchdog drivers.

    As a side effect of the changes made, an ioctl will now always fail
    with -ENODEV after a watchdog device was unregistered with the character
    device still open. Previously, it would only fail with -ENODEV in some
    situations. Also, ioctl operations are now atomic from driver perspective.
    With this change, it is now guaranteed that the driver will not unregister
    a watchdog between a timeout change and the subsequent ping.

    The 'ref' and 'unref' callbacks in struct watchdog_driver are no longer
    used and marked as deprecated.

    Signed-off-by: Guenter Roeck
    Signed-off-by: Wim Van Sebroeck

    Guenter Roeck
     

13 Dec, 2015

2 commits

  • Many watchdog drivers register a reboot notifier in order to stop the
    watchdog on system reboot. Thus we can factorize this code in the
    watchdog core.

    For that purpose, a new notifier block is added in watchdog_device for
    internal use only, as well as a new watchdog_stop_on_reboot helper
    function.

    If this helper is called, watchdog core registers the related notifier
    block and will stop the watchdog when SYS_HALT or SYS_DOWN is received.

    Since this operation can be critical on some platforms, abort the device
    registration if the reboot notifier registration fails.

    Suggested-by: Vivien Didelot
    Signed-off-by: Damien Riegel
    Reviewed-by: Vivien Didelot
    Signed-off-by: Guenter Roeck
    Signed-off-by: Wim Van Sebroeck

    Damien Riegel
     
  • Many watchdog drivers implement the same code to register a restart
    handler. This patch provides a generic way to set such a function.

    The patch adds a new restart watchdog operation. If a restart priority
    greater than 0 is needed, the driver can call
    watchdog_set_restart_priority to set it.

    Suggested-by: Vivien Didelot
    Signed-off-by: Damien Riegel
    Reviewed-by: Guenter Roeck
    Reviewed-by: Vivien Didelot
    Signed-off-by: Guenter Roeck
    Signed-off-by: Wim Van Sebroeck

    Damien Riegel
     

29 Jun, 2015

1 commit


01 Mar, 2013

1 commit

  • Add support for watchdog drivers to initialize/set the timeout field
    of the watchdog_device structure. The timeout field is initialised
    either with the module timeout parameter value (if valid) or with the
    timeout-sec dt property (if valid). If both are invalid the initial
    value is unchanged.

    Signed-off-by: Fabio Porcedda
    Acked-by: Nicolas Ferre
    Signed-off-by: Wim Van Sebroeck

    Fabio Porcedda
     

30 May, 2012

4 commits

  • If a driver's watchdog_device struct is part of a dynamically allocated
    struct (which it often will be), merely locking the module is not enough,
    even with a drivers module locked, the driver can be unbound from the device,
    examples:
    1) The root user can unbind it through sysfd
    2) The i2c bus master driver being unloaded for an i2c watchdog

    I will gladly admit that these are corner cases, but we still need to handle
    them correctly.

    The fix for this consists of 2 parts:
    1) Add ref / unref operations, so that the driver can refcount the struct
    holding the watchdog_device struct and delay freeing it until any
    open filehandles referring to it are closed
    2) Most driver operations will do IO on the device and the driver should not
    do any IO on the device after it has been unbound. Rather then letting each
    driver deal with this internally, it is better to ensure at the watchdog
    core level that no operations (other then unref) will get called after
    the driver has called watchdog_unregister_device(). This actually is the
    bulk of this patch.

    Signed-off-by: Hans de Goede
    Signed-off-by: Wim Van Sebroeck

    Hans de Goede
     
  • This patch fixes some potential multithreading issues, despite only
    allowing one process to open the /dev/watchdog device, we can still get
    called multiple times at the same time, since a program could be using thread,
    or could share the fd after a fork.

    This causes 2 potential problems:
    1) watchdog_start / open do an unlocked test_n_set / test_n_clear,
    if these 2 race, the watchdog could be stopped while the active
    bit indicates it is running or visa versa.

    2) Most watchdog_dev drivers probably assume that only one
    watchdog-op will get called at a time, this is not necessary
    true atm.

    Signed-off-by: Hans de Goede
    Signed-off-by: Wim Van Sebroeck

    Hans de Goede
     
  • Create the watchdog class and it's associated devices.

    Signed-off-by: Alan Cox
    Signed-off-by: Hans de Goede
    Signed-off-by: Wim Van Sebroeck

    Alan Cox
     
  • We keep the old /dev/watchdog interface file for the first watchdog via
    miscdev. This is basically a cut and paste of the relevant interface code
    from the rtc driver layer tweaked for watchdog.

    Revised to fix problems noted by Hans de Goede

    Signed-off-by: Alan Cox
    Signed-off-by: Hans de Goede
    Signed-off-by: Tomas Winkler
    Signed-off-by: Wim Van Sebroeck

    Alan Cox
     

23 May, 2012

1 commit


28 Mar, 2012

2 commits


21 Feb, 2012

1 commit


06 Jan, 2012

1 commit


28 Jul, 2011

9 commits