mirror of
https://github.com/linux-msm/laptops-kernel.git
synced 2026-08-13 14:19:53 -07:00
rust: dma: add generalized container for types other than slices
Currently, `CoherentAllocation` is concecptually a DMA coherent container of a slice of `[T]` of runtime-checked length. Generalize it by creating `dma::Coherent<T>` which can hold any value of `T`. `Coherent::alloc_with_attrs` is implemented but not yet exposed, as I believe we should not expose the way to obtain an uninitialized coherent region. `Coherent<[T]>` provides a `len` method instead of the previous `count()` method to be consistent with methods on slices. The existing type is re-defined as a type alias of `Coherent<[T]>` to ease transition. Methods in use are not yet removed. Signed-off-by: Gary Guo <gary@garyguo.net> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Reviewed-by: Alexandre Courbot <acourbot@nvidia.com> Link: https://patch.msgid.link/20260320194626.36263-3-dakr@kernel.org Signed-off-by: Danilo Krummrich <dakr@kernel.org>
This commit is contained in:
committed by
Danilo Krummrich
parent
7ea1a61129
commit
d9aee73c56
@@ -575,7 +575,7 @@ pub struct CoreInternal;
|
||||
/// The bound context indicates that for the entire duration of the lifetime of a [`Device<Bound>`]
|
||||
/// reference, the [`Device`] is guaranteed to be bound to a driver.
|
||||
///
|
||||
/// Some APIs, such as [`dma::CoherentAllocation`] or [`Devres`] rely on the [`Device`] to be bound,
|
||||
/// Some APIs, such as [`dma::Coherent`] or [`Devres`] rely on the [`Device`] to be bound,
|
||||
/// which can be proven with the [`Bound`] device context.
|
||||
///
|
||||
/// Any abstraction that can guarantee a scope where the corresponding bus device is bound, should
|
||||
@@ -584,7 +584,7 @@ pub struct CoreInternal;
|
||||
///
|
||||
/// [`Devres`]: kernel::devres::Devres
|
||||
/// [`Devres::access`]: kernel::devres::Devres::access
|
||||
/// [`dma::CoherentAllocation`]: kernel::dma::CoherentAllocation
|
||||
/// [`dma::Coherent`]: kernel::dma::Coherent
|
||||
pub struct Bound;
|
||||
|
||||
mod private {
|
||||
|
||||
+232
-145
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user