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 2/3] rust: reboot: add emergency_restart() wrapper
Date: Thu, 23 Jul 2026 19:15:28 +0300 [thread overview]
Message-ID: <20260723161529.23759-3-iprintercanon@gmail.com> (raw)
In-Reply-To: <20260723161529.23759-1-iprintercanon@gmail.com>
Add a minimal reboot module wrapping emergency_restart(), which
restarts the machine immediately without syncing or unmounting
filesystems.
This is needed by watchdog drivers that must restart the system when
the watchdog expires, such as the Rust software watchdog added in a
subsequent patch. emergency_restart() is safe to call from any
context, including the interrupt context of an expiring timer.
Signed-off-by: Artem Lytkin <iprintercanon@gmail.com>
---
rust/bindings/bindings_helper.h | 1 +
rust/kernel/lib.rs | 1 +
rust/kernel/reboot.rs | 19 +++++++++++++++++++
3 files changed, 21 insertions(+)
create mode 100644 rust/kernel/reboot.rs
diff --git a/rust/bindings/bindings_helper.h b/rust/bindings/bindings_helper.h
index e692d142c8608..89f0e1f65f6d7 100644
--- a/rust/bindings/bindings_helper.h
+++ b/rust/bindings/bindings_helper.h
@@ -81,6 +81,7 @@
#include <linux/property.h>
#include <linux/pwm.h>
#include <linux/random.h>
+#include <linux/reboot.h>
#include <linux/refcount.h>
#include <linux/regulator/consumer.h>
#include <linux/sched.h>
diff --git a/rust/kernel/lib.rs b/rust/kernel/lib.rs
index a1130c4b82881..e603c07dc53dd 100644
--- a/rust/kernel/lib.rs
+++ b/rust/kernel/lib.rs
@@ -113,6 +113,7 @@
#[cfg(CONFIG_RUST_PWM_ABSTRACTIONS)]
pub mod pwm;
pub mod rbtree;
+pub mod reboot;
pub mod regulator;
pub mod revocable;
pub mod safety;
diff --git a/rust/kernel/reboot.rs b/rust/kernel/reboot.rs
new file mode 100644
index 0000000000000..f98a85d19f85d
--- /dev/null
+++ b/rust/kernel/reboot.rs
@@ -0,0 +1,19 @@
+// SPDX-License-Identifier: GPL-2.0
+
+//! Reboot support.
+//!
+//! C header: [`include/linux/reboot.h`](srctree/include/linux/reboot.h).
+
+use crate::bindings;
+
+/// Restarts the machine immediately, without syncing or unmounting
+/// filesystems and without going through the reboot notifier chains.
+///
+/// This is intended for situations where the system is in a state where an
+/// orderly shutdown is no longer possible, for example when a watchdog
+/// expires. It can be called from any context, including interrupt context.
+pub fn emergency_restart() {
+ // SAFETY: `emergency_restart` has no preconditions and is documented as
+ // safe to call from any context.
+ unsafe { bindings::emergency_restart() }
+}
--
2.43.0
next prev parent reply other threads:[~2026-07-23 16:16 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Artem Lytkin [this message]
2026-07-23 16:19 ` [PATCH v2 2/3] rust: reboot: add emergency_restart() wrapper 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-3-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox