From: sashiko-bot@kernel.org
To: "Fil Dunsky" <filipp.dunsky@gmail.com>
Cc: robh@kernel.org, linux-gpio@vger.kernel.org,
linux-watchdog@vger.kernel.org, conor+dt@kernel.org,
devicetree@vger.kernel.org
Subject: Re: [PATCH 07/11] watchdog: Add ARM TWD (MPCore private) watchdog driver
Date: Mon, 12 Oct 2026 17:47:54 +0000 [thread overview]
Message-ID: <sashiko-outbox-168493@kernel.org> (raw)
In-Reply-To: <20261012-b4-cs75xx-s2-v1-7-8a7641b7b79c@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] watchdog: arm_twd_wdt: premature reset due to ignored prescaler update
--
commit f10545beccf6bb20bb2cd3eed188125eef8d1afc
Author: Fil Dunsky <filipp.dunsky@gmail.com>
watchdog: Add ARM TWD (MPCore private) watchdog driver
This commit introduces a watchdog driver for ARM Cortex-A5/A9 and ARM11 MPCore
systems. It programs, pings, and stops the watchdogs of all online CPUs, and
takes over the hardware if it is found already running from the bootloader.
> diff --git a/drivers/watchdog/arm_twd_wdt.c b/drivers/watchdog/arm_twd_wdt.c
> new file mode 100644
> index 0000000000000..1931e9a39655c
> --- /dev/null
> +++ b/drivers/watchdog/arm_twd_wdt.c
[ ... ]
> +static u32 twd_wdt_ticks(struct twd_wdt *wdt, unsigned int secs)
> +{
> + u64 ticks = div_u64((u64)wdt->rate * secs, TWD_WDT_PRESCALE + 1);
[Severity: High]
Does this calculation always match the actual hardware prescaler?
The timeout calculation strictly assumes the prescaler was successfully
updated to TWD_WDT_PRESCALE. If the prescaler update fails, this causes
a huge mismatch in the expected timeout.
> +
> + return min_t(u64, ticks, U32_MAX);
> +}
[ ... ]
> +/* The following run on the CPU whose watchdog they access */
> +static void twd_wdt_cpu_start(void *data)
> +{
> + struct twd_wdt *wdt = data;
> +
> + /*
> + * Load the counter before enabling, it may still be zero. A watchdog
> + * that is already running is reloaded and keeps running, the mode bit
> + * cannot be cleared by writing the control register.
> + */
> + writel(twd_wdt_ticks(wdt, wdt->wdd.timeout), wdt->base + TWD_WDT_LOAD);
> + writel(FIELD_PREP(TWD_WDT_CTRL_PRESCALER, TWD_WDT_PRESCALE) |
> + TWD_WDT_CTRL_WD_MODE | TWD_WDT_CTRL_ENABLE,
> + wdt->base + TWD_WDT_CONTROL);
[Severity: High]
Can this write fail to update the prescaler if the watchdog is already
running?
According to the ARM Cortex-A9 MPCore TRM, writes to the prescaler field in
the Control Register are ignored if the timer is already in watchdog mode.
Since the driver takes over a running watchdog without stopping it first via
the disable keys, the hardware retains the bootloader's prescaler.
If the bootloader set a smaller prescaler (e.g., 0), the timer counts down
much faster than calculated above, leading to a premature system reset
shortly after the driver probes.
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261012-b4-cs75xx-s2-v1-0-8a7641b7b79c@gmail.com?part=7
next prev parent reply other threads:[~2026-10-12 17:47 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-12 17:32 [PATCH 00/11] Cortina Systems CS75xx: interrupt controller, GPIO, I2C and TWD watchdog Fil Dunsky via B4 Relay
2026-10-12 17:32 ` Fil Dunsky
2026-10-12 17:32 ` [PATCH 01/11] dt-bindings: interrupt-controller: Add Cortina Systems CS7542 peripheral interrupt controller Fil Dunsky via B4 Relay
2026-10-12 17:32 ` Fil Dunsky
2026-10-12 17:32 ` [PATCH 02/11] irqchip: Add Cortina Systems CS75xx " Fil Dunsky via B4 Relay
2026-10-12 17:32 ` Fil Dunsky
2026-10-12 17:32 ` [PATCH 03/11] dt-bindings: gpio: Add Cortina Systems CS7542 GPIO controller Fil Dunsky via B4 Relay
2026-10-12 17:32 ` Fil Dunsky
2026-10-12 17:32 ` [PATCH 04/11] gpio: Add Cortina Systems CS75xx GPIO driver Fil Dunsky via B4 Relay
2026-10-12 17:32 ` Fil Dunsky
2026-10-12 17:47 ` sashiko-bot
2026-10-12 20:32 ` Uwe Kleine-König
2026-10-12 20:57 ` Fil Dunsky
2026-10-12 17:33 ` [PATCH 05/11] dt-bindings: i2c: Add Cortina Systems CS7542 I2C controller Fil Dunsky via B4 Relay
2026-10-12 17:33 ` Fil Dunsky
2026-10-12 17:33 ` [PATCH 06/11] i2c: Add Cortina Systems CS75xx I2C controller driver Fil Dunsky via B4 Relay
2026-10-12 17:33 ` Fil Dunsky
2026-10-12 17:46 ` sashiko-bot
2026-10-12 17:33 ` [PATCH 07/11] watchdog: Add ARM TWD (MPCore private) watchdog driver Fil Dunsky via B4 Relay
2026-10-12 17:33 ` Fil Dunsky
2026-10-12 17:47 ` sashiko-bot [this message]
2026-10-12 17:33 ` [PATCH 08/11] ARM: dts: cortina: cs7542: Add interrupt controller, GPIO and I2C Fil Dunsky via B4 Relay
2026-10-12 17:33 ` Fil Dunsky
2026-10-12 17:33 ` [PATCH 09/11] ARM: dts: cortina: almondplus: Add reset button and enable I2C Fil Dunsky via B4 Relay
2026-10-12 17:33 ` Fil Dunsky
2026-10-12 17:33 ` [PATCH 10/11] ARM: multi_v7_defconfig: Enable Cortina Systems CS75xx GPIO, I2C and TWD watchdog Fil Dunsky via B4 Relay
2026-10-12 17:33 ` Fil Dunsky
2026-10-12 17:33 ` [PATCH 11/11] MAINTAINERS: Add Cortina Systems CS75xx interrupt controller, GPIO and I2C Fil Dunsky via B4 Relay
2026-10-12 17:33 ` Fil Dunsky
2026-10-12 18:48 ` [PATCH 00/11] Cortina Systems CS75xx: interrupt controller, GPIO, I2C and TWD watchdog Conor Dooley
2026-10-13 7:10 ` Fil Dunsky
2026-10-13 16:52 ` Conor Dooley
2026-10-13 17:36 ` Fil Dunsky
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-168493@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=filipp.dunsky@gmail.com \
--cc=linux-gpio@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.