Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1540218 > unrolled thread

[PATCH] watchdog: bcm2835_wdt: set WDOG_HW_RUNNING bit when appropriate

Started byRasmus Villemoes <rasmus.villemoes@prevas.dk>
First post2016-12-12 10:50 +0100
Last post2016-12-12 18:50 +0100
Articles 3 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] watchdog: bcm2835_wdt: set WDOG_HW_RUNNING bit when appropriate Rasmus Villemoes <rasmus.villemoes@prevas.dk> - 2016-12-12 10:50 +0100
    Re: [PATCH] watchdog: bcm2835_wdt: set WDOG_HW_RUNNING bit when  appropriate Guenter Roeck <linux@roeck-us.net> - 2016-12-12 15:50 +0100
    Re: [PATCH] watchdog: bcm2835_wdt: set WDOG_HW_RUNNING bit when appropriate Eric Anholt <eric@anholt.net> - 2016-12-12 18:50 +0100

#1540218 — [PATCH] watchdog: bcm2835_wdt: set WDOG_HW_RUNNING bit when appropriate

FromRasmus Villemoes <rasmus.villemoes@prevas.dk>
Date2016-12-12 10:50 +0100
Subject[PATCH] watchdog: bcm2835_wdt: set WDOG_HW_RUNNING bit when appropriate
Message-ID<sNvp8-2Ek-7@gated-at.bofh.it>
A bootloader may start the watchdog device before handing control to
the kernel - in that case, we should tell the kernel about it so the
watchdog framework can keep it alive until userspace opens
/dev/watchdog0.

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
---
 drivers/watchdog/bcm2835_wdt.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/drivers/watchdog/bcm2835_wdt.c b/drivers/watchdog/bcm2835_wdt.c
index 4dddd82..c32c45b 100644
--- a/drivers/watchdog/bcm2835_wdt.c
+++ b/drivers/watchdog/bcm2835_wdt.c
@@ -55,6 +55,15 @@ struct bcm2835_wdt {
 static unsigned int heartbeat;
 static bool nowayout = WATCHDOG_NOWAYOUT;
 
+static bool bcm2835_wdt_is_running(struct bcm2835_wdt *wdt)
+{
+	uint32_t cur;
+
+	cur = readl(wdt->base + PM_RSTC);
+
+	return !!(cur & PM_RSTC_WRCFG_FULL_RESET);
+}
+
 static int bcm2835_wdt_start(struct watchdog_device *wdog)
 {
 	struct bcm2835_wdt *wdt = watchdog_get_drvdata(wdog);
@@ -181,6 +190,17 @@ static int bcm2835_wdt_probe(struct platform_device *pdev)
 	watchdog_init_timeout(&bcm2835_wdt_wdd, heartbeat, dev);
 	watchdog_set_nowayout(&bcm2835_wdt_wdd, nowayout);
 	bcm2835_wdt_wdd.parent = &pdev->dev;
+	if (bcm2835_wdt_is_running(wdt)) {
+		/*
+		 * The currently active timeout value (set by the
+		 * bootloader) may be different from the module
+		 * heartbeat parameter or the value in device
+		 * tree. But we just need to set WDOG_HW_RUNNING,
+		 * because then the framework will "immediately" ping
+		 * the device, updating the timeout.
+		 */
+		set_bit(WDOG_HW_RUNNING, &bcm2835_wdt_wdd.status);
+	}
 	err = watchdog_register_device(&bcm2835_wdt_wdd);
 	if (err) {
 		dev_err(dev, "Failed to register watchdog device");
-- 
2.7.4

[toc] | [next] | [standalone]


#1540360 — Re: [PATCH] watchdog: bcm2835_wdt: set WDOG_HW_RUNNING bit when appropriate

FromGuenter Roeck <linux@roeck-us.net>
Date2016-12-12 15:50 +0100
SubjectRe: [PATCH] watchdog: bcm2835_wdt: set WDOG_HW_RUNNING bit when appropriate
Message-ID<sNA5r-5yT-13@gated-at.bofh.it>
In reply to#1540218
On 12/12/2016 01:48 AM, Rasmus Villemoes wrote:
> A bootloader may start the watchdog device before handing control to
> the kernel - in that case, we should tell the kernel about it so the
> watchdog framework can keep it alive until userspace opens
> /dev/watchdog0.
>
> Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>

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

> ---
>  drivers/watchdog/bcm2835_wdt.c | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
>
> diff --git a/drivers/watchdog/bcm2835_wdt.c b/drivers/watchdog/bcm2835_wdt.c
> index 4dddd82..c32c45b 100644
> --- a/drivers/watchdog/bcm2835_wdt.c
> +++ b/drivers/watchdog/bcm2835_wdt.c
> @@ -55,6 +55,15 @@ struct bcm2835_wdt {
>  static unsigned int heartbeat;
>  static bool nowayout = WATCHDOG_NOWAYOUT;
>
> +static bool bcm2835_wdt_is_running(struct bcm2835_wdt *wdt)
> +{
> +	uint32_t cur;
> +
> +	cur = readl(wdt->base + PM_RSTC);
> +
> +	return !!(cur & PM_RSTC_WRCFG_FULL_RESET);
> +}
> +
>  static int bcm2835_wdt_start(struct watchdog_device *wdog)
>  {
>  	struct bcm2835_wdt *wdt = watchdog_get_drvdata(wdog);
> @@ -181,6 +190,17 @@ static int bcm2835_wdt_probe(struct platform_device *pdev)
>  	watchdog_init_timeout(&bcm2835_wdt_wdd, heartbeat, dev);
>  	watchdog_set_nowayout(&bcm2835_wdt_wdd, nowayout);
>  	bcm2835_wdt_wdd.parent = &pdev->dev;
> +	if (bcm2835_wdt_is_running(wdt)) {
> +		/*
> +		 * The currently active timeout value (set by the
> +		 * bootloader) may be different from the module
> +		 * heartbeat parameter or the value in device
> +		 * tree. But we just need to set WDOG_HW_RUNNING,
> +		 * because then the framework will "immediately" ping
> +		 * the device, updating the timeout.
> +		 */
> +		set_bit(WDOG_HW_RUNNING, &bcm2835_wdt_wdd.status);
> +	}
>  	err = watchdog_register_device(&bcm2835_wdt_wdd);
>  	if (err) {
>  		dev_err(dev, "Failed to register watchdog device");
>

[toc] | [prev] | [next] | [standalone]


#1540485

FromEric Anholt <eric@anholt.net>
Date2016-12-12 18:50 +0100
Message-ID<sNCTD-7fH-19@gated-at.bofh.it>
In reply to#1540218

[Multipart message — attachments visible in raw view] — view raw

Rasmus Villemoes <rasmus.villemoes@prevas.dk> writes:

> A bootloader may start the watchdog device before handing control to
> the kernel - in that case, we should tell the kernel about it so the
> watchdog framework can keep it alive until userspace opens
> /dev/watchdog0.

I don't believe our current bootloaders (the closed firmware or u-boot)
set up the watchdog, but this seems reasonable since they might want to
later.

Acked-by: Eric Anholt <eric@anholt.net>

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web