From: sashiko-bot@kernel.org
To: "Fil Dunsky" <filipp.dunsky@gmail.com>
Cc: devicetree@vger.kernel.org, linux-gpio@vger.kernel.org,
linux-watchdog@vger.kernel.org, robh@kernel.org,
conor+dt@kernel.org
Subject: Re: [PATCH v2 07/11] watchdog: Add ARM TWD (MPCore private) watchdog driver
Date: Tue, 13 Oct 2026 04:10:37 +0000 [thread overview]
Message-ID: <sashiko-outbox-168963@kernel.org> (raw)
In-Reply-To: <20261013-b4-cs75xx-s2-v2-7-94f8c0a90cda@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] watchdog: arm_twd_wdt: stale clock rate causes spurious reboots
- [Medium] watchdog: arm_twd_wdt: boot CPU watchdog fails to restart after resume
--
commit 6655d83c448f4cf87494cf40f7b8891a218a895c
Author: Fil Dunsky <filipp.dunsky@gmail.com>
watchdog: Add ARM TWD (MPCore private) watchdog driver
ARM11 MPCore, Cortex-A5 and Cortex-A9 MPCore systems have a watchdog next to
the local timer of every CPU. This commit adds a driver to program, ping,
and stop the watchdogs of all online CPUs together.
> diff --git a/drivers/watchdog/arm_twd_wdt.c b/drivers/watchdog/arm_twd_wdt.c
> new file mode 100644
> index 0000000000000..a582234e3d953
> --- /dev/null
> +++ b/drivers/watchdog/arm_twd_wdt.c
> @@ -0,0 +1,395 @@
[ ... ]
> +static u32 twd_wdt_ticks(struct twd_wdt *wdt, unsigned int secs)
> +{
> + u64 ticks = div_u64((u64)wdt->rate * secs, TWD_WDT_PRESCALE + 1);
> +
> + return min_t(u64, ticks, U32_MAX);
> +}
[Severity: High]
Does this calculation use a stale clock rate if the CPU frequency scales up?
The ARM TWD clock is tied to the CPU frequency on many MPCore systems. If
the CPU scales up its frequency via cpufreq, the actual clock rate will be
higher than the cached wdt->rate.
Could this result in computing too few ticks for the requested timeout,
leading to a premature expiration and spurious system reboots?
[ ... ]
> +static void twd_wdt_cpu_ping(void *data)
> +{
> + struct twd_wdt *wdt = data;
> +
> + /* In watchdog mode a write to the load register reloads the counter */
> + writel(twd_wdt_ticks(wdt, wdt->wdd.timeout), wdt->base + TWD_WDT_LOAD);
> +}
[Severity: Medium]
The ping function only writes to the LOAD register. If the system resumes
from suspend-to-RAM, the watchdog core's ping worker will invoke this
method. Since it does not restore the CONTROL register, will the boot
CPU's watchdog silently remain disabled after power loss?
[ ... ]
> +static int twd_wdt_probe(struct platform_device *pdev)
> +{
> + struct device *dev = &pdev->dev;
> + struct twd_wdt *wdt;
> + struct clk *clk;
[ ... ]
> + clk = devm_clk_get_enabled(dev, NULL);
> + if (IS_ERR(clk))
> + return dev_err_probe(dev, PTR_ERR(clk), "failed to get clock\n");
> +
> + wdt->rate = clk_get_rate(clk);
[Severity: High]
The clock rate is cached statically during probe. Since the clk pointer is
not saved, does this prevent dynamic rate updates if the CPU frequency
changes via cpufreq without modifying the driver?
> + if (!wdt->rate)
> + return dev_err_probe(dev, -EINVAL, "clock rate is zero\n");
[ ... ]
> +static struct platform_driver twd_wdt_driver = {
> + .probe = twd_wdt_probe,
> + .driver = {
> + .name = "arm-twd-wdt",
> + .of_match_table = twd_wdt_of_match,
> + },
> +};
[Severity: Medium]
This platform driver appears to lack a .pm field or syscore_ops.
During system suspend, the TWD block loses power and its CONTROL register
is cleared. While non-boot CPUs are hotplugged and restart their watchdogs
via the online hook, the boot CPU is not hotplugged.
Does this mean the boot CPU's watchdog state is never restored after resume?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261013-b4-cs75xx-s2-v2-0-94f8c0a90cda@gmail.com?part=7
next prev parent reply other threads:[~2026-10-13 4:10 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-13 3:46 [PATCH v2 00/11] Cortina Systems CS75xx: interrupt controller, GPIO, I2C and TWD watchdog Fil Dunsky via B4 Relay
2026-10-13 3:46 ` [PATCH v2 01/11] dt-bindings: interrupt-controller: Add Cortina Systems CS7542 peripheral interrupt controller Fil Dunsky via B4 Relay
2026-10-13 3:47 ` [PATCH v2 02/11] irqchip: Add Cortina Systems CS75xx " Fil Dunsky via B4 Relay
2026-10-13 3:47 ` [PATCH v2 03/11] dt-bindings: gpio: Add Cortina Systems CS7542 GPIO controller Fil Dunsky via B4 Relay
2026-10-13 3:53 ` sashiko-bot
2026-10-13 3:47 ` [PATCH v2 04/11] gpio: Add Cortina Systems CS75xx GPIO driver Fil Dunsky via B4 Relay
2026-10-13 3:58 ` sashiko-bot
2026-10-13 3:47 ` [PATCH v2 05/11] dt-bindings: i2c: Add Cortina Systems CS7542 I2C controller Fil Dunsky via B4 Relay
2026-10-13 3:47 ` [PATCH v2 06/11] i2c: Add Cortina Systems CS75xx I2C controller driver Fil Dunsky via B4 Relay
2026-10-13 4:04 ` sashiko-bot
2026-10-13 3:47 ` [PATCH v2 07/11] watchdog: Add ARM TWD (MPCore private) watchdog driver Fil Dunsky via B4 Relay
2026-10-13 4:10 ` sashiko-bot [this message]
2026-10-13 3:47 ` [PATCH v2 08/11] ARM: dts: cortina: cs7542: Add interrupt controller, GPIO and I2C Fil Dunsky via B4 Relay
2026-10-13 3:47 ` [PATCH v2 09/11] ARM: dts: cortina: almondplus: Add reset button and enable I2C Fil Dunsky via B4 Relay
2026-10-13 3:47 ` [PATCH v2 10/11] ARM: multi_v7_defconfig: Enable Cortina Systems CS75xx GPIO, I2C and TWD watchdog Fil Dunsky via B4 Relay
2026-10-13 6:13 ` Krzysztof Kozlowski
2026-10-13 6:19 ` Fil Dunsky
2026-10-13 3:47 ` [PATCH v2 11/11] MAINTAINERS: Add Cortina Systems CS75xx interrupt controller, GPIO and I2C Fil Dunsky via B4 Relay
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-168963@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox