* [PATCH] IMX: Rearm watchdog after loading value for restart
@ 2017-04-27 13:14 frederikj at gmail.com
2017-04-27 19:57 ` Baruch Siach
2017-04-28 10:03 ` Lothar Waßmann
0 siblings, 2 replies; 4+ messages in thread
From: frederikj at gmail.com @ 2017-04-27 13:14 UTC (permalink / raw)
To: linux-arm-kernel
When calling the restart function the watchdog is activated and the WDOG
timeout field is set to 0. This gives a reset time of 500 ms, which is
consistent with the following delay. However this new time is not loaded
into the WDOG until the WDOG service routine is run (see IMX6SXRM section
70.5.1.1 "Servicing WDOG to reload the counter").
Not reloading the counter could result in a random delay up to 128 seconds
before the system restarts, depending on the previous value of the WDOG
timeout field and when it has last been serviced. That bug is fixed with
this patch.
Signed-off-by: Frederik Juul <Frederik.juul@3shape.com>
--- linux/arch/arm/mach-imx/system.c.orig 2017-04-20 10:41:33.207558297 +0200
+++ linux/arch/arm/mach-imx/system.c 2017-04-27 14:27:19.225474885 +0200
@@ -32,6 +32,8 @@
#include "common.h"
#include "hardware.h"
+#define IMX_WATCHDOG_SERVICE_REGISTER 2
+
static void __iomem *wdog_base;
static struct clk *wdog_clk;
static int wcr_enable = (1 << 2);
@@ -59,6 +61,10 @@ void mxc_restart(enum reboot_mode mode,
imx_writew(wcr_enable, wdog_base);
imx_writew(wcr_enable, wdog_base);
+ /* Rearm WDOG to load 500ms value */
+ imx_writew(0x5555, wdog_base+IMX_WATCHDOG_SERVICE_REGISTER);
+ imx_writew(0xaaaa, wdog_base+IMX_WATCHDOG_SERVICE_REGISTER);
+
/* wait for reset to assert... */
mdelay(500);
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] IMX: Rearm watchdog after loading value for restart
2017-04-27 13:14 [PATCH] IMX: Rearm watchdog after loading value for restart frederikj at gmail.com
@ 2017-04-27 19:57 ` Baruch Siach
2017-04-28 10:03 ` Lothar Waßmann
1 sibling, 0 replies; 4+ messages in thread
From: Baruch Siach @ 2017-04-27 19:57 UTC (permalink / raw)
To: linux-arm-kernel
Hi Frederik,
On Thu, Apr 27, 2017 at 03:14:34PM +0200, frederikj at gmail.com wrote:
> When calling the restart function the watchdog is activated and the WDOG
> timeout field is set to 0. This gives a reset time of 500 ms, which is
> consistent with the following delay. However this new time is not loaded
> into the WDOG until the WDOG service routine is run (see IMX6SXRM section
> 70.5.1.1 "Servicing WDOG to reload the counter").
>
> Not reloading the counter could result in a random delay up to 128 seconds
> before the system restarts, depending on the previous value of the WDOG
> timeout field and when it has last been serviced. That bug is fixed with
> this patch.
Which platform are you using? This code seems to only be used on legacy
platforms that were not converted to DT. For DT based systems, including all
i.MX6, the equivalent version is at
drivers/watchdog/imx2_wdt.c:imx2_wdt_restart().
baruch
> Signed-off-by: Frederik Juul <Frederik.juul@3shape.com>
>
> --- linux/arch/arm/mach-imx/system.c.orig 2017-04-20 10:41:33.207558297 +0200
> +++ linux/arch/arm/mach-imx/system.c 2017-04-27 14:27:19.225474885 +0200
> @@ -32,6 +32,8 @@
> #include "common.h"
> #include "hardware.h"
>
> +#define IMX_WATCHDOG_SERVICE_REGISTER 2
> +
> static void __iomem *wdog_base;
> static struct clk *wdog_clk;
> static int wcr_enable = (1 << 2);
> @@ -59,6 +61,10 @@ void mxc_restart(enum reboot_mode mode,
> imx_writew(wcr_enable, wdog_base);
> imx_writew(wcr_enable, wdog_base);
>
> + /* Rearm WDOG to load 500ms value */
> + imx_writew(0x5555, wdog_base+IMX_WATCHDOG_SERVICE_REGISTER);
> + imx_writew(0xaaaa, wdog_base+IMX_WATCHDOG_SERVICE_REGISTER);
> +
> /* wait for reset to assert... */
> mdelay(500);
--
http://baruch.siach.name/blog/ ~. .~ Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
- baruch at tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] IMX: Rearm watchdog after loading value for restart
2017-04-27 13:14 [PATCH] IMX: Rearm watchdog after loading value for restart frederikj at gmail.com
2017-04-27 19:57 ` Baruch Siach
@ 2017-04-28 10:03 ` Lothar Waßmann
2017-04-28 12:45 ` Frederik Juul
1 sibling, 1 reply; 4+ messages in thread
From: Lothar Waßmann @ 2017-04-28 10:03 UTC (permalink / raw)
To: linux-arm-kernel
Hi,
On Thu, 27 Apr 2017 15:14:34 +0200 frederikj at gmail.com wrote:
> When calling the restart function the watchdog is activated and the WDOG
> timeout field is set to 0. This gives a reset time of 500 ms, which is
> consistent with the following delay. However this new time is not loaded
> into the WDOG until the WDOG service routine is run (see IMX6SXRM section
> 70.5.1.1 "Servicing WDOG to reload the counter").
>
> Not reloading the counter could result in a random delay up to 128 seconds
> before the system restarts, depending on the previous value of the WDOG
> timeout field and when it has last been serviced. That bug is fixed with
> this patch.
>
The routine is actually initiating a softreset by clearing the SRS bit
in WCR. Thus the watchdog timeout should only have any effect, if the
softreset fails in some way. Under normal circumstances the reset
should happen immediately no matter what watchdog timeout is programmed.
Lothar Wa?mann
--
___________________________________________________________
Ka-Ro electronics GmbH | Pascalstra?e 22 | D - 52076 Aachen
Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10
Gesch?ftsf?hrer: Matthias Kaussen
Handelsregistereintrag: Amtsgericht Aachen, HRB 4996
www.karo-electronics.de | info at karo-electronics.de
___________________________________________________________
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] IMX: Rearm watchdog after loading value for restart
2017-04-28 10:03 ` Lothar Waßmann
@ 2017-04-28 12:45 ` Frederik Juul
0 siblings, 0 replies; 4+ messages in thread
From: Frederik Juul @ 2017-04-28 12:45 UTC (permalink / raw)
To: linux-arm-kernel
Disregard this patch then :) I had seen some strange behavior when toying with watchdog where it didn?t reset properly and wrote the "something went wrong" message. This patch fixed it for me, but I guess I may have misunderstood the issue.
Frederik Juul
-----Original Message-----
From: Lothar Wa?mann [mailto:LW at KARO-electronics.de]
Sent: 28. april 2017 12:03
To: frederikj at gmail.com
Cc: linux-arm-kernel at lists.infradead.org; shawnguo at kernel.org; fabio.estevam at nxp.com; kernel at pengutronix.de; Frederik Juul <Frederik.Juul@3shape.com>
Subject: Re: [PATCH] IMX: Rearm watchdog after loading value for restart
Hi,
On Thu, 27 Apr 2017 15:14:34 +0200 frederikj at gmail.com wrote:
> When calling the restart function the watchdog is activated and the
> WDOG timeout field is set to 0. This gives a reset time of 500 ms,
> which is consistent with the following delay. However this new time is
> not loaded into the WDOG until the WDOG service routine is run (see
> IMX6SXRM section
> 70.5.1.1 "Servicing WDOG to reload the counter").
>
> Not reloading the counter could result in a random delay up to 128
> seconds before the system restarts, depending on the previous value of
> the WDOG timeout field and when it has last been serviced. That bug is
> fixed with this patch.
>
The routine is actually initiating a softreset by clearing the SRS bit in WCR. Thus the watchdog timeout should only have any effect, if the softreset fails in some way. Under normal circumstances the reset should happen immediately no matter what watchdog timeout is programmed.
Lothar Wa?mann
--
___________________________________________________________
Ka-Ro electronics GmbH | Pascalstra?e 22 | D - 52076 Aachen
Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10
Gesch?ftsf?hrer: Matthias Kaussen
Handelsregistereintrag: Amtsgericht Aachen, HRB 4996
www.karo-electronics.de | info at karo-electronics.de ___________________________________________________________
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-04-28 12:45 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-27 13:14 [PATCH] IMX: Rearm watchdog after loading value for restart frederikj at gmail.com
2017-04-27 19:57 ` Baruch Siach
2017-04-28 10:03 ` Lothar Waßmann
2017-04-28 12:45 ` Frederik Juul
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).