Skip to contentSkip to conversation

watchdog: meson_gxbb_wdt: improve

PATCH Superseded Artem Lapkin 2 participants 11 messages Jun 23, 2021 – Jun 27, 2021

Subsystems (2)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v2 cover 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(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH v2 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

---
 drivers/watchdog/meson_gxbb_wdt.c | 1 -
 1 file changed, 1 deletion(-)
drivers/watchdog/meson_gxbb_wdt.c +0 -1
index 5a9ca10fbcfa..3f86530c33b0 100644
@@ -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);
 }
 
Signature · 1 line
2.25.1
maintainer
#2 lore raw

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

Quoted 4 lines · Artem Lapkin

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

Quoted 18 lines
---
  drivers/watchdog/meson_gxbb_wdt.c | 1 -
  1 file changed, 1 deletion(-)
drivers/watchdog/meson_gxbb_wdt.c +0 -1
index 5a9ca10fbcfa..3f86530c33b0 100644
@@ -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);
  }
 
#3 lore raw

PATCH v2 2/5 watchdog: meson_gxbb_wdt: add timeout module param

In reply to Artem Lapkin

Added timeout module param same as in other modules

---
 drivers/watchdog/meson_gxbb_wdt.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/watchdog/meson_gxbb_wdt.c +6 -1
index 3f86530c33b0..ecd1fc6f48ba 100644
@@ -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 */
Signature · 1 line
2.25.1
maintainer
#4 lore raw

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

Quoted 24 lines · Artem Lapkin

Added timeout module param same as in other modules

---
  drivers/watchdog/meson_gxbb_wdt.c | 7 ++++++-
  1 file changed, 6 insertions(+), 1 deletion(-)
drivers/watchdog/meson_gxbb_wdt.c +5 -0
index 3f86530c33b0..ecd1fc6f48ba 100644
@@ -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;

drivers/watchdog/meson_gxbb_wdt.c static int meson_gxbb_wdt_probe(struct platform_device *pdev) · line 182

Quoted 5 lines
drivers/watchdog/meson_gxbb_wdt.c +1 -1
@@ -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

Quoted 4 lines
drivers/watchdog/meson_gxbb_wdt.c +0 -0
  	watchdog_set_drvdata(&data->wdt_dev, data);
 
  	/* Setup with 1ms timebase */
#5 lore raw

PATCH v2 3/5 watchdog: meson_gxbb_wdt: add nowayout module param

In reply to Artem Lapkin

Added nowayout module param same as in other moduels

---
 drivers/watchdog/meson_gxbb_wdt.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/watchdog/meson_gxbb_wdt.c +6 -0
index ecd1fc6f48ba..0bf5dccf70b1 100644
@@ -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);
 }
Signature · 1 line
2.25.1
maintainer
#6 lore raw

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

Quoted 1 line · Artem Lapkin

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.

Quoted 11 lines
---
  drivers/watchdog/meson_gxbb_wdt.c | 6 ++++++
  1 file changed, 6 insertions(+)
drivers/watchdog/meson_gxbb_wdt.c +0 -0
index ecd1fc6f48ba..0bf5dccf70b1 100644

drivers/watchdog/meson_gxbb_wdt.c module_param(timeout, uint, 0); · line 39

Quoted 6 lines
drivers/watchdog/meson_gxbb_wdt.c +3 -0
@@ -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'

Quoted 14 lines
drivers/watchdog/meson_gxbb_wdt.c +3 -0
+		 __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);
  }
#7 lore raw

PATCH v2 4/5 watchdog: meson_gxbb_wdt: add stop_on_unregister

In reply to Artem Lapkin

Added missed watchdog_stop_on_unregister call

---
 drivers/watchdog/meson_gxbb_wdt.c | 1 +
 1 file changed, 1 insertion(+)
drivers/watchdog/meson_gxbb_wdt.c +1 -0
index 0bf5dccf70b1..2dbe254e5122 100644
@@ -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);
 }
Signature · 1 line
2.25.1
maintainer
#8 lore raw

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

Quoted 2 lines · Artem Lapkin

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

Quoted 18 lines
---
  drivers/watchdog/meson_gxbb_wdt.c | 1 +
  1 file changed, 1 insertion(+)
drivers/watchdog/meson_gxbb_wdt.c +1 -0
index 0bf5dccf70b1..2dbe254e5122 100644
@@ -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);
  }
#9 lore raw

PATCH v2 5/5 watchdog: meson_gxbb_wdt: add register device status notification

In reply to Artem Lapkin

Print watchdog success driver start status notification

---
 drivers/watchdog/meson_gxbb_wdt.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/watchdog/meson_gxbb_wdt.c +8 -1
index 2dbe254e5122..750b304b460d 100644
@@ -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 = {
Signature · 1 line
2.25.1
maintainer
#10 lore raw

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

Quoted 2 lines · Artem Lapkin

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

Quoted 26 lines
---
  drivers/watchdog/meson_gxbb_wdt.c | 9 ++++++++-
  1 file changed, 8 insertions(+), 1 deletion(-)
drivers/watchdog/meson_gxbb_wdt.c +8 -1
index 2dbe254e5122..750b304b460d 100644
@@ -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 = {