From: Artem Lytkin <iprintercanon@gmail.com>
To: linux-watchdog@vger.kernel.org, rust-for-linux@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, wim@linux-watchdog.org,
linux@roeck-us.net, ojeda@kernel.org,
miguel.ojeda.sandonis@gmail.com, dakr@kernel.org,
aliceryhl@google.com, a.hindborg@kernel.org, lossin@kernel.org
Subject: [PATCH v2 0/3] rust: add watchdog abstraction and Rust softdog driver
Date: Thu, 23 Jul 2026 19:15:26 +0300 [thread overview]
Message-ID: <20260723161529.23759-1-iprintercanon@gmail.com> (raw)
This series adds Rust abstractions for the watchdog subsystem and a
Rust software watchdog driver functionally equivalent to the core of
the C softdog.
Patch 1 adds the watchdog abstraction: a Device wrapper, an Info
wrapper with option flags, an Options configuration struct, a
#[vtable] WatchdogOps trait with an associated Data type for driver
private data, and a generic Registration that owns the device, the
ops table and the driver data in a single heap allocation.
Patch 2 adds a minimal kernel::reboot module wrapping
emergency_restart(), needed by the softdog driver.
Patch 3 adds the softdog_rs driver: an hrtimer is armed on start and
re-armed on every keepalive ping; if userspace stops pinging, the
timer expires and the system is restarted via emergency_restart().
Changes since v1 [1]:
Most of v2 is a redesign addressing the review feedback from Guenter
(via the Sashiko review [2]), Miguel, and the kernel test robot:
- The ops table is no longer a &'static mut supplied by the driver;
it is built by the abstraction and embedded in the per-device heap
allocation, so multiple device instances need no static mutable
state (Sashiko).
- Driver private data is now supported via an associated Data type;
every callback receives a reference to it (Sashiko).
- Callbacks now take only shared references and Data must be Sync:
the watchdog core does not hold its lock on every callback path
(the first start/ping on open, the reboot notifier stop, and the
stop on unregistration run without it), so exclusive references
would be unsound.
- max_hw_heartbeat_ms is configurable and the stop()-or-heartbeat
registration requirement is documented (Sashiko).
- Removed the Registration::device() accessor that allowed aliasing
with the references used in callbacks (Sashiko).
- stop_on_reboot is now opt-in and rejected with EINVAL for drivers
without stop(); nowayout defaults to CONFIG_WATCHDOG_NOWAYOUT
(Sashiko).
- The watchdog is always stopped on unregistration so no callback can
run after the driver data is freed.
- softdog_rs now actually bites: it arms an hrtimer and calls
emergency_restart() on expiry, instead of relying on the (wrong)
assumption that the core handles expiry (Sashiko).
- Kconfig mutual exclusion fixed to SOFT_WATCHDOG=n; !SOFT_WATCHDOG
still allowed both drivers as modules (Sashiko).
- C helpers marked __rust_helper (Miguel), and updated for the
const-qualified watchdog_active()/watchdog_hw_running().
- Fixed rustfmt and clippy issues reported by the kernel test robot.
- Drivers no longer use raw bindings: added the Info wrapper, the
flags module, and the kernel::reboot module.
- Added the new rust watchdog files to MAINTAINERS.
- Rebased onto current mainline (post-v7.2-rc4).
[1] https://lore.kernel.org/linux-watchdog/20260323195138.5541-1-iprintercanon@gmail.com/
[2] https://sashiko.dev/#/patchset/20260323195138.5541-1-iprintercanon%40gmail.com
Artem Lytkin (3):
rust: watchdog: add watchdog device abstraction
rust: reboot: add emergency_restart() wrapper
watchdog: softdog_rs: add Rust software watchdog driver
MAINTAINERS | 2 +
drivers/watchdog/Kconfig | 12 +
drivers/watchdog/Makefile | 1 +
drivers/watchdog/softdog_rs.rs | 143 +++++++++++
rust/bindings/bindings_helper.h | 2 +
rust/helpers/helpers.c | 1 +
rust/helpers/watchdog.c | 38 +++
rust/kernel/lib.rs | 3 +
rust/kernel/reboot.rs | 19 ++
rust/kernel/watchdog.rs | 522 ++++++++++++++++++++++++++++++++++++++++
10 files changed, 743 insertions(+)
create mode 100644 drivers/watchdog/softdog_rs.rs
create mode 100644 rust/helpers/watchdog.c
create mode 100644 rust/kernel/reboot.rs
create mode 100644 rust/kernel/watchdog.rs
--
2.43.0
next reply other threads:[~2026-07-23 16:15 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-23 16:15 Artem Lytkin [this message]
2026-07-23 16:15 ` [PATCH v2 1/3] rust: watchdog: add watchdog device abstraction Artem Lytkin
2026-07-23 16:30 ` sashiko-bot
2026-07-23 16:15 ` [PATCH v2 2/3] rust: reboot: add emergency_restart() wrapper Artem Lytkin
2026-07-23 16:19 ` sashiko-bot
2026-07-23 16:15 ` [PATCH v2 3/3] watchdog: softdog_rs: add Rust software watchdog driver Artem Lytkin
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=20260723161529.23759-1-iprintercanon@gmail.com \
--to=iprintercanon@gmail.com \
--cc=a.hindborg@kernel.org \
--cc=aliceryhl@google.com \
--cc=dakr@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-watchdog@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=lossin@kernel.org \
--cc=miguel.ojeda.sandonis@gmail.com \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--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 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.