All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] watchdog: ath79_wdt: avoid spurious restarts on AR934x
@ 2014-04-16  9:34 Gabor Juhos
  2014-04-26 15:34 ` Guenter Roeck
  2014-05-26 19:02 ` Wim Van Sebroeck
  0 siblings, 2 replies; 3+ messages in thread
From: Gabor Juhos @ 2014-04-16  9:34 UTC (permalink / raw)
  To: Wim Van Sebroeck; +Cc: linux-watchdog, Gabor Juhos, stable

On some AR934x based systems, where the frequency of
the AHB bus is relatively high, the built-in watchdog
causes a spurious restart when it gets enabled.

The possible cause of these restarts is that the timeout
value written into the TIMER register does not reaches
the hardware in time.

Add an explicit delay into the ath79_wdt_enable function
to avoid the spurious restarts.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Cc: <stable@vger.kernel.org>
---
 drivers/watchdog/ath79_wdt.c |   10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/watchdog/ath79_wdt.c b/drivers/watchdog/ath79_wdt.c
index 399c3fd..0e67d96 100644
--- a/drivers/watchdog/ath79_wdt.c
+++ b/drivers/watchdog/ath79_wdt.c
@@ -20,6 +20,7 @@
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
 #include <linux/bitops.h>
+#include <linux/delay.h>
 #include <linux/errno.h>
 #include <linux/fs.h>
 #include <linux/io.h>
@@ -90,6 +91,15 @@ static inline void ath79_wdt_keepalive(void)
 static inline void ath79_wdt_enable(void)
 {
 	ath79_wdt_keepalive();
+
+	/*
+	 * Updating the TIMER register requires a few microseconds
+	 * on the AR934x SoCs at least. Use a small delay to ensure
+	 * that the TIMER register is updated within the hardware
+	 * before enabling the watchdog.
+	 */
+	udelay(2);
+
 	ath79_wdt_wr(WDOG_REG_CTRL, WDOG_CTRL_ACTION_FCR);
 	/* flush write */
 	ath79_wdt_rr(WDOG_REG_CTRL);
-- 
1.7.10

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

* Re: [PATCH] watchdog: ath79_wdt: avoid spurious restarts on AR934x
  2014-04-16  9:34 [PATCH] watchdog: ath79_wdt: avoid spurious restarts on AR934x Gabor Juhos
@ 2014-04-26 15:34 ` Guenter Roeck
  2014-05-26 19:02 ` Wim Van Sebroeck
  1 sibling, 0 replies; 3+ messages in thread
From: Guenter Roeck @ 2014-04-26 15:34 UTC (permalink / raw)
  To: Gabor Juhos, Wim Van Sebroeck; +Cc: linux-watchdog

On 04/16/2014 02:34 AM, Gabor Juhos wrote:
> On some AR934x based systems, where the frequency of
> the AHB bus is relatively high, the built-in watchdog
> causes a spurious restart when it gets enabled.
>
> The possible cause of these restarts is that the timeout
> value written into the TIMER register does not reaches
> the hardware in time.
>
> Add an explicit delay into the ath79_wdt_enable function
> to avoid the spurious restarts.
>
> Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
> Cc: <stable@vger.kernel.org>

Reviewed-by: Guenter Roeck <linux@roeck-us.net>


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

* Re: [PATCH] watchdog: ath79_wdt: avoid spurious restarts on AR934x
  2014-04-16  9:34 [PATCH] watchdog: ath79_wdt: avoid spurious restarts on AR934x Gabor Juhos
  2014-04-26 15:34 ` Guenter Roeck
@ 2014-05-26 19:02 ` Wim Van Sebroeck
  1 sibling, 0 replies; 3+ messages in thread
From: Wim Van Sebroeck @ 2014-05-26 19:02 UTC (permalink / raw)
  To: Gabor Juhos; +Cc: linux-watchdog, stable

Hi Gabor,

> On some AR934x based systems, where the frequency of
> the AHB bus is relatively high, the built-in watchdog
> causes a spurious restart when it gets enabled.
> 
> The possible cause of these restarts is that the timeout
> value written into the TIMER register does not reaches
> the hardware in time.
> 
> Add an explicit delay into the ath79_wdt_enable function
> to avoid the spurious restarts.
> 
> Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
> Cc: <stable@vger.kernel.org>
> ---
>  drivers/watchdog/ath79_wdt.c |   10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/drivers/watchdog/ath79_wdt.c b/drivers/watchdog/ath79_wdt.c
> index 399c3fd..0e67d96 100644
> --- a/drivers/watchdog/ath79_wdt.c
> +++ b/drivers/watchdog/ath79_wdt.c
> @@ -20,6 +20,7 @@
>  #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
>  
>  #include <linux/bitops.h>
> +#include <linux/delay.h>
>  #include <linux/errno.h>
>  #include <linux/fs.h>
>  #include <linux/io.h>
> @@ -90,6 +91,15 @@ static inline void ath79_wdt_keepalive(void)
>  static inline void ath79_wdt_enable(void)
>  {
>  	ath79_wdt_keepalive();
> +
> +	/*
> +	 * Updating the TIMER register requires a few microseconds
> +	 * on the AR934x SoCs at least. Use a small delay to ensure
> +	 * that the TIMER register is updated within the hardware
> +	 * before enabling the watchdog.
> +	 */
> +	udelay(2);
> +
>  	ath79_wdt_wr(WDOG_REG_CTRL, WDOG_CTRL_ACTION_FCR);
>  	/* flush write */
>  	ath79_wdt_rr(WDOG_REG_CTRL);

This patch has been added to linux-watchdog-next.

Kind regards,
Wim.


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

end of thread, other threads:[~2014-05-26 19:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-16  9:34 [PATCH] watchdog: ath79_wdt: avoid spurious restarts on AR934x Gabor Juhos
2014-04-26 15:34 ` Guenter Roeck
2014-05-26 19:02 ` Wim Van Sebroeck

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.