mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] watchdog: imxwd: suspend watchdog timer in low power mode
@ 2021-12-16 12:26 Andrej Picej
  2022-01-03  9:05 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Andrej Picej @ 2021-12-16 12:26 UTC (permalink / raw)
  To: barebox

Watchdog timer should be disabled in low power mode. The problem that
was observed was that when the watchdog is started from barebox, kernel
driver doesn't do its own setup again and in turn this bit is left
unset. Moreover, this bit is write-once and has to be set before
enabling the watchdog, leaving responsibility for proper setup to a
party first using the watchdog timer (e.g. bootloader). Issue manifests
itself later on, when device enters low power mode (e.g. suspend) for
more amount of time than what is maximum watchdog timeout (128s). After
that period of time, device will not recover ever as there is no service
patting the watchdog (CPU is suspended). This means that the device can
hang in suspend mode or it performs an unexpected reset.

Thus to avoid suspend/resume problems when watchdog is started already
in the bootloader, align bootloader driver settings with kernel settings.
Kernel driver has been already setting this bit since 2014.

Signed-off-by: Andrej Picej <andrej.picej@norik.com>
---
 drivers/watchdog/imxwd.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/watchdog/imxwd.c b/drivers/watchdog/imxwd.c
index b2cfd1cd3..653c2d9c4 100644
--- a/drivers/watchdog/imxwd.c
+++ b/drivers/watchdog/imxwd.c
@@ -54,6 +54,7 @@ struct imx_wd {
 #define IMX21_WDOG_WSR	0x02 /* Watchdog Service Register */
 #define IMX21_WDOG_WSTR	0x04 /* Watchdog Status Register  */
 #define IMX21_WDOG_WMCR	0x08 /* Misc Register */
+#define IMX21_WDOG_WCR_WDZST	(1 << 0)
 #define IMX21_WDOG_WCR_WDE	(1 << 2)
 #define IMX21_WDOG_WCR_WDT	(1 << 3)
 #define IMX21_WDOG_WCR_SRS	(1 << 4)
@@ -132,6 +133,9 @@ static int imx21_watchdog_set_timeout(struct imx_wd *priv, unsigned timeout)
 	if (priv->ext_reset)
 		val |= IMX21_WDOG_WCR_WDT;
 
+	/* Suspend timer in low power mode */
+	val |= IMX21_WDOG_WCR_WDZST;
+
 	/*
 	 * set time and some write once bits first prior enabling the
 	 * watchdog according to the datasheet
-- 
2.25.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] watchdog: imxwd: suspend watchdog timer in low power mode
  2021-12-16 12:26 [PATCH] watchdog: imxwd: suspend watchdog timer in low power mode Andrej Picej
@ 2022-01-03  9:05 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2022-01-03  9:05 UTC (permalink / raw)
  To: Andrej Picej; +Cc: barebox

On Thu, Dec 16, 2021 at 01:26:53PM +0100, Andrej Picej wrote:
> Watchdog timer should be disabled in low power mode. The problem that
> was observed was that when the watchdog is started from barebox, kernel
> driver doesn't do its own setup again and in turn this bit is left
> unset. Moreover, this bit is write-once and has to be set before
> enabling the watchdog, leaving responsibility for proper setup to a
> party first using the watchdog timer (e.g. bootloader). Issue manifests
> itself later on, when device enters low power mode (e.g. suspend) for
> more amount of time than what is maximum watchdog timeout (128s). After
> that period of time, device will not recover ever as there is no service
> patting the watchdog (CPU is suspended). This means that the device can
> hang in suspend mode or it performs an unexpected reset.
> 
> Thus to avoid suspend/resume problems when watchdog is started already
> in the bootloader, align bootloader driver settings with kernel settings.
> Kernel driver has been already setting this bit since 2014.
> 
> Signed-off-by: Andrej Picej <andrej.picej@norik.com>
> ---
>  drivers/watchdog/imxwd.c | 4 ++++
>  1 file changed, 4 insertions(+)

Applied, thanks

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] 2+ messages in thread

end of thread, other threads:[~2022-01-03  9:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-16 12:26 [PATCH] watchdog: imxwd: suspend watchdog timer in low power mode Andrej Picej
2022-01-03  9:05 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox