watchdog: sbsa_wdog: Make sure the timeout programming is within the limits
PATCH v2 1/1 watchdog: sbsa_wdog: Make sure the timeout programming is within the limits
Make sure to honour the max_hw_heartbeat_ms while programming the timeout value to WOR. Clamp the timeout passed to sbsa_gwdt_set_timeout() to make sure the programmed value is within the permissible range.
--- drivers/watchdog/sbsa_gwdt.c | 1 + 1 file changed, 1 insertion(+)
drivers/watchdog/sbsa_gwdt.c +1 -0
@@ -149,6 +149,7 @@ static int sbsa_gwdt_set_timeout(struct watchdog_device *wdd, {struct sbsa_gwdt *gwdt =watchdog_get_drvdata (wdd); + timeout = clamp_t(unsigned int, timeout, 1, wdd->max_hw_heartbeat_ms / 1000); wdd->timeout = timeout;if (action)
Signature · 1 line
2.34.1
Guenter Roeck
maintainerQuoted 16 lines · George Cherian
Make sure to honour the
max_hw_heartbeat_mswhile programming the timeout value to WOR. Clamp the timeout passed tosbsa_gwdt_set_timeout()to make sure the programmed value is within the permissible range.Fixes abd3ac7902fb ("watchdog: sbsa: Support architecture version 1")Signed-off-by George Cherian <[email protected]>--- drivers/watchdog/sbsa_gwdt.c | 1 + 1 file changed, 1 insertion(+)drivers/watchdog/sbsa_gwdt.c +0
-0
drivers/watchdog/sbsa_gwdt.c static int sbsa_gwdt_set_timeout(struct watchdog_device *wdd, · line 154
Quoted 6 lines
drivers/watchdog/sbsa_gwdt.c +1
-0@@ -149,6 +149,7 @@ static int sbsa_gwdt_set_timeout(struct watchdog_device *wdd, {struct sbsa_gwdt *gwdt =watchdog_get_drvdata (wdd); + timeout = clamp_t(unsigned int, timeout, 1, wdd->max_hw_heartbeat_ms / 1000); wdd->timeout = timeout;
Wrong order. wdd->timeout should still contain the requested timeout.
Guenter
Quoted 36 lines
-----Original Message-----
From: Guenter Roeck <[email protected]> On Behalf Of Guenter Roeck
Sent: Wednesday, February 8, 2023 8:41 PM
To: George Cherian <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; [email protected]
Subject: Re: [PATCH v2] watchdog:sbsa_wdog: Make sure the timeout programming is within the limits----------------------------------------------------------------------
Quoted 3 lines · George Cherian
Make sure to honour the
max_hw_heartbeat_mswhile programming the timeout value to WOR. Clamp the timeout passed tosbsa_gwdt_set_timeout()to make sure the programmed value is withinthe permissible range.
Quoted 10 lines
Fixes abd3ac7902fb ("watchdog: sbsa: Support architecture version 1")Signed-off-by George Cherian <[email protected]>--- drivers/watchdog/sbsa_gwdt.c | 1 + 1 file changed, 1 insertion(+)(quoted diff) +0
-0
b/drivers/watchdog/sbsa_gwdt.cindex9791c74aebd4..ee1039a652f1100644
drivers/watchdog/sbsa_gwdt.c static int sbsa_gwdt_set_timeout(struct
Quoted 3 lines
drivers/watchdog/sbsa_gwdt.c +0
-0@@ -149,6 +149,7 @@ static int sbsa_gwdt_set_timeout(struct
watchdog_device*wdd,Quoted 3 lines
drivers/watchdog/sbsa_gwdt.c +0
-0{struct sbsa_gwdt *gwdt =watchdog_get_drvdata (wdd);
Quoted 7 lines
Quoted 5 lines
drivers/watchdog/sbsa_gwdt.c +1
-0+ timeout = clamp_t(unsigned int, timeout, 1, wdd-
max_hw_heartbeat_ms
+/ 1000);
wdd->timeout= timeout;Wrong order.
wdd->timeoutshould still contain the requested timeout.
But then the requested timeout is not being set in HW. Isn't that a disconnect?
Quoted 2 lines
Guenter
Guenter Roeck
maintainerQuoted 43 lines · George Cherian
Quoted 36 lines
-----Original Message-----
From: Guenter Roeck <[email protected]> On Behalf Of Guenter Roeck
Sent: Wednesday, February 8, 2023 8:41 PM
To: George Cherian <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; [email protected]
Subject: Re: [PATCH v2] watchdog:sbsa_wdog: Make sure the timeout programming is within the limits----------------------------------------------------------------------
Quoted 3 lines · George Cherian
Make sure to honour the
max_hw_heartbeat_mswhile programming the timeout value to WOR. Clamp the timeout passed tosbsa_gwdt_set_timeout()to make sure the programmed value is withinthe permissible range.
Quoted 10 lines
Fixes abd3ac7902fb ("watchdog: sbsa: Support architecture version 1")Signed-off-by George Cherian <[email protected]>--- drivers/watchdog/sbsa_gwdt.c | 1 + 1 file changed, 1 insertion(+)(quoted diff) +0
-0
b/drivers/watchdog/sbsa_gwdt.cindex9791c74aebd4..ee1039a652f1100644
drivers/watchdog/sbsa_gwdt.c static int sbsa_gwdt_set_timeout(struct
Quoted 3 lines
drivers/watchdog/sbsa_gwdt.c +0
-0@@ -149,6 +149,7 @@ static int sbsa_gwdt_set_timeout(struct
watchdog_device*wdd,Quoted 3 lines
drivers/watchdog/sbsa_gwdt.c +0
-0{struct sbsa_gwdt *gwdt =watchdog_get_drvdata (wdd);Quoted 7 lines
Quoted 5 lines
drivers/watchdog/sbsa_gwdt.c +1
-0+ timeout = clamp_t(unsigned int, timeout, 1, wdd-
max_hw_heartbeat_ms
+/ 1000);
wdd->timeout= timeout;Wrong order.
wdd->timeoutshould still contain the requested timeout.
Quoted 2 lines
But then the requested timeout is not being set in HW. Isn't that a disconnect?
No. The driver is supposed to set a timeout no larger than max_hw_heartbeat_ms. The watchdog core then takes care of differences between ->timeout (as seen by the user) and max_hw_heartbeat_ms and pings the watchdog as needed.
Guenter
Quoted 60 lines
-----Original Message-----
From: Guenter Roeck <[email protected]> On Behalf Of Guenter Roeck
Sent: Wednesday, February 8, 2023 11:26 PM
To: George Cherian <[email protected]>
Cc: [email protected]; [email protected]; linux- [email protected]; [email protected]
Subject: Re: [PATCH v2] watchdog:sbsa_wdog: Make sure the timeout programming is within the limits----------------------------------------------------------------------
Quoted 4 lines · George Cherian
Quoted 4 lines
-----Original Message-----
From: Guenter Roeck <[email protected]> On Behalf Of GuenterRoeck
Quoted 11 lines
Quoted 11 lines
Sent: Wednesday, February 8, 2023 8:41 PM
To: George Cherian <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; [email protected]
Subject: Re: [PATCH v2] watchdog:sbsa_wdog: Make sure the timeout programming is within the limits--------------------------------------------------------------------
Quoted 1 line · George Cherian
Make sure to honour the
max_hw_heartbeat_mswhile programmingthe
Quoted 30 lines
Quoted 30 lines
Quoted 3 lines
timeout value to WOR. Clamp the timeout passed to
sbsa_gwdt_set_timeout()to make sure the programmed value is withinthe permissible range.
Quoted 11 lines
Fixes abd3ac7902fb ("watchdog: sbsa: Support architecture version1")
Signed-off-by George Cherian <[email protected]>--- drivers/watchdog/sbsa_gwdt.c | 1 + 1 file changed, 1 insertion(+)(quoted diff) +0
-0
b/drivers/watchdog/sbsa_gwdt.cindex9791c74aebd4..ee1039a652f1100644
drivers/watchdog/sbsa_gwdt.c static int sbsa_gwdt_set_timeout(struct
Quoted 3 lines
drivers/watchdog/sbsa_gwdt.c +0
-0@@ -149,6 +149,7 @@ static int sbsa_gwdt_set_timeout(struct
watchdog_device*wdd,Quoted 8 lines
drivers/watchdog/sbsa_gwdt.c +1
-0{struct sbsa_gwdt *gwdt =watchdog_get_drvdata (wdd); + timeout = clamp_t(unsigned int, timeout, 1, wdd-
max_hw_heartbeat_ms
+/ 1000);
wdd->timeout= timeout;Wrong order.
wdd->timeoutshould still contain the requested timeout.
Quoted 7 lines
Quoted 2 lines
But then the requested timeout is not being set in HW. Isn't that a disconnect?
No. The driver is supposed to set a timeout no larger than
max_hw_heartbeat_ms. The watchdog core then takes care of differences between ->timeout (as seen by the user) andmax_hw_heartbeat_msand pings the watchdog as needed.
Thanks for the explanation. Will post v3.
-George
Quoted 2 lines
Guenter