All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/3] rust: add watchdog abstraction and Rust softdog driver
@ 2026-07-23 16:15 Artem Lytkin
  2026-07-23 16:15 ` [PATCH v2 1/3] rust: watchdog: add watchdog device abstraction Artem Lytkin
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Artem Lytkin @ 2026-07-23 16:15 UTC (permalink / raw)
  To: linux-watchdog, rust-for-linux
  Cc: linux-kernel, wim, linux, ojeda, miguel.ojeda.sandonis, dakr,
	aliceryhl, a.hindborg, lossin

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-07-23 16:31 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-23 16:15 [PATCH v2 0/3] rust: add watchdog abstraction and Rust softdog driver Artem Lytkin
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

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.