News for hackers. Stuff that matters.
Re:Resistance to Rust abstractions for DMA mapping by meltyness on Tuesday February 04, 2025 @08:58AM (#42932374)
Seems like the preferred interface would be a purely functional block that provides the access.

Obviously forcing callers to free means adding lints and docs. Returning borrows leaves the likelihood of entering into explicit lifetimes hell and such in calling code.

A functional interface like (paraphrasing)

  // pub fn apply_op(&mut self, FnMut(&mut T, &bindings::dma_addr_t... ))
Keeps pandora inside the box.
Re:Resistance to Rust abstractions for DMA mapping by Dagonfly on Tuesday February 04, 2025 @09:08AM (#42932499)
As most of the kernel is in C, they probably need a raw pointer quite regularly to pass it into existing C APIs.

Just like `Box::into_raw`, this method shouldn't be used in pure Rust code. It's only available for C FFI.

Re:Resistance to Rust abstractions for DMA mapping by meltyness on Tuesday February 04, 2025 @09:32AM (#42932797)
Right but, this isn't merely FFI code, those are via Bindgen, this is the abstraction intended to be provided to all DMA driver authors as the API, as I understand it.