GPIO WDT "start-at-boot" property
Subsystems (2)
cover GPIO WDT "start-at-boot" property
I propose to add a new property to GPIO WDT device tree binding "start-at-boot".
If this property is present, start pinging hw watchdog at probe, in order to take advantage of kernel configs:
- WATCHDOG_HANDLE_BOOT_ENABLED: Avoid possible reboot if hw watchdog was been enabled before the kernel (by uboot for example) and userspace doesn't take control of /dev/watchdog in time;
- WATCHDOG_OPEN_TIMEOUT: Reboot if userspace doesn't take control of /dev/watchdog within the timeout.
Francesco Zanella (2):
dt-bindings: watchdog: gpio-wdt: add "start-at-boot"
watchdog: gpio_wdt: add "start-at-boot" feature
Documentation/devicetree/bindings/watchdog/gpio-wdt.txt | 7 +++++++ drivers/watchdog/gpio_wdt.c | 6 +++++- 2 files changed, 12 insertions(+), 1 deletion(-)
Signature · 1 line
2.17.1
PATCH 1/2 dt-bindings: watchdog: gpio-wdt: add "start-at-boot"
Documentation for new device tree property "start-at-boot".
--- Documentation/devicetree/bindings/watchdog/gpio-wdt.txt | 7 +++++++ 1 file changed, 7 insertions(+)
Documentation/devicetree/bindings/watchdog/gpio-wdt.txt +7 -0
@@ -17,6 +17,13 @@ Optional Properties: - always-running: If the watchdog timer cannot be disabled, add this flag to have the driver keep toggling the signal without a client. It will only cease to toggle the signal when the device is open and the timeout elapsed. +- start-at-boot: Start pinging hw watchdog at probe, in order to take advantage + of kernel configs: + - WATCHDOG_HANDLE_BOOT_ENABLED: Avoid possible reboot if hw watchdog was been + enabled before the kernel (by uboot for example) and userspace doesn't take + control of /dev/watchdog in time; + - WATCHDOG_OPEN_TIMEOUT: Reboot if userspace doesn't take control of + /dev/watchdog within the timeout. Example: watchdog: watchdog {
Signature · 1 line
2.17.1
Guenter Roeck
maintainerRe: [PATCH 1/2] dt-bindings: watchdog: gpio-wdt: add "start-at-boot"
Quoted 12 lines · Francesco Zanella
Documentation for new device tree property "start-at-boot".
Signed-off-by Francesco Zanella <[email protected]>--- Documentation/devicetree/bindings/watchdog/gpio-wdt.txt | 7 +++++++ 1 file changed, 7 insertions(+)Documentation/devicetree/bindings/watchdog/gpio-wdt.txt +0
-0
Documentation/devicetree/bindings/watchdog/gpio-wdt.txt Optional Properties: · line 26
Quoted 10 lines
Documentation/devicetree/bindings/watchdog/gpio-wdt.txt +7
-0@@ -17,6 +17,13 @@ Optional Properties: - always-running: If the watchdog timer cannot be disabled, add this flag to have the driver keep toggling the signal without a client. It will only cease to toggle the signal when the device is open and the timeout elapsed. +- start-at-boot: Start pinging hw watchdog at probe, in order to take advantage + of kernel configs: + - WATCHDOG_HANDLE_BOOT_ENABLED: Avoid possible reboot if hw watchdog was been + enabled before the kernel (by uboot for example) and userspace doesn't take + control of /dev/watchdog in time; + - WATCHDOG_OPEN_TIMEOUT: Reboot if userspace doesn't take control of + /dev/watchdog within the timeout.
You are not supposed to refer to Linux kernel details in devicetree bindings documents.
Guenter
Quoted 6 lines
Documentation/devicetree/bindings/watchdog/gpio-wdt.txt +0
-0Example: watchdog: watchdog {Signature · 1 line
2.17.1
Re: [PATCH 1/2] dt-bindings: watchdog: gpio-wdt: add "start-at-boot"
Quoted 27 lines · Guenter Roeck
Quoted 12 lines · Francesco Zanella
Documentation for new device tree property "start-at-boot".
Signed-off-by Francesco Zanella <[email protected]>--- Documentation/devicetree/bindings/watchdog/gpio-wdt.txt | 7 +++++++ 1 file changed, 7 insertions(+)Documentation/devicetree/bindings/watchdog/gpio-wdt.txt +0
-0Documentation/devicetree/bindings/watchdog/gpio-wdt.txt Optional Properties: · line 26
Quoted 10 lines
Documentation/devicetree/bindings/watchdog/gpio-wdt.txt +7
-0@@ -17,6 +17,13 @@ Optional Properties: - always-running: If the watchdog timer cannot be disabled, add this flag to have the driver keep toggling the signal without a client. It will only cease to toggle the signal when the device is open and the timeout elapsed. +- start-at-boot: Start pinging hw watchdog at probe, in order to take advantage + of kernel configs: + - WATCHDOG_HANDLE_BOOT_ENABLED: Avoid possible reboot if hw watchdog was been + enabled before the kernel (by uboot for example) and userspace doesn't take + control of /dev/watchdog in time; + - WATCHDOG_OPEN_TIMEOUT: Reboot if userspace doesn't take control of + /dev/watchdog within the timeout.You are not supposed to refer to Linux kernel details in devicetree bindings documents.
Quoted 8 lines
Guenter
Quoted 6 lines
Documentation/devicetree/bindings/watchdog/gpio-wdt.txt +0
-0Example: watchdog: watchdog {Signature · 1 line
2.17.1
OK, I'm sorry. I will resend the patch series without kernel configs references in documents.
Francesco
PATCH 2/2 watchdog: gpio_wdt: add "start-at-boot" feature
In reply to Francesco ZanellaIf "start-at-boot" property is present in the device tree, start pinging hw watchdog at probe, in order to take advantage of kernel configs:
- WATCHDOG_HANDLE_BOOT_ENABLED: Avoid possible reboot if hw watchdog was been enabled before the kernel (by uboot for example) and userspace doesn't take control of /dev/watchdog in time;
- WATCHDOG_OPEN_TIMEOUT: Reboot if userspace doesn't take control of /dev/watchdog within the timeout.
--- drivers/watchdog/gpio_wdt.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/watchdog/gpio_wdt.c +5 -1
@@ -31,6 +31,7 @@ struct gpio_wdt_priv {struct gpio_desc *gpiod;bool state;bool always_running; +bool start_at_boot;unsigned int hw_algo;struct watchdog_device wdd; };
@@ -147,6 +148,9 @@ static int gpio_wdt_probe(struct platform_device *pdev) priv->always_running =of_property_read_bool (np,"always-running" ); + priv->start_at_boot =of_property_read_bool (np, +"start-at-boot" ); +watchdog_set_drvdata (&priv->wdd, priv); priv->wdd.info = &gpio_wdt_ident;
@@ -161,7 +165,7 @@ static int gpio_wdt_probe(struct platform_device *pdev)watchdog_stop_on_reboot (&priv->wdd); -if (priv->always_running) +if (priv->always_running || priv->start_at_boot)gpio_wdt_start (&priv->wdd);return devm_watchdog_register_device (dev, &priv->wdd);
Signature · 1 line
2.17.1
Guenter Roeck
maintainerRe: [PATCH 2/2] watchdog: gpio_wdt: add "start-at-boot" feature
Quoted 36 lines · Francesco Zanella
If "start-at-boot" property is present in the device tree, start pinging hw watchdog at probe, in order to take advantage of kernel configs:
-WATCHDOG_HANDLE_BOOT_ENABLED: Avoid possible reboot if hw watchdog was been enabled before the kernel (by uboot for example) and userspace doesn't take control of/dev/watchdogin time;
-WATCHDOG_OPEN_TIMEOUT: Reboot if userspace doesn't take control of/dev/watchdogwithin the timeout.Signed-off-by Francesco Zanella <[email protected]>--- drivers/watchdog/gpio_wdt.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)drivers/watchdog/gpio_wdt.c +4
-0@@ -31,6 +31,7 @@ struct gpio_wdt_priv {struct gpio_desc *gpiod;bool state;bool always_running; +bool start_at_boot;unsigned int hw_algo;struct watchdog_device wdd; };@@ -147,6 +148,9 @@ static int gpio_wdt_probe(struct platform_device *pdev) priv->always_running =of_property_read_bool (np,"always-running" ); + priv->start_at_boot =of_property_read_bool (np, +"start-at-boot" ); +watchdog_set_drvdata (&priv->wdd, priv); priv->wdd.info = &gpio_wdt_ident;
drivers/watchdog/gpio_wdt.c static int gpio_wdt_probe(struct platform_device *pdev) · line 169
Quoted 6 lines
drivers/watchdog/gpio_wdt.c +1
-1@@ -161,7 +165,7 @@ static int gpio_wdt_probe(struct platform_device *pdev)watchdog_stop_on_reboot (&priv->wdd); -if (priv->always_running) +if (priv->always_running || priv->start_at_boot)gpio_wdt_start (&priv->wdd);
So the only real difference to always_running is that always_running doesn't stop the watchdog on close but keeps it running.
Does that really warrant another property ? Why not just use always-running ?
The special use case of being able to stop the watchdog doesn't seem to be worth the trouble. Please explain your use case.
Guenter
Re: [PATCH 2/2] watchdog: gpio_wdt: add "start-at-boot" feature
Quoted 47 lines · Guenter Roeck
Quoted 36 lines · Francesco Zanella
If "start-at-boot" property is present in the device tree, start pinging hw watchdog at probe, in order to take advantage of kernel configs:
-WATCHDOG_HANDLE_BOOT_ENABLED: Avoid possible reboot if hw watchdog was been enabled before the kernel (by uboot for example) and userspace doesn't take control of/dev/watchdogin time;
-WATCHDOG_OPEN_TIMEOUT: Reboot if userspace doesn't take control of/dev/watchdogwithin the timeout.Signed-off-by Francesco Zanella <[email protected]>--- drivers/watchdog/gpio_wdt.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)drivers/watchdog/gpio_wdt.c +4
-0@@ -31,6 +31,7 @@ struct gpio_wdt_priv {struct gpio_desc *gpiod;bool state;bool always_running; +bool start_at_boot;unsigned int hw_algo;struct watchdog_device wdd; };@@ -147,6 +148,9 @@ static int gpio_wdt_probe(struct platform_device *pdev) priv->always_running =of_property_read_bool (np,"always-running" ); + priv->start_at_boot =of_property_read_bool (np, +"start-at-boot" ); +watchdog_set_drvdata (&priv->wdd, priv); priv->wdd.info = &gpio_wdt_ident;drivers/watchdog/gpio_wdt.c static int gpio_wdt_probe(struct platform_device *pdev) · line 169
Quoted 6 lines
drivers/watchdog/gpio_wdt.c +1
-1@@ -161,7 +165,7 @@ static int gpio_wdt_probe(struct platform_device *pdev)watchdog_stop_on_reboot (&priv->wdd); -if (priv->always_running) +if (priv->always_running || priv->start_at_boot)gpio_wdt_start (&priv->wdd);So the only real difference to
always_runningis thatalways_runningdoesn't stop the watchdog on close but keeps it running.
Quoted 8 lines
Does that really warrant another property ? Why not just use always-running ?
The special use case of being able to stop the watchdog doesn't seem to be worth the trouble. Please explain your use case.
Guenter
You got the point.
I would like to be able to stop the watchdog when I want. From my point of view always_running is used in the very special case when the wdt chip can't be stopped.
I want a normal wdt that can be stopped (for example during a system update), but I want it to start at boot for the 2 reasons that I explained before:
- I need continuity in hw wdt pinging because I start in uboot, so I take advantage of WATCHDOG_HANDLE_BOOT_ENABLED that makes the kernel to do that job; but it is triggered only if it is started at probe, if I'm not wrong.
- I would like to monitor with the wdt also the kernel at boot, and more importantly handle the case when the userspace app doesn't take control of /dev/watchdog for whatever reason within the timeout set with WATCHDOG_OPEN_TIMEOUT.
Hope that this explain my target.
Thanks for your attention,
Francesco
Guenter Roeck
maintainerRe: [PATCH 2/2] watchdog: gpio_wdt: add "start-at-boot" feature
Quoted 59 lines · Francesco Zanella
Quoted 47 lines · Guenter Roeck
Quoted 36 lines · Francesco Zanella
If "start-at-boot" property is present in the device tree, start pinging hw watchdog at probe, in order to take advantage of kernel configs:
-WATCHDOG_HANDLE_BOOT_ENABLED: Avoid possible reboot if hw watchdog was been enabled before the kernel (by uboot for example) and userspace doesn't take control of/dev/watchdogin time;
-WATCHDOG_OPEN_TIMEOUT: Reboot if userspace doesn't take control of/dev/watchdogwithin the timeout.Signed-off-by Francesco Zanella <[email protected]>--- drivers/watchdog/gpio_wdt.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)drivers/watchdog/gpio_wdt.c +4
-0@@ -31,6 +31,7 @@ struct gpio_wdt_priv {struct gpio_desc *gpiod;bool state;bool always_running; +bool start_at_boot;unsigned int hw_algo;struct watchdog_device wdd; };@@ -147,6 +148,9 @@ static int gpio_wdt_probe(struct platform_device *pdev) priv->always_running =of_property_read_bool (np,"always-running" ); + priv->start_at_boot =of_property_read_bool (np, +"start-at-boot" ); +watchdog_set_drvdata (&priv->wdd, priv); priv->wdd.info = &gpio_wdt_ident;drivers/watchdog/gpio_wdt.c static int gpio_wdt_probe(struct platform_device *pdev) · line 169
Quoted 6 lines
drivers/watchdog/gpio_wdt.c +1
-1@@ -161,7 +165,7 @@ static int gpio_wdt_probe(struct platform_device *pdev)watchdog_stop_on_reboot (&priv->wdd); -if (priv->always_running) +if (priv->always_running || priv->start_at_boot)gpio_wdt_start (&priv->wdd);So the only real difference to
always_runningis thatalways_runningdoesn't stop the watchdog on close but keeps it running.Quoted 8 lines
Does that really warrant another property ? Why not just use always-running ?
The special use case of being able to stop the watchdog doesn't seem to be worth the trouble. Please explain your use case.
Guenter
Quoted 11 lines
You got the point.
I would like to be able to stop the watchdog when I want. From my point of viewalways_runningis used in the very special case when the wdt chip can't be stopped.
I want a normal wdt that can be stopped (for example during a system update), but I want it to start at boot for the 2 reasons that I explained before:
- I need continuity in hw wdt pinging because I start in uboot, so I take advantage ofWATCHDOG_HANDLE_BOOT_ENABLEDthat makes the kernel to do that job; but it is triggered only if it is started at probe, if I'm not wrong.
That depends. If the driver can read the current state (ie if it can detect if the watchdog is running) it can report it to the watchdog core accordingly. That would be the preferred mechanism. Everything else is just a workaround for bad hardware (bad as in "it doesn't report its state").
Guenter
Quoted 9 lines
- I would like to monitor with the wdt also the kernel at boot, and more importantly handle the case when the userspace app doesn't take control of
/dev/watchdogfor whatever reason within the timeout set withWATCHDOG_OPEN_TIMEOUT.Hope that this explain my target.
Thanks for your attention,Francesco
Re: [PATCH 2/2] watchdog: gpio_wdt: add "start-at-boot" feature
Quoted 72 lines · Guenter Roeck
Quoted 59 lines · Francesco Zanella
Quoted 47 lines · Guenter Roeck
Quoted 36 lines · Francesco Zanella
If "start-at-boot" property is present in the device tree, start pinging hw watchdog at probe, in order to take advantage of kernel configs:
-WATCHDOG_HANDLE_BOOT_ENABLED: Avoid possible reboot if hw watchdog was been enabled before the kernel (by uboot for example) and userspace doesn't take control of/dev/watchdogin time;
-WATCHDOG_OPEN_TIMEOUT: Reboot if userspace doesn't take control of/dev/watchdogwithin the timeout.Signed-off-by Francesco Zanella <[email protected]>--- drivers/watchdog/gpio_wdt.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)drivers/watchdog/gpio_wdt.c +4
-0@@ -31,6 +31,7 @@ struct gpio_wdt_priv {struct gpio_desc *gpiod;bool state;bool always_running; +bool start_at_boot;unsigned int hw_algo;struct watchdog_device wdd; };@@ -147,6 +148,9 @@ static int gpio_wdt_probe(struct platform_device *pdev) priv->always_running =of_property_read_bool (np,"always-running" ); + priv->start_at_boot =of_property_read_bool (np, +"start-at-boot" ); +watchdog_set_drvdata (&priv->wdd, priv); priv->wdd.info = &gpio_wdt_ident;drivers/watchdog/gpio_wdt.c static int gpio_wdt_probe(struct platform_device *pdev) · line 169
Quoted 6 lines
drivers/watchdog/gpio_wdt.c +1
-1@@ -161,7 +165,7 @@ static int gpio_wdt_probe(struct platform_device *pdev)watchdog_stop_on_reboot (&priv->wdd); -if (priv->always_running) +if (priv->always_running || priv->start_at_boot)gpio_wdt_start (&priv->wdd);So the only real difference to
always_runningis thatalways_runningdoesn't stop the watchdog on close but keeps it running.Quoted 8 lines
Does that really warrant another property ? Why not just use always-running ?
The special use case of being able to stop the watchdog doesn't seem to be worth the trouble. Please explain your use case.
Guenter
Quoted 11 lines
You got the point.
I would like to be able to stop the watchdog when I want. From my point of viewalways_runningis used in the very special case when the wdt chip can't be stopped.
I want a normal wdt that can be stopped (for example during a system update), but I want it to start at boot for the 2 reasons that I explained before:
- I need continuity in hw wdt pinging because I start in uboot, so I take advantage ofWATCHDOG_HANDLE_BOOT_ENABLEDthat makes the kernel to do that job; but it is triggered only if it is started at probe, if I'm not wrong.
Quoted 17 lines
That depends. If the driver can read the current state (ie if it can detect if the watchdog is running) it can report it to the watchdog core accordingly. That would be the preferred mechanism. Everything else is just a workaround for bad hardware (bad as in "it doesn't report its state").
Guenter
Quoted 9 lines
- I would like to monitor with the wdt also the kernel at boot, and more importantly handle the case when the userspace app doesn't take control of
/dev/watchdogfor whatever reason within the timeout set withWATCHDOG_OPEN_TIMEOUT.Hope that this explain my target.
Thanks for your attention,Francesco
Right, I agree with you that's the optimal way, but we are talking about a low cost, simple GPIO WDT, that has only an input GPIO as an interface with the system... how can it report its state if the only way to enable/disable it is a particular state of the GPIO that we are going to pilot?
I think that this driver was born for that kind of low cost chips (I'm using a SGM706 for example), why can't we let it take advantage of a useful kernel mechanism?
Thank you,
Francesco
Re: [PATCH 2/2] watchdog: gpio_wdt: add "start-at-boot" feature
In reply to Francesco ZanellaQuoted 2 lines · Francesco Zanella
If "start-at-boot" property is present in the device tree, start pinging hw watchdog at probe, in order to take advantage of kernel configs:
(1) Are you aware of the recent proposal to add a similar feature on watchdog core level:
https://lore.kernel.org/lkml/?q=start_enable
(2) If you set always-running but not nowayout you essentially have what you want now: If userspace opens the device [within the limit set by OPEN_TIMEOUT if that is in effect], but then does a graceful close (i.e. writes 'V' immediately before close()), the kernel will assume responsibility for pinging the device. So the device isn't stopped as such, but if you can't trust the kernel thread/timer to keep it alive, the system is already mostly unusable. [Also, how reliable is that 'the timer is stopped if the gpio is set to be an input' anyway].
Rasmus
Re: [PATCH 2/2] watchdog: gpio_wdt: add "start-at-boot" feature
Quoted 9 lines · Rasmus Villemoes
Quoted 2 lines · Francesco Zanella
If "start-at-boot" property is present in the device tree, start pinging hw watchdog at probe, in order to take advantage of kernel configs:
(1) Are you aware of the recent proposal to add a similar feature on watchdog core level:
Oh good! Happy to know that, I missed it, sorry, it's quite new. That kind of work would have been my next proposal if this had been accepted. Hope that it will be mainlined.
Quoted 11 lines
(2) If you set always-running but not nowayout you essentially have what you want now: If userspace opens the device [within the limit set by
OPEN_TIMEOUTif that is in effect], but then does a graceful close (i.e. writes 'V' immediately beforeclose()), the kernel will assume responsibility for pinging the device. So the device isn't stopped as such, but if you can't trust the kernel thread/timer to keep it alive, the system is already mostly unusable. [Also, how reliable is that 'the timer is stopped if the gpio is set to be an input' anyway].Rasmus
No I would like to be able to totally disable it with stop, not that the kernel will keep it pinged.
However, glad to know the news, I will follow the evolution.
Thanks, regards,
Francesco Zanella