[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aEAUlvPbX9vFWhdI@google.com>
Date: Wed, 4 Jun 2025 09:40:38 +0000
From: Alice Ryhl <aliceryhl@...gle.com>
To: Christian Schrefl <chrisi.schrefl@...il.com>
Cc: Benno Lossin <lossin@...nel.org>, Miguel Ojeda <ojeda@...nel.org>,
Danilo Krummrich <dakr@...nel.org>, Alex Gaynor <alex.gaynor@...il.com>,
Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>,
"Björn Roy Baron" <bjorn3_gh@...tonmail.com>, Andreas Hindborg <a.hindborg@...nel.org>,
Trevor Gross <tmgross@...ch.edu>, Arnd Bergmann <arnd@...db.de>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>, Lee Jones <lee@...nel.org>,
Daniel Almeida <daniel.almeida@...labora.com>,
"Gerald Wisböck" <gerald.wisboeck@...ther.ink>, rust-for-linux@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v4 2/3] rust: miscdevice: add additional data to MiscDeviceRegistration
On Mon, Jun 02, 2025 at 11:16:33PM +0200, Christian Schrefl wrote:
> On 31.05.25 2:23 PM, Benno Lossin wrote:
> > On Fri May 30, 2025 at 10:46 PM CEST, Christian Schrefl wrote:
> >> + unsafe { core::ptr::drop_in_place(self.data.get()) };
> >> }
> >> }
> >>
> >> @@ -109,6 +135,13 @@ pub trait MiscDevice: Sized {
> >> /// What kind of pointer should `Self` be wrapped in.
> >> type Ptr: ForeignOwnable + Send + Sync;
> >>
> >> + /// The additional data carried by the [`MiscDeviceRegistration`] for this [`MiscDevice`].
> >> + /// If no additional data is required than the unit type `()` should be used.
> >> + ///
> >> + /// This data can be accessed in [`MiscDevice::open()`] using
> >> + /// [`MiscDeviceRegistration::data()`].
> >> + type RegistrationData: Sync;
> >
> > Why do we require `Sync` here?
>
> Needed for `MiscDeviceRegistration` to be `Send`, see response above.
Even if `MiscDeviceRegistration` is non-Send, the registration data must
still be Sync. The f_ops->open callback can *always* be called from any
thread no matter what we do here, so the data it gives you access must
always be Sync no matter what.
Alice
Powered by blists - more mailing lists