From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lj1-f178.google.com (mail-lj1-f178.google.com [209.85.208.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 143704570EA for ; Thu, 23 Jul 2026 16:16:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784823372; cv=none; b=dwSpd94fGiLdTkS2jhgXqPB5GtKnmq6phllT97c6fkn4a34K0FlRbpBX9QikleOWXrgGWen2z7aDD1JADFMc4vbZFW2FmBn+uNLEK+P6kGFMcDv50IaTC/pSqcPZZg0HN+RzghI1Kcas/yEAvZ1I9xMRyFTqdfMlRWjPcClYcng= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784823372; c=relaxed/simple; bh=eAAR8QRYAU5FUSVKssILFt1d8jQIeSkpT5UQzrNNA4k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=reuUC/izznERE4AbqnQxBGdamYeG9ksR0HQ6QTvNcbterJsrkAonOiUhjSm0VqTM2rj8DsN/Yj9/XjNY+VpWs0GySbvp1w/nSqRPBfzVP6+omtMCUNZKVdZtGjklh+btIhuuSfRN85bXkklWw84MM0C3ZRnR76diV1Pvl66P4/0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=PnUV4n3Z; arc=none smtp.client-ip=209.85.208.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PnUV4n3Z" Received: by mail-lj1-f178.google.com with SMTP id 38308e7fff4ca-39c94fccf3eso7249041fa.0 for ; Thu, 23 Jul 2026 09:16:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784823355; x=1785428155; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=3WF4Dbs6zRO0d71RsrP4HchYRm5rd3x9Pi7RivnUfa4=; b=PnUV4n3ZjPgXwvfA/iB0SYwzfhdZ3CzGFiIBm8oGGgiinJ7GyTc4ug6WG7USjcwq57 wMQ+9aEDbhtXEC4NNFemw4jX7D6smXBVKEY/woD87KAIFs8qjwShNh6YnL6ZhBH4Dblb s9sA15bRtq3Tj0hlkAvKtw0GTZN1/AazLTARGuV50ungvPBptovE6tGtUYP2gTizs3mz aJ1UCmQJ7gSMs726fkgzhkG0UEZOSWmPkHW6KEuMUvtLcoSCzmxZHq6WJFp1f83KSVX6 HI59u13xI2V4gSGNhqcoILOqvkAb+eKq++q4OpIWy9hoPV5jwjTdiVnYc9OdfFudVDsT 1gmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784823355; x=1785428155; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=3WF4Dbs6zRO0d71RsrP4HchYRm5rd3x9Pi7RivnUfa4=; b=Tqn1iw/nEvfxrLRSeS9LSSdlOONfxDHbQeU9mkeGTEZK64cch55KNGuXiE4lPeqgqW hE+vJYklkVjYx7MYf4gxmxPGMxK7cXP4QGSXKN2go+x3TwoXepSl0uomMHMryaCD4/4r VEsD0cIK6eL085s1gwSHSGJH1X5zSiBC1dKQ+r7jmcwYyAuFz4br0GNIMq+gr6m0Thg5 kGFvVVnOknkPfes8/CZRW9w9gmiVrRdbgjcJKSBZVvOndyREXRe7FIpl0TTN3dxt0G98 83TfE8+KuaOT1slIl3Pfeom8wwrvkiRfjJwyHp2ol9cqyAph0NhJatIfcdE9XAa09WxR V8/A== X-Gm-Message-State: AOJu0Ywil5o7CRwBZZsXzJDlK0A6WqKel9eaeTEcYgOA1NeR4cFowCsD 6+yEApdKbpaxBIGkozXQz8Mir7wqHtJ+fzMTYgWfMKP0HnOEXbRmbWAg X-Gm-Gg: AR+sD13v4q8nhPSyUglzLxN44HN8YFJBdHrjs8eUKaS63dMHoxQqJP88xqLVganUBze ONDy7Of8CLhNcCUHmljfOGlPSzHGIIq+m8Sp+bmvj+H2Muc/t0rkL6QLNDCccXAzKlR6MeiOOyx unZF+TQamLPcGz6Dzo7Y3afjslM6V7vqqGC9r27+sa7aQj1TbytNxw+Em3/ieU3ygFWqzSYAi+N hnkWVAx2fKp5EvhMlG0phm9cLRNTcHRM6IxxQ/nBGWvmWEGpNOJ2F2opi2t2860KwPeNqkvAfzR wNy11v+7rTMyXs2lCRtvJNqBLK4Bre4n8WqFXukzrT2D+M2b5DXoWnqysq6ieTiUK6xUJUtwdT1 UtQWHrhPtFJmCoi5JYaq7i1w1ePUlB4ZmGYPapaFe+NPl4ljMGyTk9BNpXxI8PTkYT4gWRR3dRE tCtUQKgsdKkbo8syM8Bm4WTcooVY5p+B9vkR2lErIV2hlZAz77I5KYFgDUnc6mFu5CQWj/Xg/P4 n+A5aa5tFf+Rcs= X-Received: by 2002:a2e:a588:0:b0:39b:1b6d:5027 with SMTP id 38308e7fff4ca-39f07c70ba8mr7958461fa.11.1784823354940; Thu, 23 Jul 2026 09:15:54 -0700 (PDT) Received: from localhost.localdomain (46-138-176-102.dynamic.spd-mgts.ru. [46.138.176.102]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-39ef6d8c40fsm9875561fa.41.2026.07.23.09.15.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jul 2026 09:15:54 -0700 (PDT) From: Artem Lytkin 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 Message-ID: <20260723161529.23759-3-iprintercanon@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260723161529.23759-1-iprintercanon@gmail.com> References: <20260723161529.23759-1-iprintercanon@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- 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 #include #include +#include #include #include #include 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