Re: [PATCH] kernel/dma: dma_common_find_pages returns pages for requested address
From: Dima Stepanov
Date: Mon Jan 27 2025 - 12:47:57 EST
On Mon, Jan 27, 2025 at 12:50 PM Robin Murphy <robin.murphy@xxxxxxx> wrote:
>
> No, that's a bug in the caller of dma_mmap_attrs(). As the kerneldoc
> says, cpu_addr/dma_addr/size must still represent the whole buffer as
> returned by the allocator - any offset for the mapping itself relative
> to the start of the buffer is expressed in vma->pgoff.
>
> Thanks,
> Robin.
I see, thanks for clarification Robin. I was confused, because depending
on the backend it will work or not work. But i believe that in this case it is
undefined behavior. That is unfortunate to me, since the idea behind was:
- The memory allocated once because of device/firmware
- Different users could request a part of this memory from the kernel and
mmap it
And i didn't want to expose this offset information to the user. Wanted to
rely on the kernel to mmap the proper part of the buffer.
Thanks,
Dima.