On Mon Jan 19, 2026 at 1:13 PM CET, Gary Guo wrote:
> On Sat Jan 17, 2026 at 2:35 PM GMT, Danilo Krummrich wrote:
>> On Sat Jan 17, 2026 at 3:23 PM CET, Alice Ryhl wrote:
>>> On Sat, Jan 17, 2026 at 01:23:57PM +0000, Alice Ryhl wrote:
>>>> On Fri, Jan 16, 2026 at 03:49:54PM -0600, Timur Tabi wrote:
>>>> > +    pub unsafe fn write_buffer(
>>>> > +        &mut self,
>>>> > +        data: *const u8,
>>>> > +        len: usize,
>>>> > +        offset: usize,
>>>> > +        count: usize,
>>>> > +    ) -> Result {
>>>> 
>>>> Why not this signature?
>>>> 
>>>>    unsafe fn write_raw_slice(&mut self, data: *const [u8]) -> Result;
>>>> 
>>>> You can implement `write_slice` in terms of it.
>>>
>>> To clarify, I think this would be a simpler signature for
>>> `write_buffer()`. And `write_raw_slice()` can be used both for DMA and
>>> to simplify the existing `write_slice`.
>>
>> I.e. you can use it also to create a safe helper for DMA:
>>
>>      fn write_dma(
>>          &mut self,
>>          data: &dma::CoherentAllocation<u8>,
>>          offset: usize,
>>          count: usize
>>      ) -> Result;
>
> Would it make sense to expose a `&CoherentAllocation<u8>` -> `&[Atomic<u8>]`
> conversion method and have a `write_slice(&mut self, data: &[Atomic<[u8]>)` 
> for
> `UserSliceWriter`?

But we don't need any atomic operations for this. Maybe a transparent new type
that only allows access with {read,write}_volatile(), or maybe an UnsafeSlice
type that can provide accessors that internally use *mut [u8] with
{read,write}_volatile().

But for this problem we only need something to eventually pass to
write_slice_raw() which will just use copy_to_user(), so it might be orthogonal.

Reply via email to