From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alvin Sun Date: Thu, 26 Mar 2026 14:52:59 +0800 Subject: [PATCH 06/13] rust: revocable: make LazyRevocable use HazPtrRevocable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260326-b4-tyr-debugfs-v1-6-074badd18716@linux.dev> References: <20260326-b4-tyr-debugfs-v1-0-074badd18716@linux.dev> In-Reply-To: <20260326-b4-tyr-debugfs-v1-0-074badd18716@linux.dev> To: Miguel Ojeda , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Danilo Krummrich , David Airlie , Simona Vetter , Sumit Semwal , =?utf-8?q?Christian_K=C3=B6nig?= , Daniel Almeida Cc: rust-for-linux@vger.kernel.org, dri-devel@lists.freedesktop.org, Alvin Sun X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1774508149; l=2008; i=alvin.sun@linux.dev; s=20260317; h=from:subject:message-id; bh=cVzToFCe33VrJM/WwjDX3rjnBkbQL/Y1ZuE5gIYqw6c=; b=XUnWhjubL8fAm1EhdhBfzPB0BgpmYzDqVT9Ggv0zPFi67X/+spX3TYsl45ghINL+qxdYwIqhB J7TcDDtcpAHBfguI4PE+LMu2O+n0DYVVZgq5ndgkAA7SYS/+cW9Q9Q8 X-Developer-Key: i=alvin.sun@linux.dev; a=ed25519; pk=CHcwQp8GSoj25V/L1ZWNSQjWp9eSIb0s9LKr0Nm3WuE= X-Endpoint-Received: by B4 Relay for alvin.sun@linux.dev/20260317 with auth_id=684 List-Id: B4 Relay Submissions Change LazyRevocable to use the existing HazPtrRevocable backend instead of the RCU-based Revocable. init() now returns HazPtrRevokeHandle and try_access(ctx) forwards to the hazptr-based implementation. Signed-off-by: Alvin Sun --- rust/kernel/revocable.rs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/rust/kernel/revocable.rs b/rust/kernel/revocable.rs index eabb76ce92c43..e974c75a90ec0 100644 --- a/rust/kernel/revocable.rs +++ b/rust/kernel/revocable.rs @@ -421,7 +421,7 @@ fn deref(&self) -> &Self::Target { #[pin_data] pub struct LazyRevocable { #[pin] - once: SetOnce>, + once: SetOnce>, } impl LazyRevocable { @@ -440,18 +440,22 @@ pub const fn new() -> Self { pub fn init>( self: Pin<&Self>, init: impl PinInit, - ) -> Result> { + ) -> Result> { // SAFETY: `once` is structurally pinned. let once = unsafe { self.map_unchecked(|x| &x.once) }; - let revocable = once.pin_init(Revocable::new(init))?; - Ok(RevokeHandle::new(revocable)) + let revocable = once.pin_init(HazPtrRevocable::new(init))?; + Ok(HazPtrRevokeHandle::new(revocable)) } /// Tries to access the revocable wrapped object. /// - /// Returns `None` if the object has not been initialized, or it has been revoked and is therefore no longer accessible. - pub fn try_access(&self) -> Option> { - self.once.as_ref()?.try_access() + /// Returns `None` if the object has not been initialized, or it has been revoked and is + /// therefore no longer accessible. + pub fn try_access<'a>( + &self, + ctx: Pin<&'a mut HazptrCtx>, + ) -> Option> { + self.once.as_ref()?.try_access(ctx) } } -- 2.43.0