Linux Watchdog driver development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Antonio Borneo" <antonio.borneo@foss.st.com>,
	devicetree@vger.kernel.org
Cc: linux-watchdog@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v3 02/13] watchdog: stm32_iwdg: detect whether the watchdog is running
Date: Fri, 06 Nov 2026 17:05:34 +0000	[thread overview]
Message-ID: <sashiko-outbox-201895@kernel.org> (raw)
In-Reply-To: <20261106163429.618392-3-antonio.borneo@foss.st.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] watchdog: stm32_iwdg: unconfigured timeout in
  stm32_iwdg_probe()
- [Medium] watchdog: stm32_iwdg: WDOG_HW_RUNNING gated on Kconfig in
  stm32_iwdg_probe()
--

commit 7c2acc17f93336becc29a7a139de848c3db25624
Author: Clément Le Goffic <clement.legoffic@foss.st.com>

watchdog: stm32_iwdg: detect whether the watchdog is running

This commit adds stm32_iwdg_is_running() to detect whether the watchdog
was already started by an earlier boot stage and sets WDOG_HW_RUNNING in
stm32_iwdg_probe() only when it is running.

[Severity: High]
In drivers/watchdog/stm32_iwdg.c at line 394 in stm32_iwdg_probe(), does
removing the call to stm32_iwdg_start(wdd) leave the hardware prescaler
(IWDG_PR), reload value (IWDG_RLR), and early-wakeup interrupt
(IWDG_EWCR) registers out of sync with wdd->timeout and wdd->pretimeout?

When stm32_iwdg_is_running(wdt) returns true, stm32_iwdg_probe() now sets
WDOG_HW_RUNNING without programming wdd->timeout into the hardware or
reading the bootloader's configured timeout back into wdd->timeout.
Because stm32_iwdg_ops provides stm32_iwdg_ping() (line 162), which only
writes KR_KEY_RELOAD to IWDG_KR, the watchdog core's keepalive worker
schedules pings at half of wdd->timeout while reloading the bootloader's
counter value. If the bootloader configured a hardware timeout shorter
than wdd->timeout / 2, the watchdog expires and resets the system before
the next keepalive ping. Even after userspace opens /dev/watchdog,
watchdog_start() in drivers/watchdog/watchdog_dev.c (line 261) sees both
WDOG_HW_RUNNING and wdd->ops->ping set and calls __watchdog_ping(wdd)
instead of wdd->ops->start(wdd), leaving IWDG_PR, IWDG_RLR, and IWDG_EWCR
unconfigured.

[Severity: Medium]
In drivers/watchdog/stm32_iwdg.c at line 394 in stm32_iwdg_probe(),
should setting WDOG_HW_RUNNING be unconditional when
stm32_iwdg_is_running(wdt) is true, rather than gated on
IS_ENABLED(CONFIG_WATCHDOG_HANDLE_BOOT_ENABLED)?

In drivers/watchdog/watchdog_dev.c at line 1099 in
watchdog_cdev_register(), the watchdog core checks watchdog_hw_running()
to pin the module and device references and to evaluate the runtime
watchdog.handle_boot_enabled parameter. Gating the check on
IS_ENABLED(CONFIG_WATCHDOG_HANDLE_BOOT_ENABLED) in the driver prevents
the core from knowing the hardware is active when
CONFIG_WATCHDOG_HANDLE_BOOT_ENABLED=n, breaking the
watchdog.handle_boot_enabled=1 kernel command-line override and skipping
the module/device reference pinning.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261106163429.618392-1-antonio.borneo@foss.st.com?part=2

  reply	other threads:[~2026-11-06 17:05 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-06 16:34 [PATCH v3 00/13] Update watchdogs support on STM32MP platforms Antonio Borneo
2026-11-06 16:34 ` [PATCH v3 01/13] watchdog: stm32_iwdg: get hardware version during probe Antonio Borneo
2026-11-06 16:34 ` [PATCH v3 02/13] watchdog: stm32_iwdg: detect whether the watchdog is running Antonio Borneo
2026-11-06 17:05   ` sashiko-bot [this message]
2026-11-08 17:56     ` Guenter Roeck
2026-11-09 11:27       ` Antonio Borneo
2026-11-06 16:34 ` [PATCH v3 03/13] watchdog: stm32_iwdg: add pretimeout support for iwdg v4.0 Antonio Borneo
2026-11-06 17:11   ` sashiko-bot
2026-11-06 16:34 ` [PATCH v3 04/13] ARM: stm32: enable arm smc watchdog on stm32mp1xx Antonio Borneo
2026-11-06 17:19   ` sashiko-bot
2026-11-06 22:18     ` Guenter Roeck
2026-11-09 10:32       ` Antonio Borneo
2026-11-06 16:34 ` [PATCH v3 05/13] ARM: dts: stm32: add iwdg1 node on stm32mp151 SoC Antonio Borneo
2026-11-06 17:29   ` sashiko-bot
2026-11-06 16:34 ` [PATCH v3 06/13] ARM: dts: stm32: enable iwdg1 on stm32mp15x ST boards Antonio Borneo
2026-11-06 16:34 ` [PATCH v3 07/13] ARM: dts: stm32: move arm smc watchdog to stm32mp151 SoC Antonio Borneo
2026-11-06 16:34 ` [PATCH v3 08/13] ARM: dts: stm32: enable arm smc watchdog on stm32mp15x scmi boards Antonio Borneo
2026-11-06 17:51   ` sashiko-bot
2026-11-06 16:34 ` [PATCH v3 09/13] ARM: dts: stm32: add watchdog0 alias on ST stm32mp1xx boards Antonio Borneo
2026-11-06 16:34 ` [PATCH v3 10/13] arm64: dts: st: add iwdg1 and iwdg2 support to stm32mp211 Antonio Borneo
2026-11-06 18:02   ` sashiko-bot
2026-11-06 16:34 ` [PATCH v3 11/13] arm64: dts: st: add iwdg1 and iwdg2 support to stm32mp231 Antonio Borneo
2026-11-06 18:13   ` sashiko-bot
2026-11-06 16:34 ` [PATCH v3 12/13] arm64: dts: st: add iwdg1 and iwdg2 support to stm32mp251 Antonio Borneo
2026-11-06 16:34 ` [PATCH v3 13/13] arm64: dts: st: enable iwdg2 on stm32mp2xx ST boards Antonio Borneo
2026-11-06 18:24   ` sashiko-bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-201895@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=antonio.borneo@foss.st.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox