From: Robin Murphy <robin.murphy@arm.com>
To: Dima Stepanov <dstepanov.src@gmail.com>
Cc: Christoph Hellwig <hch@lst.de>,
Marek Szyprowski <m.szyprowski@samsung.com>,
iommu@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] kernel/dma: dma_common_find_pages returns pages for requested address
Date: Tue, 28 Jan 2025 18:53:27 +0000 [thread overview]
Message-ID: <741c6f7d-e36b-4ddf-a92b-9bbed2ce75c2@arm.com> (raw)
In-Reply-To: <CAEHp+GZRNApNBxznU8YioJO7+ezosKtUmTqaQXe8J6r2QyGjcw@mail.gmail.com>
On 27/01/2025 5:47 pm, Dima Stepanov wrote:
> On Mon, Jan 27, 2025 at 12:50 PM Robin Murphy <robin.murphy@arm.com> 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.
In principle I don't see why you shouldn't be able to create multiple
files representing different parts of one large buffer - seems like the
ops for said files would just need to be a bit cleverer, and remain
aware of the whole buffer as well as the range of their own part within
it. Then they can adjust vma->vm_pgoff accordingly before calling
dma_mmap_*() (and possibly perform their own stricter bounds checking as
well.)
Thanks,
Robin.
next prev parent reply other threads:[~2025-01-28 18:53 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-26 9:09 Dima Stepanov
2025-01-27 11:50 ` Robin Murphy
2025-01-27 17:47 ` Dima Stepanov
2025-01-28 18:53 ` Robin Murphy [this message]
2025-01-29 8:13 ` Dima Stepanov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=741c6f7d-e36b-4ddf-a92b-9bbed2ce75c2@arm.com \
--to=robin.murphy@arm.com \
--cc=dstepanov.src@gmail.com \
--cc=hch@lst.de \
--cc=iommu@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome