watchdog: qcom_wdt: set WDOG_HW_RUNNING bit when appropriate
Subsystems (2)
PATCH v4 1/1 watchdog: qcom_wdt: set WDOG_HW_RUNNING bit when appropriate
If the watchdog hardware is enabled/running during boot, e.g. due to a boot loader configuring it, we must tell the watchdog framework about this fact so that it can ping the watchdog until userspace opens the device and takes over control.
Do so using the WDOG_HW_RUNNING flag that exists for exactly that use-case.
---
Changes in v4:
* Use QCOM_WDT_ENABLE macro
Changes in v3:
* Drop call to stop as start already does it
* Update commit message
Changes in v2:
* Correct authorship
drivers/watchdog/qcom-wdt.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
drivers/watchdog/qcom-wdt.c +18 -0
@@ -152,6 +152,13 @@ static int qcom_wdt_restart(struct watchdog_device *wdd, unsigned long action,return 0 ; } +static int qcom_wdt_is_running (struct watchdog_device *wdd) +{ +struct qcom_wdt *wdt =to_qcom_wdt (wdd); + +return (readl (wdt_addr (wdt,WDT_EN )) &QCOM_WDT_ENABLE ); +} +static const struct watchdog_ops qcom_wdt_ops = { .start = qcom_wdt_start, .stop = qcom_wdt_stop,
@@ -294,6 +301,17 @@ static int qcom_wdt_probe(struct platform_device *pdev) wdt->wdd.timeout =min (wdt->wdd.max_timeout,30U );watchdog_init_timeout (&wdt->wdd,0 , dev); +/* +* If WDT is already running, call WDT start which +* will stop the WDT, set timeouts as bootloader +* might use different ones and set running bit +* to inform the WDT subsystem to ping the WDT +*/ +if (qcom_wdt_is_running (&wdt->wdd)) { +qcom_wdt_start (&wdt->wdd); +set_bit (WDOG_HW_RUNNING , &wdt->wdd.status); + } + ret =devm_watchdog_register_device (dev, &wdt->wdd);if (ret)return ret;
Signature · 1 line
2.28.0
Quoted 10 lines · Robert Marko
If the watchdog hardware is enabled/running during boot, e.g. due to a boot loader configuring it, we must tell the watchdog framework about this fact so that it can ping the watchdog until userspace opens the device and takes over control.
Do so using the
WDOG_HW_RUNNINGflag that exists for exactly that use-case.Signed-off-by Robert Marko <[email protected]>
Quoted 52 lines
Cc Luka Perkov <[email protected]>---
Changes in v4:
* UseQCOM_WDT_ENABLEmacroChanges in v3:
* Drop call to stop as start already does it
* Update commit messageChanges in v2:
* Correct authorshipdrivers/watchdog/qcom-wdt.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)drivers/watchdog/qcom-wdt.c +18
-0@@ -152,6 +152,13 @@ static int qcom_wdt_restart(struct watchdog_device *wdd, unsigned long action,return 0 ; } +static int qcom_wdt_is_running (struct watchdog_device *wdd) +{ +struct qcom_wdt *wdt =to_qcom_wdt (wdd); + +return (readl (wdt_addr (wdt,WDT_EN )) &QCOM_WDT_ENABLE ); +} +static const struct watchdog_ops qcom_wdt_ops = { .start = qcom_wdt_start, .stop = qcom_wdt_stop,@@ -294,6 +301,17 @@ static int qcom_wdt_probe(struct platform_device *pdev) wdt->wdd.timeout =min (wdt->wdd.max_timeout,30U );watchdog_init_timeout (&wdt->wdd,0 , dev); +/* +* If WDT is already running, call WDT start which +* will stop the WDT, set timeouts as bootloader +* might use different ones and set running bit +* to inform the WDT subsystem to ping the WDT +*/ +if (qcom_wdt_is_running (&wdt->wdd)) { +qcom_wdt_start (&wdt->wdd); +set_bit (WDOG_HW_RUNNING , &wdt->wdd.status); + } + ret =devm_watchdog_register_device (dev, &wdt->wdd);if (ret)return ret;
Quoted 7 lines · Guenter Roeck
Quoted 6 lines · Robert Marko
If the watchdog hardware is enabled/running during boot, e.g. due to a boot loader configuring it, we must tell the watchdog framework about this fact so that it can ping the watchdog until userspace opens the device and takes over control.
Quoted 5 lines
Quoted 4 lines
Do so using the
WDOG_HW_RUNNINGflag that exists for exactly that use-case.Signed-off-by Robert Marko <[email protected]>Reviewed-by Guenter Roeck <[email protected]>
Thanks for addressing the comments and now the patch looks good to me. One more suggestion, can we make the initcall level of the driver to subsys_initcall_sync so that the driver gets registered immediately after the watchdog_core is registered and watchdog_core starts pinging the WDT?
Quoted 52 lines
Quoted 52 lines
Cc Luka Perkov <[email protected]>---
Changes in v4:
* UseQCOM_WDT_ENABLEmacroChanges in v3:
* Drop call to stop as start already does it
* Update commit messageChanges in v2:
* Correct authorshipdrivers/watchdog/qcom-wdt.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)drivers/watchdog/qcom-wdt.c +18
-0@@ -152,6 +152,13 @@ static int qcom_wdt_restart(struct watchdog_device *wdd, unsigned long action,return 0 ; } +static int qcom_wdt_is_running (struct watchdog_device *wdd) +{ +struct qcom_wdt *wdt =to_qcom_wdt (wdd); + +return (readl (wdt_addr (wdt,WDT_EN )) &QCOM_WDT_ENABLE ); +} +static const struct watchdog_ops qcom_wdt_ops = { .start = qcom_wdt_start, .stop = qcom_wdt_stop,@@ -294,6 +301,17 @@ static int qcom_wdt_probe(struct platform_device *pdev) wdt->wdd.timeout =min (wdt->wdd.max_timeout,30U );watchdog_init_timeout (&wdt->wdd,0 , dev); +/* +* If WDT is already running, call WDT start which +* will stop the WDT, set timeouts as bootloader +* might use different ones and set running bit +* to inform the WDT subsystem to ping the WDT +*/ +if (qcom_wdt_is_running (&wdt->wdd)) { +qcom_wdt_start (&wdt->wdd); +set_bit (WDOG_HW_RUNNING , &wdt->wdd.status); + } + ret =devm_watchdog_register_device (dev, &wdt->wdd);if (ret)return ret;
Signature · 1 line
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
Guenter Roeck
maintainerQuoted 9 lines · Kathiravan T
Quoted 7 lines · Guenter Roeck
Quoted 6 lines · Robert Marko
If the watchdog hardware is enabled/running during boot, e.g. due to a boot loader configuring it, we must tell the watchdog framework about this fact so that it can ping the watchdog until userspace opens the device and takes over control.
Quoted 8 lines
Quoted 5 lines
Quoted 4 lines
Do so using the
WDOG_HW_RUNNINGflag that exists for exactly that use-case.Signed-off-by Robert Marko <[email protected]>Reviewed-by Guenter Roeck <[email protected]>Thanks for addressing the comments and now the patch looks good to me. One more suggestion, can we make the initcall level of the driver to
subsys_initcall_syncso that the driver gets registered immediately after thewatchdog_coreis registered andwatchdog_corestarts pinging the WDT?
That would mean to replace module_platform_driver(), which would be a whole different discussion, is not widely needed, and would potentially interfere with the subsys_initcall_sync() in the watchdog core. This will require specific evidence that a problem is seen in the field, and that it is truly needed. Plus, it would have to be a different patch (which you could submit yourself, with evidence). Let's stick with one logical change per patch, please.
Guenter
Quoted 24 lines · Guenter Roeck
Quoted 8 lines · Kathiravan T
Quoted 7 lines · Guenter Roeck
Quoted 6 lines · Robert Marko
If the watchdog hardware is enabled/running during boot, e.g. due to a boot loader configuring it, we must tell the watchdog framework about this fact so that it can ping the watchdog until userspace opens the device and takes over control.
Quoted 7 lines
Quoted 5 lines
Quoted 4 lines
Do so using the
WDOG_HW_RUNNINGflag that exists for exactly that use-case.Signed-off-by Robert Marko <[email protected]>Reviewed-by Guenter Roeck <[email protected]>Thanks for addressing the comments and now the patch looks good to me. One more suggestion, can we make the initcall level of the driver to
subsys_initcall_syncso that the driver gets registered immediately after thewatchdog_coreis registered andwatchdog_corestarts pinging the WDT?That would mean to replace
module_platform_driver(), which would be a whole different discussion, is not widely needed, and would potentially interfere with thesubsys_initcall_sync()in the watchdog core. This will require specific evidence that a problem is seen in the field, and that it is truly needed. Plus, it would have to be a different patch (which you could submit yourself, with evidence). Let's stick with one logical change per patch, please.
Quoted 1 line
Guenter
Yeah, of course I don't want to squash the initcall level change with this one. Just made a suggestion to consider it. Anyway I will try to collect some data and post the patch by own on that suggestion. Thanks Guenter.
Signature · 1 line
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
Quoted 27 lines · Kathiravan T
Quoted 24 lines · Guenter Roeck
Quoted 8 lines · Kathiravan T
Quoted 7 lines · Guenter Roeck
Quoted 6 lines · Robert Marko
If the watchdog hardware is enabled/running during boot, e.g. due to a boot loader configuring it, we must tell the watchdog framework about this fact so that it can ping the watchdog until userspace opens the device and takes over control.
Quoted 7 lines
Quoted 5 lines
Quoted 4 lines
Do so using the
WDOG_HW_RUNNINGflag that exists for exactly that use-case.Signed-off-by Robert Marko <[email protected]>Reviewed-by Guenter Roeck <[email protected]>Thanks for addressing the comments and now the patch looks good to me. One more suggestion, can we make the initcall level of the driver to
subsys_initcall_syncso that the driver gets registered immediately after thewatchdog_coreis registered andwatchdog_corestarts pinging the WDT?That would mean to replace
module_platform_driver(), which would be a whole different discussion, is not widely needed, and would potentially interfere with thesubsys_initcall_sync()in the watchdog core. This will require specific evidence that a problem is seen in the field, and that it is truly needed. Plus, it would have to be a different patch (which you could submit yourself, with evidence). Let's stick with one logical change per patch, please.
Quoted 9 lines
Quoted 1 line
Guenter
Yeah, of course I don't want to squash the initcall level change with this one. Just made a suggestion to consider it. Anyway I will try to collect some data and post the patch by own on that suggestion. Thanks Guenter.
--
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
Any chance this could be picked for 5.11?
I have some boards depending on it for normal boot.
Regards,
Robert
Guenter Roeck
maintainerQuoted 34 lines · Robert Marko
Quoted 33 lines · Kathiravan T
Quoted 24 lines · Guenter Roeck
Quoted 8 lines · Kathiravan T
Quoted 7 lines · Guenter Roeck
Quoted 6 lines · Robert Marko
If the watchdog hardware is enabled/running during boot, e.g. due to a boot loader configuring it, we must tell the watchdog framework about this fact so that it can ping the watchdog until userspace opens the device and takes over control.
Quoted 7 lines
Quoted 5 lines
Quoted 4 lines
Do so using the
WDOG_HW_RUNNINGflag that exists for exactly that use-case.Signed-off-by Robert Marko <[email protected]>Reviewed-by Guenter Roeck <[email protected]>Thanks for addressing the comments and now the patch looks good to me. One more suggestion, can we make the initcall level of the driver to
subsys_initcall_syncso that the driver gets registered immediately after thewatchdog_coreis registered andwatchdog_corestarts pinging the WDT?That would mean to replace
module_platform_driver(), which would be a whole different discussion, is not widely needed, and would potentially interfere with thesubsys_initcall_sync()in the watchdog core. This will require specific evidence that a problem is seen in the field, and that it is truly needed. Plus, it would have to be a different patch (which you could submit yourself, with evidence). Let's stick with one logical change per patch, please.Quoted 1 line
Guenter
Yeah, of course I don't want to squash the initcall level change with this one. Just made a suggestion to consider it. Anyway I will try to collect some data and post the patch by own on that suggestion. Thanks Guenter.
Quoted 7 lines
Quoted 3 lines
--
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux FoundationAny chance this could be picked for 5.11?
I have some boards depending on it for normal boot.
It is queued in my watchdog-next branch, so Wim will most likely pick it up.
Guenter
Quoted 11 lines · Robert Marko
If the watchdog hardware is enabled/running during boot, e.g. due to a boot loader configuring it, we must tell the watchdog framework about this fact so that it can ping the watchdog until userspace opens the device and takes over control.
Do so using the
WDOG_HW_RUNNINGflag that exists for exactly that use-case.Signed-off-by Robert Marko <[email protected]>Cc Luka Perkov <[email protected]>
Quoted 19 lines
---
Changes in v4:
* UseQCOM_WDT_ENABLEmacroChanges in v3:
* Drop call to stop as start already does it
* Update commit messageChanges in v2:
* Correct authorshipdrivers/watchdog/qcom-wdt.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)drivers/watchdog/qcom-wdt.c +0
-0
drivers/watchdog/qcom-wdt.c static int qcom_wdt_restart(struct watchdog_device *wdd, unsigned long action, · line 159
Quoted 8 lines
drivers/watchdog/qcom-wdt.c +5
-0@@ -152,6 +152,13 @@ static int qcom_wdt_restart(struct watchdog_device *wdd, unsigned long action,return 0 ; } +static int qcom_wdt_is_running (struct watchdog_device *wdd) +{ +struct qcom_wdt *wdt =to_qcom_wdt (wdd); + +return (readl (wdt_addr (wdt,WDT_EN )) &QCOM_WDT_ENABLE );
Although, you don't need the outer () here.
Regards,
Bjorn
Quoted 26 lines
drivers/watchdog/qcom-wdt.c +13
-0+} +static const struct watchdog_ops qcom_wdt_ops = { .start = qcom_wdt_start, .stop = qcom_wdt_stop,@@ -294,6 +301,17 @@ static int qcom_wdt_probe(struct platform_device *pdev) wdt->wdd.timeout =min (wdt->wdd.max_timeout,30U );watchdog_init_timeout (&wdt->wdd,0 , dev); +/* +* If WDT is already running, call WDT start which +* will stop the WDT, set timeouts as bootloader +* might use different ones and set running bit +* to inform the WDT subsystem to ping the WDT +*/ +if (qcom_wdt_is_running (&wdt->wdd)) { +qcom_wdt_start (&wdt->wdd); +set_bit (WDOG_HW_RUNNING , &wdt->wdd.status); + } + ret =devm_watchdog_register_device (dev, &wdt->wdd);if (ret)return ret;Signature · 1 line
2.28.0
This patch was applied to qcom/linux.git (refs/heads/for-next):
Hello:
This patch was applied to qcom/linux.git (refs/heads/for-next):
Quoted 10 lines · On Sat, 31 Oct 2020 13:11:15 +0100 you wrote:
If the watchdog hardware is enabled/running during boot, e.g. due to a boot loader configuring it, we must tell the watchdog framework about this fact so that it can ping the watchdog until userspace opens the device and takes over control.
Do so using the
WDOG_HW_RUNNINGflag that exists for exactly that use-case.[...]
Here is the summary with links:
- [v4] watchdog: qcom_wdt: set WDOG_HW_RUNNING bit when appropriate
https://git.kernel.org/qcom/c/8650d0f9e933
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html