[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <D96ATODOGB6O.2JAJOWXMJG3VC@proton.me>
Date: Mon, 14 Apr 2025 10:44:35 +0000
From: Benno Lossin <benno.lossin@...ton.me>
To: Danilo Krummrich <dakr@...nel.org>, bhelgaas@...gle.com, kwilczynski@...nel.org, gregkh@...uxfoundation.org, rafael@...nel.org, abdiel.janulgue@...il.com
Cc: ojeda@...nel.org, alex.gaynor@...il.com, boqun.feng@...il.com, gary@...yguo.net, bjorn3_gh@...tonmail.com, a.hindborg@...nel.org, aliceryhl@...gle.com, tmgross@...ch.edu, daniel.almeida@...labora.com, robin.murphy@....com, linux-pci@...r.kernel.org, rust-for-linux@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 6/9] rust: device: implement Bound device context
On Sun Apr 13, 2025 at 7:37 PM CEST, Danilo Krummrich wrote:
> The Bound device context indicates that a device is bound to a driver.
> It must be used for APIs that require the device to be bound, such as
> Devres or dma::CoherentAllocation.
>
> Implement Bound and add the corresponding Deref hierarchy, as well as the
> corresponding ARef conversion for this device context.
>
> Signed-off-by: Danilo Krummrich <dakr@...nel.org>
One suggestion below, feel free to make it its own patch or fold it into
the correct ones. Also two `::` nits below, with those fixed:
Reviewed-by: Benno Lossin <benno.lossin@...ton.me>
> ---
> rust/kernel/device.rs | 16 +++++++++++++++-
> 1 file changed, 15 insertions(+), 1 deletion(-)
>
> diff --git a/rust/kernel/device.rs b/rust/kernel/device.rs
> index 487211842f77..585a3fcfeea3 100644
> --- a/rust/kernel/device.rs
> +++ b/rust/kernel/device.rs
> @@ -281,7 +287,14 @@ macro_rules! impl_device_context_deref {
> // `__impl_device_context_deref!`.
> kernel::__impl_device_context_deref!(unsafe {
> $device,
> - $crate::device::Core => $crate::device::Normal
> + $crate::device::Core => $crate::device::Bound
> + });
> +
> + // SAFETY: This macro has the exact same safety requirement as
> + // `__impl_device_context_deref!`.
> + kernel::__impl_device_context_deref!(unsafe {
Missing `::`.
> + $device,
> + $crate::device::Bound => $crate::device::Normal
IIUC, all "devices" (so eg `pci::Device`) will use this macro, right? In
that case, I think we can document this behavior a bit better, possibly
on the `DeviceContext` context trait and/or on the different type
states. So on `Core` we could say "The `Core` context is a supercontext
of the [`Bound`] context and devices also expose operations available in
that context while in `Core`." and similarly on `Bound` with `Normal`.
> });
> };
> }
> @@ -304,6 +317,7 @@ fn from(dev: &$device<$src>) -> Self {
> macro_rules! impl_device_context_into_aref {
> ($device:tt) => {
> kernel::__impl_device_context_into_aref!($crate::device::Core, $device);
> + kernel::__impl_device_context_into_aref!($crate::device::Bound, $device);
Missing `::`.
---
Cheers,
Benno
> };
> }
>
Powered by blists - more mailing lists