mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH master 1/2] sandbox: watchdog: don't return positive values from set_timeout
@ 2021-04-26 11:34 Ahmad Fatoum
  2021-04-26 11:34 ` [PATCH master 2/2] Documentation: user: watchdog: sync with current state Ahmad Fatoum
  2021-05-03 10:38 ` [PATCH master 1/2] sandbox: watchdog: don't return positive values from set_timeout Sascha Hauer
  0 siblings, 2 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2021-04-26 11:34 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

linux_watchdog_set_timeout() does return alarm(), which can never fail
and returns either zero or a positive value.

watchdog::set_timeout on the other hand should return either 0 or
a negative number on error.

Ignore linux_watchdog_set_timeout()'s return value, so
watchdog_set_timeout propagates the correct value.

This fixes an issue where seconds_to_expire wasn't updated on
subsequent pings of this watchdog.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 arch/sandbox/board/watchdog.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/sandbox/board/watchdog.c b/arch/sandbox/board/watchdog.c
index 336451282fd3..e1cff7a0bf0b 100644
--- a/arch/sandbox/board/watchdog.c
+++ b/arch/sandbox/board/watchdog.c
@@ -29,7 +29,8 @@ static int sandbox_watchdog_set_timeout(struct watchdog *wdd, unsigned int timeo
 	if (timeout > wdd->timeout_max)
 		return -EINVAL;
 
-	return linux_watchdog_set_timeout(timeout);
+	linux_watchdog_set_timeout(timeout);
+	return 0;
 }
 
 static int sandbox_watchdog_probe(struct device_d *dev)
-- 
2.29.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


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

* [PATCH master 2/2] Documentation: user: watchdog: sync with current state
  2021-04-26 11:34 [PATCH master 1/2] sandbox: watchdog: don't return positive values from set_timeout Ahmad Fatoum
@ 2021-04-26 11:34 ` Ahmad Fatoum
  2021-05-03 10:38 ` [PATCH master 1/2] sandbox: watchdog: don't return positive values from set_timeout Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2021-04-26 11:34 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum, has

Since most of the documentation was written, the watchdog framework
has gained three more device parameters. Document them.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
Cc: has@pengutronix.de
---
 Documentation/user/watchdog.rst | 36 +++++++++++++++++++++++++++++----
 1 file changed, 32 insertions(+), 4 deletions(-)

diff --git a/Documentation/user/watchdog.rst b/Documentation/user/watchdog.rst
index 02bd576a89c1..ff400317a0bc 100644
--- a/Documentation/user/watchdog.rst
+++ b/Documentation/user/watchdog.rst
@@ -57,6 +57,9 @@ measured in seconds:
   barebox@DPTechnics DPT-Module:/ devinfo wdog0
   Parameters:
     autoping: 1 (type: bool)
+    priority: 100 (type: uint32)
+    running: 1 (type: enum) (values: "unknown", "1", "0")
+    seconds_to_expire: 7 (type: uint32)
     timeout_cur: 7 (type: uint32)
     timeout_max: 10 (type: uint32)
 
@@ -67,6 +70,34 @@ Use barebox' environment to persist these changes between reboots:
   nv dev.wdog0.autoping=1
   nv dev.wdog0.timeout_cur=7
 
+Watchdog State
+~~~~~~~~~~~~~~
+
+To check whether a watchdog is currently running, the ``running`` device
+parameter can be consulted. Not all watchdog devices (or their drivers)
+provide the information whether a watchdog was running prior to barebox.
+In that case, the parameter will contain the value ``unknown``.
+
+Watchdogs started by barebox can be monitored using the
+``seconds_to_expire`` parameter. A well-behaving system of watchdog
+device, watchdog driver and clocksource should reset as soon as the
+count down reaches zero.
+
+To manually start a watchdog, :ref:`command_wd` can be used.
+
+Default Watchdog
+~~~~~~~~~~~~~~~~
+
+barebox supports multiple concurrent watchdogs. The default watchdog used
+with :ref:`command_wd`, ``boot.watchdog_timeout`` and :ref:`command_boot`'s
+``-w`` option is the one with the highest positive priority.
+If multiple watchdogs share the same priority, only one will be affected.
+
+The priority is initially set by drivers and can be overridden in the
+device tree or via the ``priority`` device parameter. Normally, watchdogs
+that have a wider effect should be given the higher priority (e.g.
+PMIC watchdog resetting the board vs. SoC's watchdog resetting only itself).
+
 Boot Watchdog Timeout
 ~~~~~~~~~~~~~~~~~~~~~
 
@@ -85,7 +116,4 @@ or persistently by
   nv boot.watchdog_timeout=10
 
 where the used value again is measured in seconds.
-
-On a system with multiple watchdogs, the watchdog with the highest positive
-priority is the one affected by the ``boot.watchdog_timeout`` parameter.  If
-multiple watchdogs share the same priority, only one will be started.
+Only the default watchdog will be started.
-- 
2.29.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


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

* Re: [PATCH master 1/2] sandbox: watchdog: don't return positive values from set_timeout
  2021-04-26 11:34 [PATCH master 1/2] sandbox: watchdog: don't return positive values from set_timeout Ahmad Fatoum
  2021-04-26 11:34 ` [PATCH master 2/2] Documentation: user: watchdog: sync with current state Ahmad Fatoum
@ 2021-05-03 10:38 ` Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2021-05-03 10:38 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox

On Mon, Apr 26, 2021 at 01:34:07PM +0200, Ahmad Fatoum wrote:
> linux_watchdog_set_timeout() does return alarm(), which can never fail
> and returns either zero or a positive value.
> 
> watchdog::set_timeout on the other hand should return either 0 or
> a negative number on error.
> 
> Ignore linux_watchdog_set_timeout()'s return value, so
> watchdog_set_timeout propagates the correct value.
> 
> This fixes an issue where seconds_to_expire wasn't updated on
> subsequent pings of this watchdog.
> 
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
>  arch/sandbox/board/watchdog.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

Applied, thanks

Sascha

> 
> diff --git a/arch/sandbox/board/watchdog.c b/arch/sandbox/board/watchdog.c
> index 336451282fd3..e1cff7a0bf0b 100644
> --- a/arch/sandbox/board/watchdog.c
> +++ b/arch/sandbox/board/watchdog.c
> @@ -29,7 +29,8 @@ static int sandbox_watchdog_set_timeout(struct watchdog *wdd, unsigned int timeo
>  	if (timeout > wdd->timeout_max)
>  		return -EINVAL;
>  
> -	return linux_watchdog_set_timeout(timeout);
> +	linux_watchdog_set_timeout(timeout);
> +	return 0;
>  }
>  
>  static int sandbox_watchdog_probe(struct device_d *dev)
> -- 
> 2.29.2
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


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

end of thread, other threads:[~2021-05-03 10:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-26 11:34 [PATCH master 1/2] sandbox: watchdog: don't return positive values from set_timeout Ahmad Fatoum
2021-04-26 11:34 ` [PATCH master 2/2] Documentation: user: watchdog: sync with current state Ahmad Fatoum
2021-05-03 10:38 ` [PATCH master 1/2] sandbox: watchdog: don't return positive values from set_timeout Sascha Hauer

mail archive of the barebox mailing list

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://lore.barebox.org/barebox/0 barebox/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 barebox barebox/ https://lore.barebox.org/barebox \
		barebox@lists.infradead.org
	public-inbox-index barebox

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git