From: Robin Murphy <robin.murphy@arm.com>
To: Pankaj Suryawanshi <pankajssuryawanshi@gmail.com>,
Christoph Hellwig <hch@infradead.org>
Cc: linux-mm@kvack.org, iommu@lists.linux-foundation.org,
linux-kernel@vger.kernel.org, Vlastimil Babka <vbabka@suse.cz>,
Michal Hocko <mhocko@kernel.org>
Subject: Re: DMA-API attr - DMA_ATTR_NO_KERNEL_MAPPING
Date: Mon, 1 Jul 2019 15:09:46 +0100 [thread overview]
Message-ID: <c9fe4253-5698-a226-c643-32a21df8520a@arm.com> (raw)
In-Reply-To: <CACDBo56fNVxVyNEGtKM+2R0X7DyZrrHMQr6Yw4NwJ6USjD5Png@mail.gmail.com>
On 28/06/2019 17:29, Pankaj Suryawanshi wrote:
> On Wed, Jun 26, 2019 at 11:21 PM Christoph Hellwig <hch@infradead.org> wrote:
>>
>> On Wed, Jun 26, 2019 at 10:12:45PM +0530, Pankaj Suryawanshi wrote:
>>> [CC: linux kernel and Vlastimil Babka]
>>
>> The right list is the list for the DMA mapping subsystem, which is
>> iommu@lists.linux-foundation.org. I've also added that.
>>
>>>> I am writing driver in which I used DMA_ATTR_NO_KERNEL_MAPPING attribute
>>>> for cma allocation using dma_alloc_attr(), as per kernel docs
>>>> https://www.kernel.org/doc/Documentation/DMA-attributes.txt buffers
>>>> allocated with this attribute can be only passed to user space by calling
>>>> dma_mmap_attrs().
>>>>
>>>> how can I mapped in kernel space (after dma_alloc_attr with
>>>> DMA_ATTR_NO_KERNEL_MAPPING ) ?
>>
>> You can't. And that is the whole point of that API.
>
> 1. We can again mapped in kernel space using dma_remap() api , because
> when we are using DMA_ATTR_NO_KERNEL_MAPPING for dma_alloc_attr it
> returns the page as virtual address(in case of CMA) so we can mapped
> it again using dma_remap().
No, you really can't. A caller of dma_alloc_attrs(...,
DMA_ATTR_NO_KERNEL_MAPPING) cannot make any assumptions about the void*
it returns, other than that it must be handed back to dma_free_attrs()
later. The implementation is free to ignore the flag and give back a
virtual mapping anyway. Any driver which depends on how one particular
implementation on one particular platform happens to behave today is,
essentially, wrong.
> 2. We can mapped in kernel space using vmap() as used for ion-cma
> https://github.com/torvalds/linux/tree/master/drivers/staging/android/ion
> as used in function ion_heap_map_kernel().
>
> Please let me know if i am missing anything.
If you want a kernel mapping, *don't* explicitly request not to have a
kernel mapping in the first place. It's that simple.
Robin.
next prev parent reply other threads:[~2019-07-01 14:09 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-26 16:41 Pankaj Suryawanshi
2019-06-26 16:42 ` Pankaj Suryawanshi
2019-06-26 17:51 ` Christoph Hellwig
2019-06-28 16:29 ` Pankaj Suryawanshi
2019-07-01 14:09 ` Robin Murphy [this message]
2019-07-01 17:47 ` Pankaj Suryawanshi
2019-07-01 17:52 ` Pankaj Suryawanshi
2019-07-01 17:54 ` Robin Murphy
2019-07-01 18:07 ` Pankaj Suryawanshi
2019-07-01 18:36 ` Pankaj Suryawanshi
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=c9fe4253-5698-a226-c643-32a21df8520a@arm.com \
--to=robin.murphy@arm.com \
--cc=hch@infradead.org \
--cc=iommu@lists.linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=pankajssuryawanshi@gmail.com \
--cc=vbabka@suse.cz \
/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