Re: [PATCH v11 2/3] rust: add dma coherent allocator abstraction.
From: Daniel Almeida
Date: Mon Jan 27 2025 - 06:01:01 EST
>
> You were asked to rename this function because it returns a slice, but
> I wonder if it's better to take an `&mut [T]` argument and to have
> this function copy data into that argument. That way, we could make
> the function itself safe. Perhaps the actual copy needs to be
> volatile?
>
> Well ... I understand that we did this previously and that we want to
> avoid it because it causes too much reading if T is a struct and we
> just want to read one of its fields. How about an API like this?
>
> dma_read!(my_alloc[7].foo)
>
> which expands to something that reads the value of the foo field of
> the 7th element, and
>
> dma_write!(my_alloc[7].foo = 13);
>
> That expands to something that writes 13 to field foo of the 7th element.
>
> Thoughts? I'm proposing this to avoid going in circles between the
> same solutions.
>
> Alice
>
I think I missed something here. How is this any different from the *safe*
functions we currently have?
Anything that involves a copy is basically what we have already, although
your version seems to reduce the amount of data copied from sizeof(T) to
sizeof(T.field)?