From: Alvin Sun Date: Sun, 22 Nov 2026 20:50:22 +0800 Subject: [PATCH v7 03/10] rust: sync: arc: relax `ForeignOwnable` for `Arc` MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261122-tyr-ioctls-v7-3-3a2af624b992@linux.dev> References: <20261122-tyr-ioctls-v7-0-3a2af624b992@linux.dev> In-Reply-To: <20261122-tyr-ioctls-v7-0-3a2af624b992@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 , Daniel Almeida , Tamir Duberstein , Alexandre Courbot , =?utf-8?q?Onur_=C3=96zkan?= , Lyude Paul , David Airlie , Simona Vetter , Greg Kroah-Hartman , "Rafael J. Wysocki" , Johan Hovold Cc: Sami Tolvanen , rust-for-linux@vger.kernel.org, dri-devel@lists.freedesktop.org, driver-core@lists.linux.dev, Ke Sun , Alvin Sun X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1795352551; l=1389; i=alvin.sun@linux.dev; s=20260317; h=from:subject:message-id; bh=E65clxOu/qjNbqNDrRBBfaWHB/W/gvw7JStoVkgnAT4=; b=rgqWPnwJKctrGwdGQetlNd7KUGuTt9snjiLGs9rkxFX/uZ/s3JYn/fIkl14xeCpDuIU7Q8DR5 eMSwt09EjANBaVP8yqR/RkhcttZ+pW2Vok26yhRejB435C/8rQim/oy 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 Drop the `'static` bound so that refcounted values borrowing from a driver registration scope can be foreign-owned by the XArray abstraction. Signed-off-by: Alvin Sun Reviewed-by: Daniel Almeida Reviewed-by: Gary Guo --- rust/kernel/sync/arc.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/rust/kernel/sync/arc.rs b/rust/kernel/sync/arc.rs index 8ae0fe6f19ec0..9b582a815f888 100644 --- a/rust/kernel/sync/arc.rs +++ b/rust/kernel/sync/arc.rs @@ -363,11 +363,17 @@ pub fn into_unique_or_drop(this: Self) -> Option>> { // SAFETY: The pointer returned by `into_foreign` was originally allocated as an // `KBox>`, so that type is what determines the alignment. -unsafe impl ForeignOwnable for Arc { +unsafe impl ForeignOwnable for Arc { const FOREIGN_ALIGN: usize = > as ForeignOwnable>::FOREIGN_ALIGN; - type Borrowed<'a> = ArcBorrow<'a, T>; - type BorrowedMut<'a> = Self::Borrowed<'a>; + type Borrowed<'a> + = ArcBorrow<'a, T> + where + T: 'a; + type BorrowedMut<'a> + = Self::Borrowed<'a> + where + T: 'a; fn into_foreign(self) -> *mut c_void { ManuallyDrop::new(self).ptr.as_ptr().cast() -- 2.43.0