linux-watchdog.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Jan Kiszka <jan.kiszka@siemens.com>,
	Wim Van Sebroeck <wim@linux-watchdog.org>
Cc: linux-watchdog@vger.kernel.org,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Tero Kristo <t-kristo@ti.com>,
	"Su, Bao Cheng (RC-CN DF FA R&D)" <baocheng.su@siemens.com>
Subject: Re: [RFC][PATCH] watchdog: rti-wdt: Provide set_timeout handler to make existing userspace happy
Date: Mon, 13 Sep 2021 07:37:02 -0700	[thread overview]
Message-ID: <a454fd16-b49d-b803-6bcd-c245e059d3d8@roeck-us.net> (raw)
In-Reply-To: <4d82b8ce-bc34-e4b2-c5fe-9e883b0db59d@siemens.com>

On 9/13/21 4:41 AM, Jan Kiszka wrote:
> From: Jan Kiszka <jan.kiszka@siemens.com>
> 
> Prominent userspace - systemd - cannot handle watchdogs without
> WDIOF_SETTIMEOUT, even if it was configured to the same time as the
> driver selected or was used by firmware to start the watchdog. To avoid
> failing in this case, implement a handler that only fails if a deviating
> set_timeout is requested.
> 
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>

NACK. This is a userspace problem. The ABI clearly states that
WDIOF_SETTIMEOUT is optional, and userspace must not depend on it.
We can not start making kernel changes just to make broken userspace
code happy. systemd should be fixed instead.

Guenter

> ---
> 
> See also https://github.com/systemd/systemd/issues/20683
> 
>   drivers/watchdog/rti_wdt.c | 17 ++++++++++++++++-
>   1 file changed, 16 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/watchdog/rti_wdt.c b/drivers/watchdog/rti_wdt.c
> index 359302f71f7e..365255b15a0d 100644
> --- a/drivers/watchdog/rti_wdt.c
> +++ b/drivers/watchdog/rti_wdt.c
> @@ -173,13 +173,27 @@ static unsigned int rti_wdt_get_timeleft_ms(struct watchdog_device *wdd)
>   	return timer_counter;
>   }
>   
> +static int rti_wdt_set_timeout(struct watchdog_device *wdd,
> +			       unsigned int timeout)
> +{
> +	/*
> +	 * Updating the timeout after start is actually not supported, but
> +	 * let's ignore requests for the already configured value. Helps
> +	 * existing userspace such as systemd.
> +	 */
> +	if (timeout != heartbeat)
> +		return -EOPNOTSUPP;
> +
> +	return 0;
> +}
> +
>   static unsigned int rti_wdt_get_timeleft(struct watchdog_device *wdd)
>   {
>   	return rti_wdt_get_timeleft_ms(wdd) / 1000;
>   }
>   
>   static const struct watchdog_info rti_wdt_info = {
> -	.options = WDIOF_KEEPALIVEPING,
> +	.options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT,
>   	.identity = "K3 RTI Watchdog",
>   };
>   
> @@ -187,6 +201,7 @@ static const struct watchdog_ops rti_wdt_ops = {
>   	.owner		= THIS_MODULE,
>   	.start		= rti_wdt_start,
>   	.ping		= rti_wdt_ping,
> +	.set_timeout	= rti_wdt_set_timeout,
>   	.get_timeleft	= rti_wdt_get_timeleft,
>   };
>   
> 


      reply	other threads:[~2021-09-13 15:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-13 11:41 Jan Kiszka
2021-09-13 14:37 ` 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=a454fd16-b49d-b803-6bcd-c245e059d3d8@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=baocheng.su@siemens.com \
    --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 \
    --subject='Re: [RFC][PATCH] watchdog: rti-wdt: Provide set_timeout handler to make existing userspace happy' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).