linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC][PATCH] watchdog: rti-wdt: Provide set_timeout handler to make existing userspace happy
@ 2021-09-13 11:41 Jan Kiszka
  2021-09-13 14:37 ` Guenter Roeck
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Jan Kiszka @ 2021-09-13 11:41 UTC (permalink / raw)
  To: Wim Van Sebroeck, Guenter Roeck
  Cc: linux-watchdog, Linux Kernel Mailing List, Tero Kristo, Su,
	Bao Cheng (RC-CN DF FA R&D)

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>
---

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,
 };
 
-- 
2.31.1

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

* Re: [RFC][PATCH] watchdog: rti-wdt: Provide set_timeout handler to make existing userspace happy
  2021-09-13 11:41 [RFC][PATCH] watchdog: rti-wdt: Provide set_timeout handler to make existing userspace happy Jan Kiszka
@ 2021-09-13 14:37 ` Guenter Roeck
  2024-04-21  8:49 ` Francesco Dolcini
  2024-04-21 23:50 ` Guenter Roeck
  2 siblings, 0 replies; 8+ messages in thread
From: Guenter Roeck @ 2021-09-13 14:37 UTC (permalink / raw)
  To: Jan Kiszka, Wim Van Sebroeck
  Cc: linux-watchdog, Linux Kernel Mailing List, Tero Kristo, Su,
	Bao Cheng (RC-CN DF FA R&D)

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,
>   };
>   
> 


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

* Re: [RFC][PATCH] watchdog: rti-wdt: Provide set_timeout handler to make existing userspace happy
  2021-09-13 11:41 [RFC][PATCH] watchdog: rti-wdt: Provide set_timeout handler to make existing userspace happy Jan Kiszka
  2021-09-13 14:37 ` Guenter Roeck
@ 2024-04-21  8:49 ` Francesco Dolcini
  2024-04-22  5:35   ` Jan Kiszka
  2024-04-21 23:50 ` Guenter Roeck
  2 siblings, 1 reply; 8+ messages in thread
From: Francesco Dolcini @ 2024-04-21  8:49 UTC (permalink / raw)
  To: Jan Kiszka
  Cc: Wim Van Sebroeck, Guenter Roeck, linux-watchdog,
	Linux Kernel Mailing List, Tero Kristo, Su,
	Bao Cheng (RC-CN DF FA R&D)

Hello Jan,

On Mon, Sep 13, 2021 at 01:41:43PM +0200, 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>

Are you aware of this patch https://lore.kernel.org/all/20240417205700.3947408-1-jm@ti.com/ ?

Francesco


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

* Re: [RFC][PATCH] watchdog: rti-wdt: Provide set_timeout handler to make existing userspace happy
  2021-09-13 11:41 [RFC][PATCH] watchdog: rti-wdt: Provide set_timeout handler to make existing userspace happy Jan Kiszka
  2021-09-13 14:37 ` Guenter Roeck
  2024-04-21  8:49 ` Francesco Dolcini
@ 2024-04-21 23:50 ` Guenter Roeck
  2024-04-22  5:36   ` Jan Kiszka
  2 siblings, 1 reply; 8+ messages in thread
From: Guenter Roeck @ 2024-04-21 23:50 UTC (permalink / raw)
  To: Jan Kiszka
  Cc: Wim Van Sebroeck, linux-watchdog, Linux Kernel Mailing List,
	Tero Kristo, Su, Bao Cheng (RC-CN DF FA R&D)

On Mon, Sep 13, 2021 at 01:41:43PM +0200, 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 will need to be fixed in systemd. set_timeout is and will remain
optional.

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,
>  };
>  
> -- 
> 2.31.1

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

* Re: [RFC][PATCH] watchdog: rti-wdt: Provide set_timeout handler to make existing userspace happy
  2024-04-21  8:49 ` Francesco Dolcini
@ 2024-04-22  5:35   ` Jan Kiszka
  2024-04-22  8:20     ` Francesco Dolcini
  0 siblings, 1 reply; 8+ messages in thread
From: Jan Kiszka @ 2024-04-22  5:35 UTC (permalink / raw)
  To: Francesco Dolcini
  Cc: Wim Van Sebroeck, Guenter Roeck, linux-watchdog,
	Linux Kernel Mailing List, Tero Kristo, Su,
	Bao Cheng (RC-CN DF FA R&D)

On 21.04.24 10:49, Francesco Dolcini wrote:
> Hello Jan,
> 
> On Mon, Sep 13, 2021 at 01:41:43PM +0200, 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>
> 
> Are you aware of this patch https://lore.kernel.org/all/20240417205700.3947408-1-jm@ti.com/ ?
> 

Thanks for the heads-up, we will surely try to test things on our setups
as well. But commenting on this dead and not directly related thread may
have caused some confusion...

Jan

-- 
Siemens AG, Technology
Linux Expert Center


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

* Re: [RFC][PATCH] watchdog: rti-wdt: Provide set_timeout handler to make existing userspace happy
  2024-04-21 23:50 ` Guenter Roeck
@ 2024-04-22  5:36   ` Jan Kiszka
  0 siblings, 0 replies; 8+ messages in thread
From: Jan Kiszka @ 2024-04-22  5:36 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Wim Van Sebroeck, linux-watchdog, Linux Kernel Mailing List,
	Tero Kristo, Su, Bao Cheng (RC-CN DF FA R&D)

On 22.04.24 01:50, Guenter Roeck wrote:
> On Mon, Sep 13, 2021 at 01:41:43PM +0200, 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 will need to be fixed in systemd. set_timeout is and will remain
> optional.

Err, this patch was sent in 2021, and even systemd is long fixed (since
v250).

Jan

-- 
Siemens AG, Technology
Linux Expert Center


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

* Re: [RFC][PATCH] watchdog: rti-wdt: Provide set_timeout handler to make existing userspace happy
  2024-04-22  5:35   ` Jan Kiszka
@ 2024-04-22  8:20     ` Francesco Dolcini
  2024-04-22  8:23       ` Francesco Dolcini
  0 siblings, 1 reply; 8+ messages in thread
From: Francesco Dolcini @ 2024-04-22  8:20 UTC (permalink / raw)
  To: Jan Kiszka
  Cc: Wim Van Sebroeck, Guenter Roeck, linux-watchdog,
	Linux Kernel Mailing List, Tero Kristo, Su,
	Bao Cheng (RC-CN DF FA R&D)



Il 22 aprile 2024 07:35:52 CEST, Jan Kiszka <jan.kiszka@siemens.com> ha scritto:
>On 21.04.24 10:49, Francesco Dolcini wrote:
>> On Mon, Sep 13, 2021 at 01:41:43PM +0200, 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>
>> 
>> Are you aware of this patch https://lore.kernel.org/all/20240417205700.3947408-1-jm@ti.com/ ?
>> 
>
>Thanks for the heads-up, we will surely try to test things on our setups
>as well. But commenting on this dead and not directly related thread may
>have caused some confusion...

I was too terse.

We have working systemd watchdog with that patch applied, this is the reason I mentioned it here, it might also solve your issue.

Francesco



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

* Re: [RFC][PATCH] watchdog: rti-wdt: Provide set_timeout handler to make existing userspace happy
  2024-04-22  8:20     ` Francesco Dolcini
@ 2024-04-22  8:23       ` Francesco Dolcini
  0 siblings, 0 replies; 8+ messages in thread
From: Francesco Dolcini @ 2024-04-22  8:23 UTC (permalink / raw)
  To: Jan Kiszka
  Cc: Wim Van Sebroeck, Guenter Roeck, linux-watchdog,
	Linux Kernel Mailing List, Tero Kristo, Su,
	Bao Cheng (RC-CN DF FA R&D)



Il 22 aprile 2024 10:20:07 CEST, Francesco Dolcini <francesco@dolcini.it> ha scritto:
>
>
>Il 22 aprile 2024 07:35:52 CEST, Jan Kiszka <jan.kiszka@siemens.com> ha scritto:
>>On 21.04.24 10:49, Francesco Dolcini wrote:
>>> On Mon, Sep 13, 2021 at 01:41:43PM +0200, 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>
>>> 
>>> Are you aware of this patch https://lore.kernel.org/all/20240417205700.3947408-1-jm@ti.com/ ?
>>> 
>>
>>Thanks for the heads-up, we will surely try to test things on our setups
>>as well. But commenting on this dead and not directly related thread may
>>have caused some confusion...
>
>I was too terse.

And I did not realize your patch was from 2021. Sorry for the confusion.


Francesco 

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

end of thread, other threads:[~2024-04-22  8:23 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-13 11:41 [RFC][PATCH] watchdog: rti-wdt: Provide set_timeout handler to make existing userspace happy Jan Kiszka
2021-09-13 14:37 ` Guenter Roeck
2024-04-21  8:49 ` Francesco Dolcini
2024-04-22  5:35   ` Jan Kiszka
2024-04-22  8:20     ` Francesco Dolcini
2024-04-22  8:23       ` Francesco Dolcini
2024-04-21 23:50 ` Guenter Roeck
2024-04-22  5:36   ` Jan Kiszka

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).