All of lore.kernel.org
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Tero Kristo <t-kristo@ti.com>,
	wim@linux-watchdog.org, linux-watchdog@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, jan.kiszka@siemens.com
Subject: Re: [PATCHv2 2/5] watchdog: add support for adjusting last known HW keepalive time
Date: Sun, 5 Jul 2020 07:58:02 -0700	[thread overview]
Message-ID: <faeebfbb-cb8c-e31e-50ef-af42e1b11e0e@roeck-us.net> (raw)
In-Reply-To: <20200703120406.7092-3-t-kristo@ti.com>

On 7/3/20 5:04 AM, Tero Kristo wrote:
> Certain watchdogs require the watchdog only to be pinged within a
> specific time window, pinging too early or too late cause the watchdog
> to fire. In cases where this sort of watchdog has been started before
> kernel comes up, we must adjust the watchdog keepalive window to match
> the actually running timer, so add a new driver API for this purpose.
> 
> Signed-off-by: Tero Kristo <t-kristo@ti.com>
> ---
>  drivers/watchdog/watchdog_dev.c | 23 +++++++++++++++++++++++
>  include/linux/watchdog.h        |  2 ++
>  2 files changed, 25 insertions(+)
> 
> diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c
> index bc1cfa288553..5848551cf29d 100644
> --- a/drivers/watchdog/watchdog_dev.c
> +++ b/drivers/watchdog/watchdog_dev.c
> @@ -1138,6 +1138,29 @@ void watchdog_dev_unregister(struct watchdog_device *wdd)
>  	watchdog_cdev_unregister(wdd);
>  }
>  
> +/*
> + *	watchdog_set_last_hw_keepalive: set last HW keepalive time for watchdog
> + *
> + *	Adjusts the last known HW keepalive time for a watchdog timer.
> + *	This is needed in case where watchdog has been started before
> + *	kernel by someone like bootloader, and it can't be pinged

... needed if the watchdog is already running when the probe function
is called, and ...

> + *	immediately. This adjusts the watchdog ping period to match
> + *	the currently running timer.

It doesn't adjust the ping period.

> + */

last_ping_ms needs to be documented (the last heartbeat was last_ping_ms
milliseconds ago ?), both here and in Documentation/watchdog/watchdog-kernel-api.rst.
It needs to be documented that the function must be called immediately
after watchdog registration, and that min_hw_heartbeat_ms must
be set for it to be useful.

> +int watchdog_set_last_hw_keepalive(struct watchdog_device *wdd,
> +				   unsigned int last_ping_ms)
> +{
> +	struct watchdog_core_data *wd_data = wdd->wd_data;

This needs a NULL check, in case it is called before watchdog driver
registration.

> +	ktime_t now;
> +
> +	now = ktime_get();
> +
> +	wd_data->last_hw_keepalive = ktime_sub(now, ms_to_ktime(last_ping_ms));
> +
> +	return __watchdog_ping(wdd);
> +}
> +EXPORT_SYMBOL_GPL(watchdog_set_last_hw_keepalive);
> +
>  /*
>   *	watchdog_dev_init: init dev part of watchdog core
>   *
> diff --git a/include/linux/watchdog.h b/include/linux/watchdog.h
> index 1464ce6ffa31..9b19e6bb68b5 100644
> --- a/include/linux/watchdog.h
> +++ b/include/linux/watchdog.h
> @@ -210,6 +210,8 @@ extern int watchdog_init_timeout(struct watchdog_device *wdd,
>  extern int watchdog_register_device(struct watchdog_device *);
>  extern void watchdog_unregister_device(struct watchdog_device *);
>  
> +int watchdog_set_last_hw_keepalive(struct watchdog_device *, unsigned int);
> +
>  /* devres register variant */
>  int devm_watchdog_register_device(struct device *dev, struct watchdog_device *);
>  
> 


  reply	other threads:[~2020-07-05 14:58 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-03 12:04 [PATCHv2] watchdog: rti-wdt: support attaching to running wdt Tero Kristo
2020-07-03 12:04 ` [PATCHv2 1/5] watchdog: use __watchdog_ping in startup Tero Kristo
2020-07-03 12:04 ` [PATCHv2 2/5] watchdog: add support for adjusting last known HW keepalive time Tero Kristo
2020-07-05 14:58   ` Guenter Roeck [this message]
2020-07-13 12:45     ` Tero Kristo
2020-07-03 12:04 ` [PATCHv2 3/5] watchdog: rti-wdt: add support for window size configuration Tero Kristo
2020-07-05 14:49   ` Guenter Roeck
2020-07-13 12:51     ` Tero Kristo
2020-07-03 12:04 ` [PATCHv2 4/5] watchdog: rti-wdt: attach to running watchdog during probe Tero Kristo
2020-07-05 15:07   ` Guenter Roeck
2020-07-13 12:55     ` Tero Kristo
2020-07-03 12:04 ` [PATCHv2 5/5] watchdog: rti-wdt: balance pm runtime enable calls Tero Kristo
2020-07-05 15:08   ` 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=faeebfbb-cb8c-e31e-50ef-af42e1b11e0e@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=jan.kiszka@siemens.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=t-kristo@ti.com \
    --cc=wim@linux-watchdog.org \
    /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 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.