Re: [PATCH v6] watchdog: Add ARM TWD (MPCore private) watchdog driver
From: Guenter Roeck
Date: Fri Nov 20 2026 - 23:35:59 EST
On Wed, Nov 18, 2026 at 07:59:36PM +0300, Fil Dunsky wrote:
> From: Fil Dunsky <filipp.dunsky@xxxxxxxxx>
>
> ARM11 MPCore, Cortex-A5 and Cortex-A9 MPCore systems have a watchdog
> next to the local timer of every CPU, banked at the same address. The
> binding "arm,cortex-a9-twd-wdt" exists, but there has been no driver
> since mpcore_wdt was removed in v3.11, among other reasons because it
> only ever programmed the CPU that ran the ioctl.
>
> Use the watchdog of CPU0 as the system watchdog: start, stop, ping and
> get_timeleft run there through smp_call_function_single(). CPU0 cannot
> be taken offline on 32-bit ARM unless the platform allows it, the driver
> does not probe then. The watchdogs of the other CPUs are left alone. The
> watchdog is used in reset mode only, its interrupt is not needed.
>
> Bootloaders such as the one of the Securifi Almond+ start the watchdog
> before booting the kernel. A running watchdog is marked WDOG_HW_RUNNING
> and taken over with the driver's timeout without being stopped, unless
> it runs with a different prescaler: the prescaler cannot be changed in
> watchdog mode. Once the watchdog mode is set it can only be left through
> the disable register sequence, which is what stop does.
>
> The TWD clock follows the CPU clock on many systems, so rate changes are
> followed through a clock notifier. If CPU0 lost its watchdog in a deep
> idle state it is set up again on CPU PM exit, and on resume from
> suspend. The expiration time is kept atomically and the watchdog is
> always loaded with the time left until it, so neither path extends the
> timeout. Timeout changes are serialized with the clock notifier, and the
> expiration time is published before the CPU PM notifier can see the
> watchdog as armed.
>
> The watchdog is also registered as a restart handler with the default
> priority, for systems that have no other way to restart: the CPU that
> restarts the system, the only one left running, lets its own watchdog
> expire right away.
>
> Signed-off-by: Fil Dunsky <filipp.dunsky@xxxxxxxxx>
> ---
> ARM11 MPCore, Cortex-A5 and Cortex-A9 MPCore systems have a watchdog next
> to the local timer of every CPU. The binding "arm,cortex-a9-twd-wdt"
> (watchdog/arm,twd-wdt.yaml) exists and 15 dts/dtsi files describe the
> device, but there has been no driver since mpcore_wdt was removed in
> v3.11 ("watchdog: delete mpcore_wdt driver").
>
> As discussed on v4, this version uses the watchdog of CPU0 only, as the
> system watchdog. CPU0 cannot be taken offline on 32-bit ARM unless the
> platform allows it, and the driver does not probe then. The watchdogs of
> the other CPUs are not touched.
>
> The driver was written for the Cortina Systems CS75xx / Securifi Almond+,
> whose boot loader arms the watchdog of CPU0: the board resets ~300 s
> after boot unless it is serviced. The driver also registers a restart
> handler with the default (last resort) priority, since the CS75xx
> platform has no other way to restart.
>
> This revision was tested on a Securifi Almond+ (Cortex-A9, two CPUs)
> with PROVE_LOCKING: takeover of the running watchdog; watchdog ioctls
> issued from CPU1; reducing the timeout from 60 to 30 seconds after 35
> seconds without a ping; keepalives for 60 seconds followed by expiration
> and a reset; reboot(2) issued from CPU1 through the restart handler.
> Both runs returned to OpenWrt without lockdep warnings. GCC and Clang
> W=1 builds and host regression tests of deadline handling also pass.
> CPU hotplug, CPU PM and suspend were not tested: the platform has no
> support for them. The deadline regression tests simulate time and CPU PM
> interleaving; they do not replace testing on hardware with CPU PM.
>
> The v6 changes address the five issues in the review confirmed by Guenter:
> https://lore.kernel.org/all/71aafc99-b3c4-4d4c-b468-086dde709b71@xxxxxxxxxxxx/
>
> Open questions:
>
> 1. The binding marks clocks as optional, the driver requires them (the
> rate is needed to compute the timeout). Should the binding be
> tightened, or should the driver fall back to something when there is
> no clock? Several of the existing dts files have no clocks property;
> the driver does not probe there.
"something" is a bit vague. One possibility might be to try cpufreq
functions (cpufreq_get / cpufreq_register_notifier) as fallback.
> 2. Is a separate MAINTAINERS entry for this driver the right thing, or
> should it only be covered by the watchdog subsystem entry?
A MAINTAINERS entry would be preferred, but is not mandatory.
Regarding the issue raised by Sashiko:
Does calling watchdog_stop_ping_on_suspend() cause wdt->expires to be
overwritten with a full timeout on suspend and resume instead of preserving
the saved deadline?
I think we can call that on purpose. Maybe add a comment along that line
into the code to clarify that.
Thanks,
Guenter