Re: [PATCH 1/2] rust: dma: make use of start_ptr() and start_ptr_mut()

From: Alice Ryhl

Date: Thu Nov 06 2025 - 06:33:31 EST


On Thu, Nov 06, 2025 at 10:44:06AM +0100, Danilo Krummrich wrote:
> On Mon Nov 3, 2025 at 8:06 PM CET, Danilo Krummrich wrote:
> > @@ -576,7 +580,7 @@ pub fn item_from_index(&self, offset: usize) -> Result<*mut T> {
> > // and we've just checked that the range and index is within bounds.
> > // - `offset` can't overflow since it is smaller than `self.count` and we've checked
> > // that `self.count` won't overflow early in the constructor.
> > - Ok(unsafe { self.cpu_addr.add(offset) })
> > + Ok(unsafe { self.start_ptr().cast_mut().add(offset) })
>
> In this specific case start_ptr().cast_mut() is indeed a bit odd, I will use the
> following hunk instead and keep the raw access.
>
> @@ -576,7 +580,7 @@ pub fn item_from_index(&self, offset: usize) -> Result<*mut T> {
> // and we've just checked that the range and index is within bounds.
> // - `offset` can't overflow since it is smaller than `self.count` and we've checked
> // that `self.count` won't overflow early in the constructor.
> - Ok(unsafe { self.cpu_addr.add(offset) })
> + Ok(unsafe { self.cpu_addr.get().add(offset) })

Assuming you got rid of all cast_mut() instances:

Reviewed-by: Alice Ryhl <aliceryhl@xxxxxxxxxx>