public inbox for linux-watchdog@vger.kernel.org
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	linux-watchdog@vger.kernel.org,
	"Wim Van Sebroeck" <wim@iguana.be>, "Felipe Balbi" <balbi@ti.com>
Cc: Lokesh Vutla <lokeshvutla@ti.com>, kernel@pengutronix.de
Subject: Re: [PATCH v2 5/4] watchdog: omap: assert the counter being stopped before reprogramming
Date: Thu, 30 Apr 2015 21:53:07 -0700	[thread overview]
Message-ID: <554306B3.7060104@roeck-us.net> (raw)
In-Reply-To: <1430332727-27491-1-git-send-email-u.kleine-koenig@pengutronix.de>

On 04/29/2015 11:38 AM, Uwe Kleine-König wrote:
> The omap watchdog has the annoying behaviour that writes to most
> registers don't have any effect when the watchdog is already running.
> Quoting the AM335x reference manual:
>
> 	To modify the timer counter value (the WDT_WCRR register),
> 	prescaler ratio (the WDT_WCLR[4:2] PTV bit field), delay
> 	configuration value (the WDT_WDLY[31:0] DLY_VALUE bit field), or
> 	the load value (the WDT_WLDR[31:0] TIMER_LOAD bit field), the
> 	watchdog timer must be disabled by using the start/stop sequence
> 	(the WDT_WSPR register).
>
> Currently the timer is stopped in the .probe callback but still there
> are possibilities that yield to a situation where omap_wdt_start is
> entered with the timer running (e.g. when /dev/watchdog is closed
> without stopping and then reopened). In such a case programming the
> timeout silently fails!
>
> To circumvent this stop the timer before reprogramming.
>
> Assuming one of the first things the watchdog user does is setting the
> timeout explicitly nothing too bad should happen because this explicit
> setting works fine.
>
> Fixes: 7768a13c252a ("[PATCH] OMAP: Add Watchdog driver support")
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

Annoying, but it looks like it is necessary.

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

> ---
>   drivers/watchdog/omap_wdt.c | 7 +++++++
>   1 file changed, 7 insertions(+)
>
> diff --git a/drivers/watchdog/omap_wdt.c b/drivers/watchdog/omap_wdt.c
> index 0421c06a6cf0..d7619dd7c1ca 100644
> --- a/drivers/watchdog/omap_wdt.c
> +++ b/drivers/watchdog/omap_wdt.c
> @@ -135,6 +135,13 @@ static int omap_wdt_start(struct watchdog_device *wdog)
>
>   	pm_runtime_get_sync(wdev->dev);
>
> +	/*
> +	 * Make sure the watchdog is disabled. This is unfortunately required
> +	 * because writing to various registers with the watchdog running has no
> +	 * effect.
> +	 */
> +	omap_wdt_disable(wdev);
> +
>   	/* initialize prescaler */
>   	while (readl_relaxed(base + OMAP_WATCHDOG_WPS) & 0x01)
>   		cpu_relax();
>


  reply	other threads:[~2015-05-01  4:53 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-27  9:22 [PATCH v2 0/4] watchdog: omap: several cleanups Uwe Kleine-König
2015-04-27  9:22 ` [PATCH v2 1/4] watchdog: omap: clearify device tree documentation Uwe Kleine-König
2015-04-27  9:22 ` [PATCH v2 2/4] watchdog: omap: use watchdog_init_timeout instead of open coding it Uwe Kleine-König
2015-04-27  9:23 ` [PATCH v2 3/4] watchdog: omap: put struct watchdog_device into driver data Uwe Kleine-König
2015-04-27  9:23 ` [PATCH v2 4/4] watchdog: omap: simplify assignment of bootstatus Uwe Kleine-König
2015-04-29 18:38 ` [PATCH v2 5/4] watchdog: omap: assert the counter being stopped before reprogramming Uwe Kleine-König
2015-05-01  4:53   ` Guenter Roeck [this message]
2015-04-29 18:38 ` [PATCH v2 6/4] watchdog: omap: allow to keep timer running at probe time Uwe Kleine-König
2015-04-29 18:47   ` Uwe Kleine-König
2015-05-01  4:52   ` Guenter Roeck
2015-05-05 13:53     ` Uwe Kleine-König
2015-05-08  7:35 ` [PATCH v2 0/4] watchdog: omap: several cleanups Uwe Kleine-König
2015-05-22 17:59   ` Uwe Kleine-König
2015-05-22 19:18     ` Guenter Roeck
2015-07-31  9:33       ` Uwe Kleine-König
2015-07-31 10:04         ` Guenter Roeck
2015-07-31 14:52           ` Uwe Kleine-König
2015-07-31 16:03             ` Guenter Roeck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=554306B3.7060104@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=balbi@ti.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=lokeshvutla@ti.com \
    --cc=u.kleine-koenig@pengutronix.de \
    --cc=wim@iguana.be \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox