2021-06-23 02:46:16

by Artem Lapkin

[permalink] [raw]
Subject: [PATCH 0/5 v2] watchdog: meson_gxbb_wdt: improve

Try to improve meson_gxbb_wdt driver to common view:

* Remove watchdog_stop_on_reboot (still can be activated by
watchdog.stop_on_reboot=1) i think this driver configuration more useful
becouse we can get reboot waranty for abnormal situations on shutdown stage

* Added timeout module param same as in other modules
* Added nowayout module param same as in other moduels
* Added missed watchdog_stop_on_unregister call
* Print watchdog success driver start status notification

Artem Lapkin (5):
watchdog: meson_gxbb_wdt: remove watchdog_stop_on_reboot
watchdog: meson_gxbb_wdt: add timeout module param
watchdog: meson_gxbb_wdt: add nowayout module param
watchdog: meson_gxbb_wdt: add stop_on_unregister
watchdog: meson_gxbb_wdt: add register device status notification

drivers/watchdog/meson_gxbb_wdt.c | 24 +++++++++++++++++++++---
1 file changed, 21 insertions(+), 3 deletions(-)

--
2.25.1


2021-06-23 02:46:32

by Artem Lapkin

[permalink] [raw]
Subject: [PATCH 1/5] watchdog: meson_gxbb_wdt: remove watchdog_stop_on_reboot

Remove watchdog_stop_on_reboot (still can be activated by
watchdog.stop_on_reboot=1) i think this driver configuration more useful
becouse we can get reboot waranty for abnormal situations on shutdown stage

Signed-off-by: Artem Lapkin <[email protected]>
---
drivers/watchdog/meson_gxbb_wdt.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/drivers/watchdog/meson_gxbb_wdt.c b/drivers/watchdog/meson_gxbb_wdt.c
index 5a9ca10fbcfa..3f86530c33b0 100644
--- a/drivers/watchdog/meson_gxbb_wdt.c
+++ b/drivers/watchdog/meson_gxbb_wdt.c
@@ -186,7 +186,6 @@ static int meson_gxbb_wdt_probe(struct platform_device *pdev)

meson_gxbb_wdt_set_timeout(&data->wdt_dev, data->wdt_dev.timeout);

- watchdog_stop_on_reboot(&data->wdt_dev);
return devm_watchdog_register_device(dev, &data->wdt_dev);
}

--
2.25.1

2021-06-23 02:46:45

by Artem Lapkin

[permalink] [raw]
Subject: [PATCH 2/5] watchdog: meson_gxbb_wdt: add timeout module param

Added timeout module param same as in other modules

Signed-off-by: Artem Lapkin <[email protected]>
---
drivers/watchdog/meson_gxbb_wdt.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/watchdog/meson_gxbb_wdt.c b/drivers/watchdog/meson_gxbb_wdt.c
index 3f86530c33b0..ecd1fc6f48ba 100644
--- a/drivers/watchdog/meson_gxbb_wdt.c
+++ b/drivers/watchdog/meson_gxbb_wdt.c
@@ -29,6 +29,11 @@
#define GXBB_WDT_TCNT_SETUP_MASK (BIT(16) - 1)
#define GXBB_WDT_TCNT_CNT_SHIFT 16

+static unsigned int timeout = DEFAULT_TIMEOUT;
+module_param(timeout, uint, 0);
+MODULE_PARM_DESC(timeout, "Watchdog heartbeat in seconds="
+ __MODULE_STRING(DEFAULT_TIMEOUT) ")");
+
struct meson_gxbb_wdt {
void __iomem *reg_base;
struct watchdog_device wdt_dev;
@@ -174,7 +179,7 @@ static int meson_gxbb_wdt_probe(struct platform_device *pdev)
data->wdt_dev.ops = &meson_gxbb_wdt_ops;
data->wdt_dev.max_hw_heartbeat_ms = GXBB_WDT_TCNT_SETUP_MASK;
data->wdt_dev.min_timeout = 1;
- data->wdt_dev.timeout = DEFAULT_TIMEOUT;
+ data->wdt_dev.timeout = timeout;
watchdog_set_drvdata(&data->wdt_dev, data);

/* Setup with 1ms timebase */
--
2.25.1

2021-06-23 02:47:08

by Artem Lapkin

[permalink] [raw]
Subject: [PATCH 4/5] watchdog: meson_gxbb_wdt: add stop_on_unregister

Added missed watchdog_stop_on_unregister call

Signed-off-by: Artem Lapkin <[email protected]>
---
drivers/watchdog/meson_gxbb_wdt.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/watchdog/meson_gxbb_wdt.c b/drivers/watchdog/meson_gxbb_wdt.c
index 0bf5dccf70b1..2dbe254e5122 100644
--- a/drivers/watchdog/meson_gxbb_wdt.c
+++ b/drivers/watchdog/meson_gxbb_wdt.c
@@ -196,6 +196,7 @@ static int meson_gxbb_wdt_probe(struct platform_device *pdev)

meson_gxbb_wdt_set_timeout(&data->wdt_dev, data->wdt_dev.timeout);
watchdog_set_nowayout(&data->wdt_dev, nowayout);
+ watchdog_stop_on_unregister(&data->wdt_dev);

return devm_watchdog_register_device(dev, &data->wdt_dev);
}
--
2.25.1

2021-06-23 02:48:42

by Artem Lapkin

[permalink] [raw]
Subject: [PATCH 3/5] watchdog: meson_gxbb_wdt: add nowayout module param

Added nowayout module param same as in other moduels

Signed-off-by: Artem Lapkin <[email protected]>
---
drivers/watchdog/meson_gxbb_wdt.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/drivers/watchdog/meson_gxbb_wdt.c b/drivers/watchdog/meson_gxbb_wdt.c
index ecd1fc6f48ba..0bf5dccf70b1 100644
--- a/drivers/watchdog/meson_gxbb_wdt.c
+++ b/drivers/watchdog/meson_gxbb_wdt.c
@@ -34,6 +34,11 @@ module_param(timeout, uint, 0);
MODULE_PARM_DESC(timeout, "Watchdog heartbeat in seconds="
__MODULE_STRING(DEFAULT_TIMEOUT) ")");

+static bool nowayout = WATCHDOG_NOWAYOUT;
+module_param(nowayout, bool, 0);
+MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started default="
+ __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
+
struct meson_gxbb_wdt {
void __iomem *reg_base;
struct watchdog_device wdt_dev;
@@ -190,6 +195,7 @@ static int meson_gxbb_wdt_probe(struct platform_device *pdev)
data->reg_base + GXBB_WDT_CTRL_REG);

meson_gxbb_wdt_set_timeout(&data->wdt_dev, data->wdt_dev.timeout);
+ watchdog_set_nowayout(&data->wdt_dev, nowayout);

return devm_watchdog_register_device(dev, &data->wdt_dev);
}
--
2.25.1

2021-06-23 02:49:47

by Artem Lapkin

[permalink] [raw]
Subject: [PATCH 5/5] watchdog: meson_gxbb_wdt: add register device status notification

Print watchdog success driver start status notification

Signed-off-by: Artem Lapkin <[email protected]>
---
drivers/watchdog/meson_gxbb_wdt.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/watchdog/meson_gxbb_wdt.c b/drivers/watchdog/meson_gxbb_wdt.c
index 2dbe254e5122..750b304b460d 100644
--- a/drivers/watchdog/meson_gxbb_wdt.c
+++ b/drivers/watchdog/meson_gxbb_wdt.c
@@ -198,7 +198,14 @@ static int meson_gxbb_wdt_probe(struct platform_device *pdev)
watchdog_set_nowayout(&data->wdt_dev, nowayout);
watchdog_stop_on_unregister(&data->wdt_dev);

- return devm_watchdog_register_device(dev, &data->wdt_dev);
+ ret = devm_watchdog_register_device(dev, &data->wdt_dev);
+ if (ret)
+ return ret;
+
+ dev_info(dev, "Watchdog enabled (timeout=%d sec, nowayout=%d)",
+ data->wdt_dev.timeout, nowayout);
+
+ return ret;
}

static struct platform_driver meson_gxbb_wdt_driver = {
--
2.25.1

2021-06-27 15:34:14

by Guenter Roeck

[permalink] [raw]
Subject: Re: [PATCH 1/5] watchdog: meson_gxbb_wdt: remove watchdog_stop_on_reboot

On 6/22/21 7:44 PM, Artem Lapkin wrote:
> Remove watchdog_stop_on_reboot (still can be activated by
> watchdog.stop_on_reboot=1) i think this driver configuration more useful
> becouse we can get reboot waranty for abnormal situations on shutdown stage
>

This is personal opinion. Driver authors would have to agree.

Guenter

> Signed-off-by: Artem Lapkin <[email protected]>
> ---
> drivers/watchdog/meson_gxbb_wdt.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/drivers/watchdog/meson_gxbb_wdt.c b/drivers/watchdog/meson_gxbb_wdt.c
> index 5a9ca10fbcfa..3f86530c33b0 100644
> --- a/drivers/watchdog/meson_gxbb_wdt.c
> +++ b/drivers/watchdog/meson_gxbb_wdt.c
> @@ -186,7 +186,6 @@ static int meson_gxbb_wdt_probe(struct platform_device *pdev)
>
> meson_gxbb_wdt_set_timeout(&data->wdt_dev, data->wdt_dev.timeout);
>
> - watchdog_stop_on_reboot(&data->wdt_dev);
> return devm_watchdog_register_device(dev, &data->wdt_dev);
> }
>
>

2021-06-27 15:35:48

by Guenter Roeck

[permalink] [raw]
Subject: Re: [PATCH 2/5] watchdog: meson_gxbb_wdt: add timeout module param

On 6/22/21 7:44 PM, Artem Lapkin wrote:
> Added timeout module param same as in other modules
>
> Signed-off-by: Artem Lapkin <[email protected]>
> ---
> drivers/watchdog/meson_gxbb_wdt.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/watchdog/meson_gxbb_wdt.c b/drivers/watchdog/meson_gxbb_wdt.c
> index 3f86530c33b0..ecd1fc6f48ba 100644
> --- a/drivers/watchdog/meson_gxbb_wdt.c
> +++ b/drivers/watchdog/meson_gxbb_wdt.c
> @@ -29,6 +29,11 @@
> #define GXBB_WDT_TCNT_SETUP_MASK (BIT(16) - 1)
> #define GXBB_WDT_TCNT_CNT_SHIFT 16
>
> +static unsigned int timeout = DEFAULT_TIMEOUT;
> +module_param(timeout, uint, 0);
> +MODULE_PARM_DESC(timeout, "Watchdog heartbeat in seconds="
> + __MODULE_STRING(DEFAULT_TIMEOUT) ")");
> +
> struct meson_gxbb_wdt {
> void __iomem *reg_base;
> struct watchdog_device wdt_dev;
> @@ -174,7 +179,7 @@ static int meson_gxbb_wdt_probe(struct platform_device *pdev)
> data->wdt_dev.ops = &meson_gxbb_wdt_ops;
> data->wdt_dev.max_hw_heartbeat_ms = GXBB_WDT_TCNT_SETUP_MASK;
> data->wdt_dev.min_timeout = 1;
> - data->wdt_dev.timeout = DEFAULT_TIMEOUT;
> + data->wdt_dev.timeout = timeout;

This is wrong. A timeout module parameter should be set with a call to
watchdog_init_timeout(), the initial value should be 0, and data->wdt_dev.timeout
should be kept as-is. This ensures that the module parameter is validated.

Guenter

> watchdog_set_drvdata(&data->wdt_dev, data);
>
> /* Setup with 1ms timebase */
>

2021-06-27 15:38:38

by Guenter Roeck

[permalink] [raw]
Subject: Re: [PATCH 3/5] watchdog: meson_gxbb_wdt: add nowayout module param

On 6/22/21 7:44 PM, Artem Lapkin wrote:
> Added nowayout module param same as in other moduels

Please use complete sentences and words, check your spelling (modules),
and refrain from irrelevant statements such as "same as in other moduels".

"Add nowayout module parameter" is sufficient here.

>
> Signed-off-by: Artem Lapkin <[email protected]>
> ---
> drivers/watchdog/meson_gxbb_wdt.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/drivers/watchdog/meson_gxbb_wdt.c b/drivers/watchdog/meson_gxbb_wdt.c
> index ecd1fc6f48ba..0bf5dccf70b1 100644
> --- a/drivers/watchdog/meson_gxbb_wdt.c
> +++ b/drivers/watchdog/meson_gxbb_wdt.c
> @@ -34,6 +34,11 @@ module_param(timeout, uint, 0);
> MODULE_PARM_DESC(timeout, "Watchdog heartbeat in seconds="
> __MODULE_STRING(DEFAULT_TIMEOUT) ")");
>
> +static bool nowayout = WATCHDOG_NOWAYOUT;
> +module_param(nowayout, bool, 0);
> +MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started default="

'(' missing before 'default'

> + __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
> +
> struct meson_gxbb_wdt {
> void __iomem *reg_base;
> struct watchdog_device wdt_dev;
> @@ -190,6 +195,7 @@ static int meson_gxbb_wdt_probe(struct platform_device *pdev)
> data->reg_base + GXBB_WDT_CTRL_REG);
>
> meson_gxbb_wdt_set_timeout(&data->wdt_dev, data->wdt_dev.timeout);
> + watchdog_set_nowayout(&data->wdt_dev, nowayout);
>
> return devm_watchdog_register_device(dev, &data->wdt_dev);
> }
>

2021-06-27 15:47:37

by Guenter Roeck

[permalink] [raw]
Subject: Re: [PATCH 4/5] watchdog: meson_gxbb_wdt: add stop_on_unregister

On 6/22/21 7:44 PM, Artem Lapkin wrote:
> Added missed watchdog_stop_on_unregister call
>

This is again personal opinion and needs an acknowledgement
by driver authors. It is only necessary if one wants to support
that the watchdog is force-stopped by killing the watchdog daemon
(which leaves the watchdog running) and subsequently unloading
the driver. The call is not 'missing'; otherwise the core could
just do it. For that reason it should not be added with the argument
that it would be 'missing'. This will require a better argument.
Why is that call needed ? What is the use case ?

Guenter

> Signed-off-by: Artem Lapkin <[email protected]>
> ---
> drivers/watchdog/meson_gxbb_wdt.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/watchdog/meson_gxbb_wdt.c b/drivers/watchdog/meson_gxbb_wdt.c
> index 0bf5dccf70b1..2dbe254e5122 100644
> --- a/drivers/watchdog/meson_gxbb_wdt.c
> +++ b/drivers/watchdog/meson_gxbb_wdt.c
> @@ -196,6 +196,7 @@ static int meson_gxbb_wdt_probe(struct platform_device *pdev)
>
> meson_gxbb_wdt_set_timeout(&data->wdt_dev, data->wdt_dev.timeout);
> watchdog_set_nowayout(&data->wdt_dev, nowayout);
> + watchdog_stop_on_unregister(&data->wdt_dev);
>
> return devm_watchdog_register_device(dev, &data->wdt_dev);
> }
>

2021-06-27 15:50:44

by Guenter Roeck

[permalink] [raw]
Subject: Re: [PATCH 5/5] watchdog: meson_gxbb_wdt: add register device status notification

On 6/22/21 7:44 PM, Artem Lapkin wrote:
> Print watchdog success driver start status notification
>

Another personal opinion: The driver author decided that the message is
not needed (which matches my personal opinion). I'd rather see all those
messages either go away or moved to the core. Either case, this one is
misleading: The watchdog is _not_ enabled. The watchdog driver is loaded,
which is different.

Guenter

> Signed-off-by: Artem Lapkin <[email protected]>
> ---
> drivers/watchdog/meson_gxbb_wdt.c | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/watchdog/meson_gxbb_wdt.c b/drivers/watchdog/meson_gxbb_wdt.c
> index 2dbe254e5122..750b304b460d 100644
> --- a/drivers/watchdog/meson_gxbb_wdt.c
> +++ b/drivers/watchdog/meson_gxbb_wdt.c
> @@ -198,7 +198,14 @@ static int meson_gxbb_wdt_probe(struct platform_device *pdev)
> watchdog_set_nowayout(&data->wdt_dev, nowayout);
> watchdog_stop_on_unregister(&data->wdt_dev);
>
> - return devm_watchdog_register_device(dev, &data->wdt_dev);
> + ret = devm_watchdog_register_device(dev, &data->wdt_dev);
> + if (ret)
> + return ret;
> +
> + dev_info(dev, "Watchdog enabled (timeout=%d sec, nowayout=%d)",
> + data->wdt_dev.timeout, nowayout);
> +
> + return ret;
> }
>
> static struct platform_driver meson_gxbb_wdt_driver = {
>