watchdog: gpio_wdt: set WDOG_HW_RUNNING in gpio_wdt_stop

"Linux Kernel Mailing List" <[email protected]>
Newsgroups gmane.linux.kernel.commits.head
Message-ID <[email protected]>
Web:        https://git.kernel.org/torvalds/c/bc137dfdbec27c0ec5731a89002daded4a4aa1ea
Commit:     bc137dfdbec27c0ec5731a89002daded4a4aa1ea
Parent:     57b6d481f7a59c091b53a18c843d8631fa04f7eb
Refname:    refs/heads/master
Author:     Rasmus Villemoes <[email protected]>
AuthorDate: Thu Nov 9 14:39:55 2017 +0100
Committer:  Wim Van Sebroeck <[email protected]>
CommitDate: Thu Dec 28 20:45:36 2017 +0100

    watchdog: gpio_wdt: set WDOG_HW_RUNNING in gpio_wdt_stop
    
    The first patch above (https://patchwork.kernel.org/patch/9970181/)
    makes the oops go away, but it just papers over the problem. The real
    problem is that the watchdog core clears WDOG_HW_RUNNING in
    watchdog_stop, and the gpio driver fails to set it in its stop
    function when it doesn't actually stop it. This means that the core
    doesn't know that it now has responsibility for petting the device, in
    turn causing the device to reset the system (I hadn't noticed this
    because the board I'm working on has that reset logic disabled).
    
    How about this (other drivers may of course have the same problem, I
    haven't checked). One might say that ->stop should return an error
    when the device can't be stopped, but OTOH this brings parity between
    a device without a ->stop method and a GPIO wd that has always-running
    set. IOW, I think ->stop should only return an error when an actual
    attempt to stop the hardware failed.
    
    From: Rasmus Villemoes <[email protected]>
    
    The watchdog framework clears WDOG_HW_RUNNING before calling
    ->stop. If the driver is unable to stop the device, it is supposed to
    set that bit again so that the watchdog core takes care of sending
    heart-beats while the device is not open from user-space. Update the
    gpio_wdt driver to honour that contract (and get rid of the redundant
    clearing of WDOG_HW_RUNNING).
    
    Fixes: 3c10bbde10 ("watchdog: core: Clear WDOG_HW_RUNNING before calling the stop function")
    Signed-off-by: Rasmus Villemoes <[email protected]>
    Reviewed-by: Guenter Roeck <[email protected]>
    Signed-off-by: Guenter Roeck <[email protected]>
    Signed-off-by: Wim Van Sebroeck <[email protected]>
---
 drivers/watchdog/gpio_wdt.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/watchdog/gpio_wdt.c b/drivers/watchdog/gpio_wdt.c
index b077c88a5ceb..3ade28190341 100644
--- a/drivers/watchdog/gpio_wdt.c
+++ b/drivers/watchdog/gpio_wdt.c
@@ -81,7 +81,8 @@ static int gpio_wdt_stop(struct watchdog_device *wdd)
 
 	if (!priv->always_running) {
 		gpio_wdt_disable(priv);
-		clear_bit(WDOG_HW_RUNNING, &wdd->status);
+	} else {
+		set_bit(WDOG_HW_RUNNING, &wdd->status);
 	}
 
 	return 0;
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.