Re: [PATCH v8 2/2] rust: add dma coherent allocator abstraction.

Danilo Krummrich
2025-01-09T08:49:54Z

On Thu, Jan 09, 2025 at 09:08:12AM +0100, Christoph Hellwig wrote:
> On Wed, Jan 08, 2025 at 04:21:33PM +0100, Danilo Krummrich wrote:
> > What does "your code" mean? Duplicated in every driver?
>
> Yes, interfaces to the DMA API should stay in readable C code and not
> in weird bindings so that it reminds greppable and maintainable.
>

Rust drivers shouldn't use C APIs directly, but rather use an abstraction of the
corresponding C API.

One reason for that is that some requirements C APIs naturally have, can be
abstracted in a way, that the Rust compiler already ensures certain things and
hence drivers have less potential to produce errors.

(I understand this is very abstract and we can go into details and examples, if
you like.)

So, in the end, Rust drivers would just end up with each of them including a
copy of those abstractions, rather than using the C APIs from all over the place
within the driver.

This wouldn't help with what you ask for, it would just duplicate the "problem".

If you don't feel comfortable maintaining the Rust abstraction (or just don't
want to), that's fine. I don't think anyone expects you to do that, we can take
care of that instead.

From your perspective, I think you can just think of the Rust abstraction as a
single driver calling into the DMA API.