watchdog: rti-wdt: Provide set_timeout handler to make existing userspace happy
RFC PATCH 1/1 watchdog: rti-wdt: Provide set_timeout handler to make existing userspace happy
From: Jan Kiszka <[email protected]>
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.
---
See also https://github.com/systemd/systemd/issues/20683
drivers/watchdog/rti_wdt.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
drivers/watchdog/rti_wdt.c +16 -1
@@ -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, };
Signature · 1 line
2.31.1
Guenter Roeck
maintainerQuoted 9 lines · Jan Kiszka
From: Jan Kiszka <[email protected]>
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 deviatingset_timeoutis requested.Signed-off-by Jan Kiszka <[email protected]>
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
Quoted 49 lines
---
See also https://github.com/systemd/systemd/issues/20683
drivers/watchdog/rti_wdt.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)drivers/watchdog/rti_wdt.c +16
-1@@ -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, };
Hello Jan,
Quoted 9 lines · Jan Kiszka
From: Jan Kiszka <[email protected]>
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 deviatingset_timeoutis requested.Signed-off-by Jan Kiszka <[email protected]>
Are you aware of this patch https://lore.kernel.org/all/[email protected]/ ?
Francesco
Quoted 11 lines · Francesco Dolcini
Hello Jan,
Quoted 8 lines · Jan Kiszka
From: Jan Kiszka <[email protected]>
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 deviatingset_timeoutis requested.
Quoted 4 lines
Quoted 1 line
Signed-off-by Jan Kiszka <[email protected]>Are you aware of this patch https://lore.kernel.org/all/[email protected]/ ?
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
Signature · 2 lines
Siemens AG, Technology Linux Expert Center
Il 22 aprile 2024 07:35:52 CEST, Jan Kiszka <[email protected]> ha scritto:
Quoted 10 lines · Francesco Dolcini
Quoted 9 lines · Jan Kiszka
Quoted 8 lines
From: Jan Kiszka <[email protected]>
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 deviatingset_timeoutis requested.
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by Jan Kiszka <[email protected]>Are you aware of this patch https://lore.kernel.org/all/[email protected]/ ?
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
Il 22 aprile 2024 10:20:07 CEST, Francesco Dolcini <[email protected]> ha scritto:
Quoted 15 lines
Il 22 aprile 2024 07:35:52 CEST, Jan Kiszka <[email protected]> ha scritto:
Quoted 12 lines · Francesco Dolcini
Quoted 11 lines · Jan Kiszka
Quoted 9 lines
From: Jan Kiszka <[email protected]>
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 deviatingset_timeoutis requested.Signed-off-by Jan Kiszka <[email protected]>
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
Are you aware of this patch https://lore.kernel.org/all/[email protected]/ ?
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
Quoted 9 lines · Jan Kiszka
From: Jan Kiszka <[email protected]>
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 deviatingset_timeoutis requested.Signed-off-by Jan Kiszka <[email protected]>
NACK.
This will need to be fixed in systemd. set_timeout is and will remain optional.
Guenter
Quoted 50 lines
---
See also https://github.com/systemd/systemd/issues/20683
drivers/watchdog/rti_wdt.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)drivers/watchdog/rti_wdt.c +16
-1@@ -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, };Signature · 1 line
2.31.1
Quoted 9 lines · Guenter Roeck
Quoted 8 lines · Jan Kiszka
From: Jan Kiszka <[email protected]>
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 deviatingset_timeoutis requested.
Quoted 6 lines
Quoted 1 line
Signed-off-by Jan Kiszka <[email protected]>NACK.
This will need to be fixed in systemd.
set_timeoutis and will remain optional.
Err, this patch was sent in 2021, and even systemd is long fixed (since v250).
Jan
Signature · 2 lines
Siemens AG, Technology Linux Expert Center