mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Josh Cartwright <joshc@codeaurora.org>
Cc: Wim Van Sebroeck <wim@iguana.be>,
	linux-watchdog@vger.kernel.org, linux-arm-msm@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	Kumar Gala <galak@codeaurora.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 3/3] watchdog: qcom: register a restart notifier
Date: Wed, 24 Sep 2014 10:05:21 -0700	[thread overview]
Message-ID: <20140924170521.GB31578@roeck-us.net> (raw)
In-Reply-To: <2d539bc944f3e8fc70f39728b0f61fd171b2e5bf.1411513109.git.joshc@codeaurora.org>

On Tue, Sep 23, 2014 at 06:04:38PM -0500, Josh Cartwright wrote:
> The WDT's BITE_TIME warm-reset behavior can be leveraged as a last
> resort mechanism for triggering chip reset.  Usually, other restart
> methods (such as PS_HOLD) are preferrable for issuing a more complete
> reset of the chip.  As such, keep the priority of the watchdog notifier
> low.
> 
> Signed-off-by: Josh Cartwright <joshc@codeaurora.org>
> ---
>  drivers/watchdog/qcom-wdt.c | 28 ++++++++++++++++++++++++++++
>  1 file changed, 28 insertions(+)
> 
> diff --git a/drivers/watchdog/qcom-wdt.c b/drivers/watchdog/qcom-wdt.c
> index d5e46e2..eba92ef 100644
> --- a/drivers/watchdog/qcom-wdt.c
> +++ b/drivers/watchdog/qcom-wdt.c
> @@ -16,6 +16,7 @@
>  #include <linux/module.h>
>  #include <linux/of.h>
>  #include <linux/platform_device.h>
> +#include <linux/reboot.h>
>  #include <linux/watchdog.h>
>  
>  #define WDT_RST		0x0
> @@ -25,6 +26,7 @@
>  struct qcom_wdt {
>  	struct watchdog_device	wdd;
>  	struct clk		*clk;
> +	struct notifier_block	restart_nb;
>  	void __iomem		*base;
>  };
>  
> @@ -86,6 +88,23 @@ static const struct watchdog_info qcom_wdt_info = {
>  	.identity	= KBUILD_MODNAME,
>  };
>  
> +static int qcom_wdt_restart(struct notifier_block *nb, unsigned long action,
> +			    void *data)
> +{
> +	struct qcom_wdt *wdt = container_of(nb, struct qcom_wdt, restart_nb);
> +
> +	/*
> +	 * Trigger watchdog bite:
> +	 *    Setup BITE_TIME to be very low, and enable WDT.
> +	 *      0x31F3 => 390ms @ 32kHz, also value at reset

What happens if you set it to a lower value ? If you set it to, say,
0x100, would the timeout be ~8ms ? Wouldn't that make more sense ?
Or at least something like 0x800, which should make it around 64 ms,
or 0x400 for 32 ms.

[ In other words, I don't really see the point for a 390 ms wait here ]

> +	 */
> +	writel(0, wdt->base + WDT_EN);
> +	writel(1, wdt->base + WDT_RST);
> +	writel(0x31F3, wdt->base + WDT_BITE_TIME);
> +	writel(1, wdt->base + WDT_EN);

You should have some mdelay() here, larger than the expected timeout.

Thanks,
Guenter

> +	return NOTIFY_DONE;
> +}
> +
>  static int qcom_wdt_probe(struct platform_device *pdev)
>  {
>  	struct qcom_wdt *wdt;
> @@ -141,6 +160,14 @@ static int qcom_wdt_probe(struct platform_device *pdev)
>  		return ret;
>  	}
>  
> +	/*
> +	 * WDT restart notifier has priority 0 (use as a last resort)
> +	 */
> +	wdt->restart_nb.notifier_call = qcom_wdt_restart;
> +	ret = register_restart_handler(&wdt->restart_nb);
> +	if (ret)
> +		dev_err(&pdev->dev, "failed to setup restart handler\n");
> +
>  	platform_set_drvdata(pdev, wdt);
>  	return 0;
>  }
> @@ -149,6 +176,7 @@ static int qcom_wdt_remove(struct platform_device *pdev)
>  {
>  	struct qcom_wdt *wdt = platform_get_drvdata(pdev);
>  
> +	unregister_restart_handler(&wdt->restart_nb);
>  	watchdog_unregister_device(&wdt->wdd);
>  	clk_disable_unprepare(wdt->clk);
>  	return 0;
> -- 
> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
> hosted by The Linux Foundation
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

      reply	other threads:[~2014-09-24 17:05 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-23 23:04 [PATCH v2 0/3] watchdog: add support for QCOM WDT Josh Cartwright
2014-09-23 23:04 ` [PATCH v2 1/3] watchdog: qcom: add support for KPSS WDT Josh Cartwright
2014-09-24 15:58   ` Guenter Roeck
2014-09-24 18:30     ` Josh Cartwright
2014-09-23 23:04 ` [PATCH v2 2/3] watchdog: qcom: document device tree bindings Josh Cartwright
2014-09-24 10:44   ` Arnd Bergmann
2014-09-24 10:56     ` Mark Rutland
2014-09-23 23:04 ` [PATCH v2 3/3] watchdog: qcom: register a restart notifier Josh Cartwright
2014-09-24 17:05   ` Guenter Roeck [this message]

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=20140924170521.GB31578@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=galak@codeaurora.org \
    --cc=joshc@codeaurora.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-watchdog@vger.kernel.org \
    --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

all inboxes | Powered by JetHome®