mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Fil Dunsky <filipp.dunsky@gmail.com>
Cc: Wim Van Sebroeck <wim@linux-watchdog.org>,
	linux-kernel@vger.kernel.org, linux-watchdog@vger.kernel.org,
	Russell King <linux@armlinux.org.uk>,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v6] watchdog: Add ARM TWD (MPCore private) watchdog driver
Date: Fri, 20 Nov 2026 20:35:52 -0800	[thread overview]
Message-ID: <377b89b7-90a3-41c9-88c4-fd3393055f91@roeck-us.net> (raw)
In-Reply-To: <20261118-arm-twd-wdt-v6-1-ce5c85b45c63@gmail.com>

On Wed, Nov 18, 2026 at 07:59:36PM +0300, Fil Dunsky wrote:
> From: Fil Dunsky <filipp.dunsky@gmail.com>
> 
> 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@gmail.com>
> ---
> 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@roeck-us.net/
> 
> 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

  reply	other threads:[~2026-11-21  4:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-18 16:59 Fil Dunsky via B4 Relay
2026-11-21  4:35 ` Guenter Roeck [this message]
2026-11-21 10:29   ` 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=377b89b7-90a3-41c9-88c4-fd3393055f91@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=filipp.dunsky@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=wim@linux-watchdog.org \
    /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

all inboxes | Powered by JetHome®