[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aAEaubIVd9XDflxc@cassiopeiae>
Date: Thu, 17 Apr 2025 17:14:01 +0200
From: Danilo Krummrich <dakr@...nel.org>
To: 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, benno.lossin@...ton.me,
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 0/9] Implement "Bound" device context
On Sun, Apr 13, 2025 at 07:36:55PM +0200, Danilo Krummrich wrote:
> Currently, we do not ensure that APIs that require a bound device instance can
> only be called with a bound device.
>
> Examples of such APIs are Devres, dma::CoherentAllocation and
> pci::Device::iomap_region().
>
> This patch series introduces the "Bound" device context such that we can ensure
> to only ever pass a bound device to APIs that require this precondition.
>
> In order to get there, we need some prerequisites:
>
> (1) Implement macros to consistently derive Deref implementations for the
> different device contexts. For instance, Device<Core> can be dereferenced to
> Device<Bound>, since all device references we get from "core" bus callbacks
> are guaranteed to be from a bound device. Device<Bound> can always be
> dereferenced to Device (i.e. Device<Normal>), since the "Normal" device
> context has no specific requirements.
>
> (2) Implement device context support for the generic Device type. Some APIs such
> as Devres and dma::CoherentAllocation work with generic devices.
>
> (3) Preserve device context generics in bus specific device' AsRef
> implementation, such that we can derive the device context when converting
> from a bus specific device reference to a generic device reference.
>
> With this, Devres::new(), for instance, can take a &Device<Bound> argument and
> hence ensure that it can't be called with a Device reference that is not
> guaranteed to be bound to a driver.
>
> A branch containing the patches can be found in [1].
>
> [1] https://web.git.kernel.org/pub/scm/linux/kernel/git/dakr/linux.git/log/?h=rust/device-bound
With the following changes, applied to driver-core/topic/device-context, thanks!
* Add missing `::` prefix in macros.
* Fix typos pointed out by Bjorn.
- Danilo
Powered by blists - more mailing lists