Linux Watchdog driver development
 help / color / mirror / Atom feed
* [PATCH 0/4] Various fixes for the da9052 watchdog
@ 2025-03-13 12:14 Marcus Folkesson
  2025-03-13 12:14 ` [PATCH 1/4] watchdog: da9052_wdt: add support for nowayout Marcus Folkesson
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Marcus Folkesson @ 2025-03-13 12:14 UTC (permalink / raw)
  To: Support Opensource, Wim Van Sebroeck, Guenter Roeck
  Cc: linux-watchdog, linux-kernel, Marcus Folkesson

Add support for the nowayout and timeout module parameters and treat
them in a standard way.

Respect twdmin, without this the watchdog timer will immediately assert
TWD_ERROR and power down to reset mode.

Do not stop the watchdog during probe. If the watchdog is enabled in the
bootloader, it should propably supposed to stay on.

Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
---
Marcus Folkesson (4):
      watchdog: da9052_wdt: add support for nowayout
      watchdog: da9052_wdt: use timeout value from external inputs
      watchdog: da9052_wdt: do not disable wdt during probe
      watchdog: da9052_wdt: respect TWDMIN

 drivers/watchdog/da9052_wdt.c | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)
---
base-commit: 0fed89a961ea851945d23cc35beb59d6e56c0964
change-id: 20250313-da9052-fixes-186674b34993

Best regards,
-- 
Marcus Folkesson <marcus.folkesson@gmail.com>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/4] watchdog: da9052_wdt: add support for nowayout
  2025-03-13 12:14 [PATCH 0/4] Various fixes for the da9052 watchdog Marcus Folkesson
@ 2025-03-13 12:14 ` Marcus Folkesson
  2025-03-13 12:14 ` [PATCH 2/4] watchdog: da9052_wdt: use timeout value from external inputs Marcus Folkesson
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Marcus Folkesson @ 2025-03-13 12:14 UTC (permalink / raw)
  To: Support Opensource, Wim Van Sebroeck, Guenter Roeck
  Cc: linux-watchdog, linux-kernel, Marcus Folkesson

Add nowayout module parameter for not stopping the
watchdog when userspae application quits.

Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
---
 drivers/watchdog/da9052_wdt.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/watchdog/da9052_wdt.c b/drivers/watchdog/da9052_wdt.c
index 77039f2f0be54273df1666fe40c413b6c89285a1..a8ff1e6a7903f6f139c5bb60d7d92ca39077ee04 100644
--- a/drivers/watchdog/da9052_wdt.c
+++ b/drivers/watchdog/da9052_wdt.c
@@ -30,6 +30,12 @@ struct da9052_wdt_data {
 	unsigned long jpast;
 };
 
+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) ")");
+
 static const struct {
 	u8 reg_val;
 	int time;  /* Seconds */
@@ -172,6 +178,7 @@ static int da9052_wdt_probe(struct platform_device *pdev)
 	da9052_wdt->ops = &da9052_wdt_ops;
 	da9052_wdt->parent = dev;
 	watchdog_set_drvdata(da9052_wdt, driver_data);
+	watchdog_set_nowayout(da9052_wdt, nowayout);
 
 	if (da9052->fault_log & DA9052_FAULTLOG_TWDERROR)
 		da9052_wdt->bootstatus |= WDIOF_CARDRESET;

-- 
2.48.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/4] watchdog: da9052_wdt: use timeout value from external inputs
  2025-03-13 12:14 [PATCH 0/4] Various fixes for the da9052 watchdog Marcus Folkesson
  2025-03-13 12:14 ` [PATCH 1/4] watchdog: da9052_wdt: add support for nowayout Marcus Folkesson
@ 2025-03-13 12:14 ` Marcus Folkesson
  2025-03-13 12:14 ` [PATCH 3/4] watchdog: da9052_wdt: do not disable wdt during probe Marcus Folkesson
  2025-03-13 12:14 ` [PATCH 4/4] watchdog: da9052_wdt: respect TWDMIN Marcus Folkesson
  3 siblings, 0 replies; 6+ messages in thread
From: Marcus Folkesson @ 2025-03-13 12:14 UTC (permalink / raw)
  To: Support Opensource, Wim Van Sebroeck, Guenter Roeck
  Cc: linux-watchdog, linux-kernel, Marcus Folkesson

Introduce the `timeout` module parameter and pass it to
watchdog_init_timeout(). If the parameter is not set or contains an
invalid value, fallback on the `timeout-secs` devicetree property value.

If none of the above is valid, go for the old default value.

Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
---
 drivers/watchdog/da9052_wdt.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/watchdog/da9052_wdt.c b/drivers/watchdog/da9052_wdt.c
index a8ff1e6a7903f6f139c5bb60d7d92ca39077ee04..fa9078d4c136a52f1193768fe93dc04189519679 100644
--- a/drivers/watchdog/da9052_wdt.c
+++ b/drivers/watchdog/da9052_wdt.c
@@ -36,6 +36,12 @@ MODULE_PARM_DESC(nowayout,
 		 "Watchdog cannot be stopped once started (default="
 		 __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
 
+static int timeout;
+module_param(timeout, int, 0);
+MODULE_PARM_DESC(timeout,
+	"Watchdog timeout in seconds. (default = "
+	__MODULE_STRING(WDT_DEFAULT_TIMEOUT) ")");
+
 static const struct {
 	u8 reg_val;
 	int time;  /* Seconds */
@@ -178,6 +184,7 @@ static int da9052_wdt_probe(struct platform_device *pdev)
 	da9052_wdt->ops = &da9052_wdt_ops;
 	da9052_wdt->parent = dev;
 	watchdog_set_drvdata(da9052_wdt, driver_data);
+	watchdog_init_timeout(da9052_wdt, timeout, dev);
 	watchdog_set_nowayout(da9052_wdt, nowayout);
 
 	if (da9052->fault_log & DA9052_FAULTLOG_TWDERROR)

-- 
2.48.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/4] watchdog: da9052_wdt: do not disable wdt during probe
  2025-03-13 12:14 [PATCH 0/4] Various fixes for the da9052 watchdog Marcus Folkesson
  2025-03-13 12:14 ` [PATCH 1/4] watchdog: da9052_wdt: add support for nowayout Marcus Folkesson
  2025-03-13 12:14 ` [PATCH 2/4] watchdog: da9052_wdt: use timeout value from external inputs Marcus Folkesson
@ 2025-03-13 12:14 ` Marcus Folkesson
  2025-03-14  7:32   ` kernel test robot
  2025-03-13 12:14 ` [PATCH 4/4] watchdog: da9052_wdt: respect TWDMIN Marcus Folkesson
  3 siblings, 1 reply; 6+ messages in thread
From: Marcus Folkesson @ 2025-03-13 12:14 UTC (permalink / raw)
  To: Support Opensource, Wim Van Sebroeck, Guenter Roeck
  Cc: linux-watchdog, linux-kernel, Marcus Folkesson

If the watchog is started by the bootloader, we do not want the watchdog
to be disabled.

Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
---
 drivers/watchdog/da9052_wdt.c | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/drivers/watchdog/da9052_wdt.c b/drivers/watchdog/da9052_wdt.c
index fa9078d4c136a52f1193768fe93dc04189519679..90b620b11b5fb634372e18ce4c40568cd946f284 100644
--- a/drivers/watchdog/da9052_wdt.c
+++ b/drivers/watchdog/da9052_wdt.c
@@ -194,13 +194,6 @@ static int da9052_wdt_probe(struct platform_device *pdev)
 	if (da9052->fault_log & DA9052_FAULTLOG_VDDFAULT)
 		da9052_wdt->bootstatus |= WDIOF_POWERUNDER;
 
-	ret = da9052_reg_update(da9052, DA9052_CONTROL_D_REG,
-				DA9052_CONTROLD_TWDSCALE, 0);
-	if (ret < 0) {
-		dev_err(dev, "Failed to disable watchdog bits, %d\n", ret);
-		return ret;
-	}
-
 	return devm_watchdog_register_device(dev, &driver_data->wdt);
 }
 

-- 
2.48.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 4/4] watchdog: da9052_wdt: respect TWDMIN
  2025-03-13 12:14 [PATCH 0/4] Various fixes for the da9052 watchdog Marcus Folkesson
                   ` (2 preceding siblings ...)
  2025-03-13 12:14 ` [PATCH 3/4] watchdog: da9052_wdt: do not disable wdt during probe Marcus Folkesson
@ 2025-03-13 12:14 ` Marcus Folkesson
  3 siblings, 0 replies; 6+ messages in thread
From: Marcus Folkesson @ 2025-03-13 12:14 UTC (permalink / raw)
  To: Support Opensource, Wim Van Sebroeck, Guenter Roeck
  Cc: linux-watchdog, linux-kernel, Marcus Folkesson

We have to wait at least the minimium time for the watchdog window
(TWDMIN) before writings to the wdt register after the
watchdog is activated.
Otherwise the chip will assert TWD_ERROR and power down to reset mode.

Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
---
 drivers/watchdog/da9052_wdt.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/watchdog/da9052_wdt.c b/drivers/watchdog/da9052_wdt.c
index 90b620b11b5fb634372e18ce4c40568cd946f284..b46338061e7d269adec691f8e88e650e1e2fbfc9 100644
--- a/drivers/watchdog/da9052_wdt.c
+++ b/drivers/watchdog/da9052_wdt.c
@@ -180,6 +180,7 @@ static int da9052_wdt_probe(struct platform_device *pdev)
 	da9052_wdt = &driver_data->wdt;
 
 	da9052_wdt->timeout = DA9052_DEF_TIMEOUT;
+	da9052_wdt->min_hw_heartbeat_ms = DA9052_TWDMIN;
 	da9052_wdt->info = &da9052_wdt_info;
 	da9052_wdt->ops = &da9052_wdt_ops;
 	da9052_wdt->parent = dev;

-- 
2.48.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 3/4] watchdog: da9052_wdt: do not disable wdt during probe
  2025-03-13 12:14 ` [PATCH 3/4] watchdog: da9052_wdt: do not disable wdt during probe Marcus Folkesson
@ 2025-03-14  7:32   ` kernel test robot
  0 siblings, 0 replies; 6+ messages in thread
From: kernel test robot @ 2025-03-14  7:32 UTC (permalink / raw)
  To: Marcus Folkesson, Support Opensource, Wim Van Sebroeck,
	Guenter Roeck
  Cc: llvm, oe-kbuild-all, linux-watchdog, linux-kernel,
	Marcus Folkesson

Hi Marcus,

kernel test robot noticed the following build warnings:

[auto build test WARNING on 0fed89a961ea851945d23cc35beb59d6e56c0964]

url:    https://github.com/intel-lab-lkp/linux/commits/Marcus-Folkesson/watchdog-da9052_wdt-add-support-for-nowayout/20250313-202430
base:   0fed89a961ea851945d23cc35beb59d6e56c0964
patch link:    https://lore.kernel.org/r/20250313-da9052-fixes-v1-3-379dc87af953%40gmail.com
patch subject: [PATCH 3/4] watchdog: da9052_wdt: do not disable wdt during probe
config: riscv-randconfig-001-20250314 (https://download.01.org/0day-ci/archive/20250314/202503141558.tHcAG0Q5-lkp@intel.com/config)
compiler: clang version 19.1.7 (https://github.com/llvm/llvm-project cd708029e0b2869e80abe31ddb175f7c35361f90)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250314/202503141558.tHcAG0Q5-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202503141558.tHcAG0Q5-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> drivers/watchdog/da9052_wdt.c:173:6: warning: unused variable 'ret' [-Wunused-variable]
     173 |         int ret;
         |             ^~~
   1 warning generated.


vim +/ret +173 drivers/watchdog/da9052_wdt.c

664a0d7862a6b10 Ashish Jangam    2012-05-24  165  
664a0d7862a6b10 Ashish Jangam    2012-05-24  166  
2d991a164a61858 Bill Pemberton   2012-11-19  167  static int da9052_wdt_probe(struct platform_device *pdev)
664a0d7862a6b10 Ashish Jangam    2012-05-24  168  {
f7e29623e2678c5 Guenter Roeck    2019-04-08  169  	struct device *dev = &pdev->dev;
f7e29623e2678c5 Guenter Roeck    2019-04-08  170  	struct da9052 *da9052 = dev_get_drvdata(dev->parent);
664a0d7862a6b10 Ashish Jangam    2012-05-24  171  	struct da9052_wdt_data *driver_data;
664a0d7862a6b10 Ashish Jangam    2012-05-24  172  	struct watchdog_device *da9052_wdt;
664a0d7862a6b10 Ashish Jangam    2012-05-24 @173  	int ret;
664a0d7862a6b10 Ashish Jangam    2012-05-24  174  
f7e29623e2678c5 Guenter Roeck    2019-04-08  175  	driver_data = devm_kzalloc(dev, sizeof(*driver_data), GFP_KERNEL);
189c049a01c2de6 Guenter Roeck    2017-01-10  176  	if (!driver_data)
189c049a01c2de6 Guenter Roeck    2017-01-10  177  		return -ENOMEM;
664a0d7862a6b10 Ashish Jangam    2012-05-24  178  	driver_data->da9052 = da9052;
664a0d7862a6b10 Ashish Jangam    2012-05-24  179  
664a0d7862a6b10 Ashish Jangam    2012-05-24  180  	da9052_wdt = &driver_data->wdt;
664a0d7862a6b10 Ashish Jangam    2012-05-24  181  
664a0d7862a6b10 Ashish Jangam    2012-05-24  182  	da9052_wdt->timeout = DA9052_DEF_TIMEOUT;
664a0d7862a6b10 Ashish Jangam    2012-05-24  183  	da9052_wdt->info = &da9052_wdt_info;
664a0d7862a6b10 Ashish Jangam    2012-05-24  184  	da9052_wdt->ops = &da9052_wdt_ops;
f7e29623e2678c5 Guenter Roeck    2019-04-08  185  	da9052_wdt->parent = dev;
664a0d7862a6b10 Ashish Jangam    2012-05-24  186  	watchdog_set_drvdata(da9052_wdt, driver_data);
ebed370e19c893f Marcus Folkesson 2025-03-13  187  	watchdog_init_timeout(da9052_wdt, timeout, dev);
950a7a3375b3d8e Marcus Folkesson 2025-03-13  188  	watchdog_set_nowayout(da9052_wdt, nowayout);
664a0d7862a6b10 Ashish Jangam    2012-05-24  189  
651b5fde35d67a2 Marcus Folkesson 2024-12-10  190  	if (da9052->fault_log & DA9052_FAULTLOG_TWDERROR)
651b5fde35d67a2 Marcus Folkesson 2024-12-10  191  		da9052_wdt->bootstatus |= WDIOF_CARDRESET;
651b5fde35d67a2 Marcus Folkesson 2024-12-10  192  	if (da9052->fault_log & DA9052_FAULTLOG_TEMPOVER)
651b5fde35d67a2 Marcus Folkesson 2024-12-10  193  		da9052_wdt->bootstatus |= WDIOF_OVERHEAT;
651b5fde35d67a2 Marcus Folkesson 2024-12-10  194  	if (da9052->fault_log & DA9052_FAULTLOG_VDDFAULT)
651b5fde35d67a2 Marcus Folkesson 2024-12-10  195  		da9052_wdt->bootstatus |= WDIOF_POWERUNDER;
651b5fde35d67a2 Marcus Folkesson 2024-12-10  196  
60415f701fce001 Wolfram Sang     2019-05-18  197  	return devm_watchdog_register_device(dev, &driver_data->wdt);
664a0d7862a6b10 Ashish Jangam    2012-05-24  198  }
664a0d7862a6b10 Ashish Jangam    2012-05-24  199  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-03-14  7:32 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-13 12:14 [PATCH 0/4] Various fixes for the da9052 watchdog Marcus Folkesson
2025-03-13 12:14 ` [PATCH 1/4] watchdog: da9052_wdt: add support for nowayout Marcus Folkesson
2025-03-13 12:14 ` [PATCH 2/4] watchdog: da9052_wdt: use timeout value from external inputs Marcus Folkesson
2025-03-13 12:14 ` [PATCH 3/4] watchdog: da9052_wdt: do not disable wdt during probe Marcus Folkesson
2025-03-14  7:32   ` kernel test robot
2025-03-13 12:14 ` [PATCH 4/4] watchdog: da9052_wdt: respect TWDMIN Marcus Folkesson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox