Skip to contentSkip to conversation

watchdog: ma35d1: Add support for MA35D1 Watchdog

PATCH Superseded Zi-Yu Chen 3 participants 9 messages Jul 23 – Jul 24

Subsystems (4)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Zi-Yu Chen

author
#0 lore raw

cover watchdog: ma35d1: Add support for MA35D1 Watchdog

This patch series introduces watchdog timer support for the Nuvoton MA35D1 SoC platform.

The MA35D1 watchdog timer hardware provides a programmable countdown timer capable of triggering a system reset upon timeout expiration or generating an interrupt to wake up the system from low-power states.

Key features supported in this driver:
- Standard watchdog operations (start, stop, ping, set_timeout).
- Boot status detection to identify watchdog reset events (WDIOF_CARDRESET).
- Power management support including suspend/resume and wakeup functionality.

Series breakdown:
- Patch 1: Add DT binding documentation for Nuvoton MA35D1 watchdog.
- Patch 2: Add the watchdog driver implementation for MA35D1.
- Patch 3: Add the watchdog node in the MA35D1 SoC DeviceTree file.

Testing:
- Tested on the Nuvoton MA35D1 development board using standard watchdog test utilities (e.g., watchdog-test from tools/testing/selftests/watchdog).

Zi-Yu Chen (3):
dt-bindings: watchdog: Add MA35D1 Watchdog binding
watchdog: Add Nuvoton MA35D1 watchdog driver support
arm64: dts: nuvoton: Add WDT node for MA35D1 SoC

 .../bindings/watchdog/nuvoton,ma35d1-wdt.yaml |  55 +++
 arch/arm64/boot/dts/nuvoton/ma35d1.dtsi       |   7 +
 drivers/watchdog/Kconfig                      |  11 +
 drivers/watchdog/Makefile                     |   1 +
 drivers/watchdog/ma35d1_wdt.c                 | 357 ++++++++++++++++++
 5 files changed, 431 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/watchdog/nuvoton,ma35d1-wdt.yaml
 create mode 100644 drivers/watchdog/ma35d1_wdt.c
Signature · 1 line
2.34.1
author
#1 lore raw

PATCH 1/3 dt-bindings: watchdog: Add MA35D1 Watchdog binding

Add device tree binding documentation for the watchdog timer (WDT) controller found on Nuvoton MA35D1 SoC.

---
 .../bindings/watchdog/nuvoton,ma35d1-wdt.yaml | 55 +++++++++++++++++++
 1 file changed, 55 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/watchdog/nuvoton,ma35d1-wdt.yaml
Documentation/devicetree/bindings/watchdog/nuvoton,ma35d1-wdt.yaml new file +55 -0
new file mode 100644
index 000000000000..aced7d77a7d3
@@ -0,0 +1,55 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/watchdog/nuvoton,ma35d1-wdt.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Nuvoton MA35D1 Watchdog Timer
+
+maintainers:
+  - Zi-Yu Chen <[email protected]>
+
+allOf:
+  - $ref: watchdog.yaml#
+
+properties:
+  compatible:
+    enum:
+      - nuvoton,ma35d1-wdt
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  clocks:
+    maxItems: 1
+
+  wakeup-source: true
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - clocks
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+    #include <dt-bindings/interrupt-controller/irq.h>
+    #include <dt-bindings/clock/nuvoton,ma35d1-clk.h>
+
+    soc {
+        #address-cells = <2>;
+        #size-cells = <2>;
+        wdt1: watchdog@40440000 {
+          compatible = "nuvoton,ma35d1-wdt";
+          reg = <0x0 0x40440000 0x0 0x100>;
+          interrupts = <GIC_SPI 43 IRQ_TYPE_LEVEL_HIGH>;
+          clocks = <&clk WDT1_GATE>;
+        };
+    };
+...
Signature · 1 line
2.34.1
author
#2 lore raw

PATCH 2/3 watchdog: Add Nuvoton MA35D1 watchdog driver support

In reply to Zi-Yu Chen

Add driver support for the Watchdog Timer (WDT) integrated in Nuvoton MA35D1 SoC. This driver provides standard watchdog functionality, including timeout configuration, ping, and system reset support via the watchdog framework.

---
 drivers/watchdog/Kconfig      |  11 ++
 drivers/watchdog/Makefile     |   1 +
 drivers/watchdog/ma35d1_wdt.c | 357 ++++++++++++++++++++++++++++++++++
 3 files changed, 369 insertions(+)
 create mode 100644 drivers/watchdog/ma35d1_wdt.c
drivers/watchdog/Kconfig +11 -0
index 08cb8612d41f..28d8d3d12c27 100644
@@ -720,6 +720,17 @@ config STMP3XXX_RTC_WATCHDOG
 	  To compile this driver as a module, choose M here: the
 	  module will be called stmp3xxx_rtc_wdt.
 
+config MA35D1_WDT
+	tristate "Nuvoton MA35D1 Watchdog Timer"
+	depends on ARCH_MA35 || COMPILE_TEST
+	select WATCHDOG_CORE
+	select MFD_SYSCON
+	help
+	  Say Y here to include support for the watchdog timer
+	  for the Nuvoton MA35D1 series microprosser.
+	  To compile this driver as a module, choose M here: the
+	  module will be called ma35d1_wdt.
+
 config TS4800_WATCHDOG
 	tristate "TS-4800 Watchdog"
 	depends on HAS_IOMEM && OF
drivers/watchdog/Makefile +1 -0
index bc1d52220f22..a7889eb48c7f 100644
@@ -104,6 +104,7 @@ obj-$(CONFIG_APPLE_WATCHDOG) += apple_wdt.o
 obj-$(CONFIG_SUNPLUS_WATCHDOG) += sunplus_wdt.o
 obj-$(CONFIG_MARVELL_GTI_WDT) += marvell_gti_wdt.o
 obj-$(CONFIG_GUNYAH_WATCHDOG) += gunyah_wdt.o
+obj-$(CONFIG_MA35D1_WDT) += ma35d1_wdt.o
 
 # X86 (i386 + ia64 + x86_64) Architecture
 obj-$(CONFIG_ACQUIRE_WDT) += acquirewdt.o
drivers/watchdog/ma35d1_wdt.c new file +357 -0

357 lines not on this page · raw message

Signature · 1 line
2.34.1
author
#7 lore raw

PATCH 3/3 arm64: dts: nuvoton: Add WDT node for MA35D1 SoC

In reply to Zi-Yu Chen

Add Watchdog Timer (WDT) device node to ma35d1.dtsi.

---
 arch/arm64/boot/dts/nuvoton/ma35d1.dtsi | 7 +++++++
 1 file changed, 7 insertions(+)
arch/arm64/boot/dts/nuvoton/ma35d1.dtsi +7 -0
index 7228ad4735b5..14fd17cfdc5a 100644
@@ -82,6 +82,13 @@ soc {
 		#size-cells = <2>;
 		ranges;
 
+		wdt1: watchdog@40440000 {
+			compatible = "nuvoton,ma35d1-wdt";
+			reg = <0x0 0x40440000 0x0 0x100>;
+			interrupts = <GIC_SPI 43 IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&clk WDT1_GATE>;
+		};
+
 		sys: system-management@40460000 {
 			compatible = "nuvoton,ma35d1-reset", "syscon";
 			reg = <0x0 0x40460000 0x0 0x200>;
Signature · 1 line
2.34.1
#8 lore raw

Re: [PATCH 3/3] arm64: dts: nuvoton: Add WDT node for MA35D1 SoC

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [High] Error check for platform_get_irq() is always false due to u32 type mismatch. - [High] Resource…

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Error check for platform_get_irq() is always false due to u32 type mismatch.
- [High] Resource leak due to missing device-managed variant for wake IRQ setup. --

--- Patch [3]: [PATCH 3/3] arm64: dts: nuvoton: Add WDT node for MA35D1 SoC --- commit c2bd64766eedbf6c5de5bc325d96283f217c6464
Author: Zi-Yu Chen <[email protected]>

arm64: dts: nuvoton: Add WDT node for MA35D1 SoC

Add Watchdog Timer (WDT) device node to ma35d1.dtsi.

arch/arm64/boot/dts/nuvoton/ma35d1.dtsi soc { · line 86

Quoted 10 lines
arch/arm64/boot/dts/nuvoton/ma35d1.dtsi +2 -0
index 7228ad4735b5c..14fd17cfdc5ae 100644
@@ -82,6 +82,13 @@ soc {
 		#size-cells = <2>;
 		ranges;
 
+		wdt1: watchdog@40440000 {
+			compatible = "nuvoton,ma35d1-wdt";

[Severity: High]
Does adding this device node trigger a probe regression if platform_get_irq() returns a negative error code like -EPROBE_DEFER?

Looking at ma35d1_wdt_probe() in drivers/watchdog/ma35d1_wdt.c:

	ma35d1_wdt->irq = platform_get_irq(pdev, 0);
	if (ma35d1_wdt->irq < 0)
		return dev_err_probe(dev, ma35d1_wdt->irq,
				     "failed to get irq\n");

If ma35d1_wdt->irq is a u32, the negative error code is implicitly cast to a large positive number, making the check evaluate to false.

Will this cause probe errors to be ignored and devm_request_irq() to be called with an invalid IRQ number, resulting in -EINVAL and breaking the probe deferral mechanism?

[Severity: High]
Could this also lead to a resource leak when setting the wake IRQ?

Looking further in ma35d1_wdt_probe() in drivers/watchdog/ma35d1_wdt.c:

		ret = dev_pm_set_wake_irq(dev, ma35d1_wdt->irq);
		if (ret)
			return ret;

Since dev_pm_set_wake_irq() is used instead of the device-managed variant devm_pm_set_wake_irq(), and the driver relies on devm_ interfaces without a .remove callback, will the wake IRQ remain attached to the device structure if the driver is unbound or a subsequent probe step fails?

Can this leave a dangling wake IRQ and potentially cause a use-after-free when the device is destroyed?

Quoted 4 lines
arch/arm64/boot/dts/nuvoton/ma35d1.dtsi +4 -0
+			reg = <0x0 0x40440000 0x0 0x100>;
+			interrupts = <GIC_SPI 43 IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&clk WDT1_GATE>;
+		};
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
#3 lore raw

Re: [PATCH 2/3] watchdog: Add Nuvoton MA35D1 watchdog driver support

In reply to Zi-Yu Chen
Thank you for your contribution! Sashiko AI review found 9 potential issue(s) to consider: - [High] The `ma35d1_wdt->dev` pointer is never initialized, leading to NULL pointer dereferences in…

Thank you for your contribution! Sashiko AI review found 9 potential issue(s) to consider:
- [High] The ma35d1_wdt->dev pointer is never initialized, leading to NULL pointer dereferences in logging functions.
- [High] Read-modify-write operations on REG_WDT_CTL inadvertently clear W1C (write-one-to-clear) status flags.
- [High] Missing clock domain synchronization (ma35d1_wdt_wait_sync) after writes to REG_WDT_CTL can lead to dropped register writes.
- [High] Driver overwrites wdt_dev->timeout, breaking the software heartbeat extension.
- [High] Missing cleanup for wake IRQ allocated by dev_pm_set_wake_irq(), leading to a memory leak and permanent device unbind/bind failures.
- [High] The driver fails to check if the watchdog was already enabled by the bootloader, causing unexpected system reboots during boot.
- [Medium] Unsigned integer comparison against zero renders IRQ error handling dead code.
- [Medium] Integer overflow in target_ticks calculation triggers unexpected system resets for large timeouts.
- [Low] Unnecessary dependency: selects MFD_SYSCON without using it.
--

--- Patch [2]: [PATCH 2/3] watchdog: Add Nuvoton MA35D1 watchdog driver support --- commit 3456ece7880176f0928364babfa03dcf9243b968
Author: Zi-Yu Chen <[email protected]>

watchdog: Add Nuvoton MA35D1 watchdog driver support

Add driver support for the Watchdog Timer (WDT) integrated in Nuvoton MA35D1 SoC. This driver provides standard watchdog functionality, including timeout configuration, ping, and system reset support via the watchdog framework.

drivers/watchdog/Kconfig config STMP3XXX_RTC_WATCHDOG · line 727

Quoted 13 lines
drivers/watchdog/Kconfig +5 -0
index 08cb8612d41fe..28d8d3d12c27f 100644
@@ -720,6 +720,17 @@ config STMP3XXX_RTC_WATCHDOG
 	  To compile this driver as a module, choose M here: the
 	  module will be called stmp3xxx_rtc_wdt.
 
+config MA35D1_WDT
+	tristate "Nuvoton MA35D1 Watchdog Timer"
+	depends on ARCH_MA35 || COMPILE_TEST
+	select WATCHDOG_CORE
+	select MFD_SYSCON

[Severity: Low]
Is select MFD_SYSCON necessary here?

The driver maps its MMIO region directly and doesn't appear to use MFD or syscon APIs.

[ ... ]

Quoted 2 lines
drivers/watchdog/ma35d1_wdt.c new file +0 -0

[ ... ]

drivers/watchdog/ma35d1_wdt.c line 114

Quoted 10 lines
drivers/watchdog/ma35d1_wdt.c new file +10 -0
+static int ma35d1_wdt_set_timeout(struct watchdog_device *wdt_dev,
+				  unsigned int timeout)
+{
+	struct ma35d1_wdt_dev *ma35d1_wdt = watchdog_get_drvdata(wdt_dev);
+	unsigned long target_ticks;
+	unsigned int val, i;
+	static const uint8_t toutsel_shifts[] = { 4,  6,  8,  10, 12,
+						  14, 16, 18, 20 };
+
+	target_ticks = (unsigned long)timeout * ma35d1_wdt->clk_rate;

[Severity: Medium]
Can this calculation overflow on 32-bit platforms where unsigned long is 32 bits?

If a user configures a large timeout, timeout * clk_rate might truncate before it can be clamped, resulting in a tiny hardware timeout.

Quoted 5 lines
drivers/watchdog/ma35d1_wdt.c new file +5 -0
+
+	for (i = 0; i < ARRAY_SIZE(toutsel_shifts); i++) {
+		if ((1UL << toutsel_shifts[i]) >= target_ticks)
+			break;
+	}

drivers/watchdog/ma35d1_wdt.c line 129

Quoted 10 lines
drivers/watchdog/ma35d1_wdt.c new file +10 -0
+
+	if (i == ARRAY_SIZE(toutsel_shifts))
+		i = ARRAY_SIZE(toutsel_shifts) - 1;
+
+	scoped_guard(spinlock_irqsave, &ma35d1_wdt->lock) {
+		val = readl_relaxed(ma35d1_wdt->wdt_base + REG_WDT_CTL);
+		val &= ~TOUTSEL;
+		val |= FIELD_PREP(TOUTSEL, i);
+		writel_relaxed(val, ma35d1_wdt->wdt_base + REG_WDT_CTL);
+	}

[Severity: High]
Does this read-modify-write sequence accidentally clear write-one-to-clear status flags like IF, WKF, or RSTF?

Writing back a 1 to these bits when they are concurrently set by hardware would acknowledge and clear them.

drivers/watchdog/ma35d1_wdt.c line 132

Quoted 3 lines
drivers/watchdog/ma35d1_wdt.c new file +3 -0
+
+	/* To avoid truncation errors (0 seconds) during division. */
+	wdt_dev->timeout = (1UL << toutsel_shifts[i]) / ma35d1_wdt->clk_rate;

[Severity: High]
Does overwriting wdt_dev->timeout with the truncated hardware timeout break the software heartbeat extension?

If userspace requests a timeout larger than the hardware maximum, the core delegates to the software ping worker. Modifying wdt_dev->timeout here causes the core to adopt the small timeout instead.

Quoted 16 lines
drivers/watchdog/ma35d1_wdt.c new file +16 -0
+	if (wdt_dev->timeout == 0)
+		wdt_dev->timeout = 1;
+
+	dev_dbg(ma35d1_wdt->dev, "wdt_dev->timeout = %d\n", wdt_dev->timeout);
+
+	return 0;
+}
+
+static int ma35d1_wdt_start(struct watchdog_device *wdt_dev)
+{
+	unsigned int val;
+
+	struct ma35d1_wdt_dev *ma35d1_wdt = watchdog_get_drvdata(wdt_dev);
+	void __iomem *wdt_base = ma35d1_wdt->wdt_base;
+	int ret;
+

drivers/watchdog/ma35d1_wdt.c line 158

Quoted 10 lines
drivers/watchdog/ma35d1_wdt.c new file +10 -0
+	ret = ma35d1_wdt_set_timeout(wdt_dev, wdt_dev->timeout);
+	if (ret < 0)
+		return ret;
+
+	guard(spinlock_irqsave)
+		(&ma35d1_wdt->lock);
+	val = readl_relaxed(wdt_base + REG_WDT_CTL);
+	val |= (WDTEN | RSTEN);
+
+	writel_relaxed(val, wdt_base + REG_WDT_CTL);

[Severity: High]
Can the back-to-back writes to REG_WDT_CTL drop register updates?

ma35d1_wdt_set_timeout() writes to REG_WDT_CTL but doesn't call ma35d1_wdt_wait_sync() afterwards. When ma35d1_wdt_start() immediately writes to REG_WDT_CTL again, it might happen before the synchronization bit clears.

[ ... ]

drivers/watchdog/ma35d1_wdt.c line 201

Quoted 10 lines
drivers/watchdog/ma35d1_wdt.c new file +10 -0
+static int ma35d1_wdt_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct ma35d1_wdt_dev *ma35d1_wdt;
+	unsigned long clk_rate, val;
+	int ret;
+
+	ma35d1_wdt = devm_kzalloc(dev, sizeof(*ma35d1_wdt), GFP_KERNEL);
+	if (!ma35d1_wdt)
+		return -ENOMEM;

[Severity: High]
It looks like ma35d1_wdt->dev is never assigned to dev during probe.

If a synchronization timeout occurs later in ma35d1_wdt_stop(), will dev_err(ma35d1_wdt->dev, ...) dereference this uninitialized pointer?

[ ... ]

drivers/watchdog/ma35d1_wdt.c line 223

Quoted 4 lines
drivers/watchdog/ma35d1_wdt.c new file +4 -0
+	ma35d1_wdt->irq = platform_get_irq(pdev, 0);
+	if (ma35d1_wdt->irq < 0)
+		return dev_err_probe(dev, ma35d1_wdt->irq,
+				     "failed to get irq\n");

[Severity: Medium]
Since the irq field in struct ma35d1_wdt_dev is declared as an unsigned u32, will this < 0 check ever evaluate to true?

If platform_get_irq() returns a negative error code like -ENXIO, the error handling would be skipped and proceed to devm_request_irq() with a huge positive IRQ number.

[ ... ]

drivers/watchdog/ma35d1_wdt.c line 256

Quoted 9 lines
drivers/watchdog/ma35d1_wdt.c new file +9 -0
+	if (device_property_read_bool(dev, "wakeup-source")) {
+		ret = devm_device_init_wakeup(dev);
+		if (ret)
+			return ret;
+
+		ret = dev_pm_set_wake_irq(dev, ma35d1_wdt->irq);
+		if (ret)
+			return ret;
+	}

[Severity: High]
Because the driver uses dev_pm_set_wake_irq() without a devm_ wrapper and lacks a remove function, does this leak the PM wake IRQ structure?

If the driver is unbound and rebound via sysfs, the attached wake IRQ is never cleaned up, which could cause subsequent binds to fail.

[ ... ]

drivers/watchdog/ma35d1_wdt.c line 238

Quoted 7 lines
drivers/watchdog/ma35d1_wdt.c new file +7 -0
+	val = readl_relaxed(ma35d1_wdt->wdt_base + REG_WDT_CTL);
+	if (val & RSTF) {
+		ma35d1_wdt->wdt_dev.bootstatus = WDIOF_CARDRESET;
+		writel_relaxed(val, ma35d1_wdt->wdt_base + REG_WDT_CTL);
+	}
+
+	watchdog_set_drvdata(&ma35d1_wdt->wdt_dev, ma35d1_wdt);

[Severity: High]
Does this code need to check the WDTEN bit to handle a running watchdog handed off by the bootloader?

If the hardware is already ticking and WDOG_HW_RUNNING is not set, the watchdog core won't know to ping the hardware before userspace connects, which could lead to spurious resets during boot.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
maintainer
#4 lore raw

Re: [PATCH 2/3] watchdog: Add Nuvoton MA35D1 watchdog driver support

Quoted 10 lines · On 7/22/26 23:20, [email protected] wrote:

Thank you for your contribution! Sashiko AI review found 9 potential issue(s) to consider:
- [High] The ma35d1_wdt->dev pointer is never initialized, leading to NULL pointer dereferences in logging functions.
- [High] Read-modify-write operations on REG_WDT_CTL inadvertently clear W1C (write-one-to-clear) status flags.
- [High] Missing clock domain synchronization (ma35d1_wdt_wait_sync) after writes to REG_WDT_CTL can lead to dropped register writes.
- [High] Driver overwrites wdt_dev->timeout, breaking the software heartbeat extension.
- [High] Missing cleanup for wake IRQ allocated by dev_pm_set_wake_irq(), leading to a memory leak and permanent device unbind/bind failures.
- [High] The driver fails to check if the watchdog was already enabled by the bootloader, causing unexpected system reboots during boot.
- [Medium] Unsigned integer comparison against zero renders IRQ error handling dead code.
- [Medium] Integer overflow in target_ticks calculation triggers unexpected system resets for large timeouts.
- [Low] Unnecessary dependency: selects MFD_SYSCON without using it.

Please fix or explain why the issues reported by Sashiko are not real.

Thanks,
Guenter

author
#5 lore raw

Re: [PATCH 2/3] watchdog: Add Nuvoton MA35D1 watchdog driver support

Hi Guenter,

Guenter Roeck 於 2026/7/23 下午 10:07 寫道:

Quoted 3 lines · On 7/22/26 23:20, [email protected] wrote:
Quoted 2 lines

Thank you for your contribution! Sashiko AI review found 9 potential issue(s) to consider:
- [High] The ma35d1_wdt->dev pointer is never initialized, leading to NULL pointer dereferences in logging functions.

Fix in v2. Switched to using wdt_dev->parent and direct device pointers for logging functions.Remove redundant ma35d1_wdt->dev>> - [High] Read-modify-write operations on REG_WDT_CTL inadvertently clear W1C (write-one-to-clear) status flags.
Not real.The W1C flags (IF/WKF) are only utilized by PM callbacks during the suspend/resume window for wake-up event handling. During runtime, clearing these flags via RMW in set_timeout causes no functional side-effects. Furthermore, RSTF is already consumed and cleared during probe().>> - [High] Missing clock domain synchronization (ma35d1_wdt_wait_sync) after writes to REG_WDT_CTL can lead to dropped register writes. Fix in v2.Add ma35d1_wdt_wait_sync() after writing WDTEN to REG_WDT_CTL in ma35d1_wdt_start().>> - [High] Driver overwrites wdt_dev->timeout, breaking the software heartbeat extension.
Fix in v2>> - [High] Missing cleanup for wake IRQ allocated by dev_pm_set_wake_irq(), leading to a memory leak and permanent device unbind/bind failures.
Fix in v2.switch to devm_pm_set_wake_irq() in v2.>> - [High] The driver fails to check if the watchdog was already enabled by the bootloader, causing unexpected system reboots during boot.
Fix in v2.Added a check to set WDOG_HW_RUNNING when necessary.>> - [Medium] Unsigned integer comparison against zero renders IRQ error handling dead code.
Fix in v2.Change the IRQ variable type to int in v2 to properly handle negative error codes.>> - [Medium] Integer overflow in target_ticks calculation triggers unexpected system resets for large timeouts.
Fix in v2.Add a check to skip calculation for large timeouts.>> - [Low] Unnecessary dependency: selects MFD_SYSCON without using it.
Fix in v2.remove select MFD_SYSCON.

Quoted 6 lines

Please fix or explain why the issues reported by Sashiko are not real.

Thanks,
Guenter

Regards,
Zi-Yu Chen

author
#6 lore raw

Re: [PATCH 2/3] watchdog: Add Nuvoton MA35D1 watchdog driver support

In reply to Guenter Roeck

Apologies for the broken formatting in my previous email due to a mail client configuration issue. Resending with proper inline formatting:

Guenter Roeck 於 2026/7/23 下午 10:07 寫道:

Quoted 3 lines · On 7/22/26 23:20, [email protected] wrote:
Quoted 2 lines

Thank you for your contribution! Sashiko AI review found 9 potential issue(s) to consider:
- [High] The ma35d1_wdt->dev pointer is never initialized, leading to NULL pointer dereferences in logging functions.

Fix in v2. Switched to using wdt_dev->parent and direct device pointers for logging functions.Remove redundant ma35d1_wdt->dev.

Quoted 1 line
Quoted 1 line

- [High] Read-modify-write operations on REG_WDT_CTL inadvertently clear W1C (write-one-to-clear) status flags.

Not real.The W1C flags (IF/WKF) are only utilized by PM callbacks during the suspend/resume window for wake-up event handling. During runtime, clearing these flags via RMW in set_timeout causes no functional side-effects. Furthermore, RSTF is already consumed and cleared during probe().

Quoted 1 line
Quoted 1 line

- [High] Missing clock domain synchronization (ma35d1_wdt_wait_sync) after writes to REG_WDT_CTL can lead to dropped register writes.

Fix in v2.Add ma35d1_wdt_wait_sync() after writing WDTEN to REG_WDT_CTL in ma35d1_wdt_start().

Quoted 1 line
Quoted 1 line

- [High] Driver overwrites wdt_dev->timeout, breaking the software heartbeat extension.

Fix in v2

Quoted 1 line
Quoted 1 line

- [High] Missing cleanup for wake IRQ allocated by dev_pm_set_wake_irq(), leading to a memory leak and permanent device unbind/bind failures.

Fix in v2.switch to devm_pm_set_wake_irq() in v2.

Quoted 1 line
Quoted 1 line

- [High] The driver fails to check if the watchdog was already enabled by the bootloader, causing unexpected system reboots during boot.

Fix in v2.Added a check to set WDOG_HW_RUNNING when necessary.

Quoted 1 line
Quoted 1 line

- [Medium] Unsigned integer comparison against zero renders IRQ error handling dead code.

Fix in v2.Change the IRQ variable type to int in v2 to properly handle negative error codes.

Quoted 1 line
Quoted 1 line

- [Medium] Integer overflow in target_ticks calculation triggers unexpected system resets for large timeouts.

Fix in v2.Add a check to skip calculation for large timeouts.

Quoted 1 line
Quoted 1 line

- [Low] Unnecessary dependency: selects MFD_SYSCON without using it.

Fix in v2.remove select MFD_SYSCON.

Quoted 6 lines

Please fix or explain why the issues reported by Sashiko are not real.

Thanks,
Guenter

Regards,
Zi-Yu Chen