30 Dec, 2015

5 commits

  • Reference counting is now implemented in the watchdog core and no longer
    required in watchdog drivers.

    Since it was implememented a no-op, and since the local memory is allocated
    with devm_kzalloc(), the reference counting code in the driver really did
    not really work anyway, and this patch effectively fixes a bug which could
    cause a crash on unloading if the watchdog device was still open.

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

    Guenter Roeck
     
  • Reference counting is now implemented in the watchdog core and no longer
    required in watchdog drivers.

    Since it was implememented a no-op, and since the local memory is allocated
    with devm_kzalloc(), the reference counting code in the driver really did
    not really work anyway, and this patch effectively fixes a bug which could
    cause a crash on unloading if the watchdog device was still open.

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

    Guenter Roeck
     
  • 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
     
  • A watchdog driver should not use watchdog subsystem internal flags.
    Use a driver variable and flag instead to maintain the watchdog state
    and to determine if a suspend operation is possible or not.

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

    Guenter Roeck
     
  • The watchdog character device is currently created in watchdog_dev.c,
    and the watchdog device in watchdog_core.c. This results in
    cross-dependencies, since device creation needs to know the watchdog
    character device number as well as the watchdog class, both of which
    reside in watchdog_dev.c.

    Create the watchdog device in watchdog_dev.c to simplify the code.

    Inspired by earlier patch set from Damien Riegel.

    Cc: Damien Riegel
    Signed-off-by: Guenter Roeck
    Signed-off-by: Wim Van Sebroeck

    Guenter Roeck
     

29 Dec, 2015

16 commits


28 Dec, 2015

9 commits

  • Use to_platform_device() instead of open-coding it.

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

    Geliang Tang
     
  • With the early_enable module parameter the watchdog can be started
    during driver probe time. If this is requested the bets are good that
    the timer is already running, so to narrow the gap where the timer is
    disabled only call the disable function when the timer shouldn't be
    started.

    Signed-off-by: Uwe Kleine-König
    Signed-off-by: Guenter Roeck
    Signed-off-by: Wim Van Sebroeck

    Uwe Kleine-König
     
  • omap_wdt_start calls pm_runtime_get_sync so dropping a reference just
    before calling omap_wdt_start doesn't make much sense. Moreover there is
    no point to use the synchronous variant of pm_runtime_put because the
    driver doesn't care if the clock is disabled before or after
    omap_wdt_probe returns.

    Signed-off-by: Uwe Kleine-König
    Signed-off-by: Guenter Roeck
    Signed-off-by: Wim Van Sebroeck

    Uwe Kleine-König
     
  • On 64bit platforms, "(1 << (16 + top)) / clk_get_rate(dw_wdt.clk)" is
    sign-extended to 64bit then converted to unsigned 64bit, finally divide
    the clk rate. If the top is the maximum TOP i.e 15, "(1 << (16 +15))"
    will be sign-extended to 0xffffffff80000000, then converted to unsigned
    0xffffffff80000000, which is a huge number, thus the final result is
    wrong.

    We fix this issue by giving usigned value(1U in this case) at first.

    Let's assume clk rate is 25MHZ,
    Before the patch:
    dw_wdt_top_in_seconds(15) = -864612050

    After the patch:
    dw_wdt_top_in_seconds(15) = 85

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

    Jisheng Zhang
     
  • the softdog has static variables which are accessed if its timer is
    still running after the driver is unloaded. and lead to crash:

    $modprobe softdog
    $echo 1 >/dev/watchdog
    $modprobe -r softdog

    CPU 20 Unable to handle kernel paging request at virtual address
    Oops[#1]:
    CPU: 20 PID: 0 Comm: swapper/20 Not tainted 4.1.13-WR8.0.0.0_standard
    ...
    Modules linked in: [last unloaded: softdog]
    ....
    Call Trace:
    [] cascade+0x34/0xb0
    [] run_timer_softirq+0x30c/0x368
    [] __do_softirq+0x1ec/0x418
    [] irq_exit+0x90/0x98
    [] plat_irq_dispatch+0xa4/0x140
    [] ret_from_irq+0x0/0x4
    [] __r4k_wait+0x20/0x40
    [] cpu_startup_entry+0x2a0/0x368
    [] start_secondary+0x444/0x4d8

    add the module ref when timer is running to avoid to unload the softdog
    module

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

    Li RongQing
     
  • This allows the system to actually halt even if userspace forgot to
    disable the watchdog first. Old behaviour was that the watchdog forced
    the system to boot again.

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

    Harald Geyer
     
  • For SB800 and later chipsets, the register definitions are the same
    with SB800. And for SB700 and older chipsets, the definitions should
    be same with SP5100/SB7x0.

    Signed-off-by: Huang Rui
    Cc: Denis Turischev
    Signed-off-by: Guenter Roeck
    Signed-off-by: Wim Van Sebroeck

    Huang Rui
     
  • sp5100_tco watchdog is also supported on AMD KernCZ chipset of Carrizo
    platform.

    Signed-off-by: Huang Rui
    Cc: Denis Turischev
    Signed-off-by: Guenter Roeck
    Signed-off-by: Wim Van Sebroeck

    Huang Rui
     
  • AMD Mullins watchdog is fully compatible to the previous Hudson chipset,
    reuse the existent sp5100_tco driver.

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

    Denis Turischev
     

27 Dec, 2015

2 commits

  • This patch adds following attributes to watchdog device's sysfs interface
    to read its different status.

    * state - reads whether device is active or not
    * identity - reads Watchdog device's identity string.
    * timeout - reads current timeout.
    * timeleft - reads timeleft before watchdog generates a reset
    * bootstatus - reads status of the watchdog device at boot
    * status - reads watchdog device's internal status bits
    * nowayout - reads whether nowayout feature was set or not

    Testing with iTCO_wdt:
    # cd /sys/class/watchdog/watchdog1/
    # ls
    bootstatus dev device identity nowayout power state
    subsystem timeleft timeout uevent
    # cat identity
    iTCO_wdt
    # cat timeout
    30
    # cat state
    inactive
    # echo > /dev/watchdog1
    # cat timeleft
    26
    # cat state
    active
    # cat bootstatus
    0
    # cat nowayout
    0

    Signed-off-by: Pratyush Anand
    Reviewed-by: Guenter Roeck
    Signed-off-by: Guenter Roeck
    Signed-off-by: Wim Van Sebroeck

    Pratyush Anand
     
  • We need few sysfs attributes to know different status of a watchdog device.
    To do that, we need to associate .dev_groups with watchdog_class. So
    convert it from pointer to static.
    Putting this static struct in watchdog_dev.c, so that static device
    attributes defined in that file can be attached to it.

    Signed-off-by: Pratyush Anand
    Suggested-by: Guenter Roeck
    Reviewed-by: Guenter Roeck
    Signed-off-by: Guenter Roeck
    Signed-off-by: Wim Van Sebroeck

    Pratyush Anand
     

13 Dec, 2015

8 commits

  • Get rid of the custom reboot notifier block registration and use the one
    provided by the watchdog core.

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

    Damien Riegel
     
  • Get rid of the custom reboot notifier block registration and use the one
    provided by the watchdog core.

    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
     
  • Get rid of the custom reboot notifier block registration and use the one
    provided by the watchdog core.

    Note that this watchdog used to stop unconditionnaly on SYS_HALT and
    SYS_POWER_OFF. The core function now calls ops->stop on SYS_HALT and
    SYS_DOWN. To prevent the watchdog from being stopped on reboot, the
    "always-running" property must be set, otherwise it will now be stopped.

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

    Damien Riegel
     
  • Get rid of the custom reboot notifier block registration and use the one
    provided by the watchdog core.

    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
     
  • Get rid of the custom reboot notifier block registration and use the one
    provided by the watchdog core.

    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
     
  • 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
     
  • Get rid of the custom restart handler by using the one provided by the
    watchdog core.

    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
     
  • Get rid of the custom restart handler by using the one provided by the
    watchdog core.

    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