* [PATCH] watchdog: fix watchdog_set_timeout breakage for drivers like imxwd
@ 2020-08-18 13:18 Ahmad Fatoum
2020-08-19 6:59 ` Sascha Hauer
2020-08-19 7:38 ` Sascha Hauer
0 siblings, 2 replies; 5+ messages in thread
From: Ahmad Fatoum @ 2020-08-18 13:18 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum, Bastian Krause
Commit 0b944fce55f4 ("watchdog: permit `wd 0` for non-stoppable, but
inactive, watchdogs") silently broke use of non-stoppable, but inactive,
watchdogs altogether. Because those always had watchdog_hw_running
evaluating to false, it early exited without a chance to ever actually
set the timeout (and for watchdog_hw_running to evaluate to != false).
This results in following watchdog drivers being broken in v2020.08.0:
- imxwd
- f71808e_wdt
- at91sam9_wdt
Fixes: 0b944fce55f4 ("watchdog: permit `wd 0` for non-stoppable, but inactive, watchdogs")
Reported-by: Bastian Krause <bst@pengutronix.de>
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
Please apply to master (and to v2020.08.1?).
---
drivers/watchdog/wd_core.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/watchdog/wd_core.c b/drivers/watchdog/wd_core.c
index ab1dcaa40a3a..4247288dbd0a 100644
--- a/drivers/watchdog/wd_core.c
+++ b/drivers/watchdog/wd_core.c
@@ -45,12 +45,11 @@ int watchdog_set_timeout(struct watchdog *wd, unsigned timeout)
if (timeout > wd->timeout_max)
return -EINVAL;
- if (watchdog_hw_running(wd) == false)
- return 0;
-
pr_debug("setting timeout on %s to %ds\n", watchdog_name(wd), timeout);
ret = wd->set_timeout(wd, timeout);
+ if (ret == -ENOSYS && watchdog_hw_running(wd) == false)
+ return 0;
if (ret)
return ret;
--
2.28.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] watchdog: fix watchdog_set_timeout breakage for drivers like imxwd
2020-08-18 13:18 [PATCH] watchdog: fix watchdog_set_timeout breakage for drivers like imxwd Ahmad Fatoum
@ 2020-08-19 6:59 ` Sascha Hauer
2020-08-19 7:18 ` Ahmad Fatoum
2020-08-19 7:38 ` Sascha Hauer
1 sibling, 1 reply; 5+ messages in thread
From: Sascha Hauer @ 2020-08-19 6:59 UTC (permalink / raw)
To: Ahmad Fatoum; +Cc: barebox, Bastian Krause
Hi Ahmad,
On Tue, Aug 18, 2020 at 03:18:16PM +0200, Ahmad Fatoum wrote:
> Commit 0b944fce55f4 ("watchdog: permit `wd 0` for non-stoppable, but
> inactive, watchdogs") silently broke use of non-stoppable, but inactive,
> watchdogs altogether.
Didn't this commit break *all* watchdogs? With 0b944fce55f4 an inactive
watchdog will never be activated anymore.
Sascha
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] watchdog: fix watchdog_set_timeout breakage for drivers like imxwd
2020-08-19 6:59 ` Sascha Hauer
@ 2020-08-19 7:18 ` Ahmad Fatoum
2020-08-19 7:33 ` Sascha Hauer
0 siblings, 1 reply; 5+ messages in thread
From: Ahmad Fatoum @ 2020-08-19 7:18 UTC (permalink / raw)
To: Sascha Hauer; +Cc: barebox, Bastian Krause
On 8/19/20 8:59 AM, Sascha Hauer wrote:
> Hi Ahmad,
>
> On Tue, Aug 18, 2020 at 03:18:16PM +0200, Ahmad Fatoum wrote:
>> Commit 0b944fce55f4 ("watchdog: permit `wd 0` for non-stoppable, but
>> inactive, watchdogs") silently broke use of non-stoppable, but inactive,
>> watchdogs altogether.
>
> Didn't this commit break *all* watchdogs? With 0b944fce55f4 an inactive
> watchdog will never be activated anymore.
watchdog_hw_running() returns -ENOSYS for watchdog that don't report whether
they are running, so it broke all those who do report it and are inactive at
driver probe time.
>
> Sascha
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] watchdog: fix watchdog_set_timeout breakage for drivers like imxwd
2020-08-19 7:18 ` Ahmad Fatoum
@ 2020-08-19 7:33 ` Sascha Hauer
0 siblings, 0 replies; 5+ messages in thread
From: Sascha Hauer @ 2020-08-19 7:33 UTC (permalink / raw)
To: Ahmad Fatoum; +Cc: barebox, Bastian Krause
On Wed, Aug 19, 2020 at 09:18:44AM +0200, Ahmad Fatoum wrote:
> On 8/19/20 8:59 AM, Sascha Hauer wrote:
> > Hi Ahmad,
> >
> > On Tue, Aug 18, 2020 at 03:18:16PM +0200, Ahmad Fatoum wrote:
> >> Commit 0b944fce55f4 ("watchdog: permit `wd 0` for non-stoppable, but
> >> inactive, watchdogs") silently broke use of non-stoppable, but inactive,
> >> watchdogs altogether.
> >
> > Didn't this commit break *all* watchdogs? With 0b944fce55f4 an inactive
> > watchdog will never be activated anymore.
>
> watchdog_hw_running() returns -ENOSYS for watchdog that don't report whether
> they are running, so it broke all those who do report it and are inactive at
> driver probe time.
Ah, I see. I didn't look at the implementation of watchdog_hw_running().
The code explicitly tested for a boolean result, so it seemed obvious to
me that this function returns either true or false, but not an error.
Sascha
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] watchdog: fix watchdog_set_timeout breakage for drivers like imxwd
2020-08-18 13:18 [PATCH] watchdog: fix watchdog_set_timeout breakage for drivers like imxwd Ahmad Fatoum
2020-08-19 6:59 ` Sascha Hauer
@ 2020-08-19 7:38 ` Sascha Hauer
1 sibling, 0 replies; 5+ messages in thread
From: Sascha Hauer @ 2020-08-19 7:38 UTC (permalink / raw)
To: Ahmad Fatoum; +Cc: barebox, Bastian Krause
On Tue, Aug 18, 2020 at 03:18:16PM +0200, Ahmad Fatoum wrote:
> Commit 0b944fce55f4 ("watchdog: permit `wd 0` for non-stoppable, but
> inactive, watchdogs") silently broke use of non-stoppable, but inactive,
> watchdogs altogether. Because those always had watchdog_hw_running
> evaluating to false, it early exited without a chance to ever actually
> set the timeout (and for watchdog_hw_running to evaluate to != false).
>
> This results in following watchdog drivers being broken in v2020.08.0:
>
> - imxwd
> - f71808e_wdt
> - at91sam9_wdt
>
> Fixes: 0b944fce55f4 ("watchdog: permit `wd 0` for non-stoppable, but inactive, watchdogs")
> Reported-by: Bastian Krause <bst@pengutronix.de>
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
> Please apply to master (and to v2020.08.1?).
> ---
> drivers/watchdog/wd_core.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/watchdog/wd_core.c b/drivers/watchdog/wd_core.c
> index ab1dcaa40a3a..4247288dbd0a 100644
> --- a/drivers/watchdog/wd_core.c
> +++ b/drivers/watchdog/wd_core.c
> @@ -45,12 +45,11 @@ int watchdog_set_timeout(struct watchdog *wd, unsigned timeout)
> if (timeout > wd->timeout_max)
> return -EINVAL;
>
> - if (watchdog_hw_running(wd) == false)
> - return 0;
> -
> pr_debug("setting timeout on %s to %ds\n", watchdog_name(wd), timeout);
>
> ret = wd->set_timeout(wd, timeout);
> + if (ret == -ENOSYS && watchdog_hw_running(wd) == false)
Instead of testing for a specific error code from set_timeout(), can't
we just do a
if (!timeout && !watchdog_hw_running(wd))
return 0;
This would make the intention of the code more clear.
Sascha
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-08-19 7:38 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-18 13:18 [PATCH] watchdog: fix watchdog_set_timeout breakage for drivers like imxwd Ahmad Fatoum
2020-08-19 6:59 ` Sascha Hauer
2020-08-19 7:18 ` Ahmad Fatoum
2020-08-19 7:33 ` Sascha Hauer
2020-08-19 7:38 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox