From: David Laight <David.Laight@ACULAB.COM>
To: 'Christoph Hellwig' <hch@lst.de>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Marek Szyprowski <m.szyprowski@samsung.com>,
"Tomasz Figa" <tfiga@chromium.org>,
Ricardo Ribalda <ribalda@chromium.org>,
"Sergey Senozhatsky" <senozhatsky@google.com>,
"iommu@lists.linux-foundation.org"
<iommu@lists.linux-foundation.org>
Cc: "linux-media@vger.kernel.org" <linux-media@vger.kernel.org>,
Robin Murphy <robin.murphy@arm.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-doc@vger.kernel.org" <linux-doc@vger.kernel.org>
Subject: RE: [PATCH 2/6] dma-mapping: add a dma_mmap_pages helper
Date: Thu, 28 Jan 2021 15:41:31 +0000 [thread overview]
Message-ID: <792682fa4a97411a8248abeec29b78ee@AcuMS.aculab.com> (raw)
In-Reply-To: <20210128145837.2250561-3-hch@lst.de>
From: Christoph Hellwig
> Sent: 28 January 2021 14:59
>
> Add a helper to map memory allocated using dma_alloc_pages into
> a user address space, similar to the dma_alloc_attrs function for
> coherent allocations.
>
...
> +::
> +
> + int
> + dma_mmap_pages(struct device *dev, struct vm_area_struct *vma,
> + size_t size, struct page *page)
> +
> +Map an allocation returned from dma_alloc_pages() into a user address space.
> +dev and size must be the same as those passed into dma_alloc_pages().
> +page must be the pointer returned by dma_alloc_pages().
To be useful this needs to specify the offset into the user address area.
(ie the offset in the mmap() buffer.)
For example we have an fpga based PCIe card that converts internal
addresses that refer to one of 512 16k 'pages' to 64bit PCIe bus
master addresses.
So it (sort of) contains its own iommu.
So we can allocate (aligned) 16k kernel memory buffers with
dma_alloc_coherent() and make them appear contiguous to the
on-board PCIe bus master users.
We then mmap() them into contiguous user addresses.
So both 'ends' see contiguous addresses without requiring
contiguous physical memory or requiring all the memory be
allocated at the same time.
Clearly in-kernel users have to allow for the 16k boundaries.
But the large structures are accesses from user space.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
next prev parent reply other threads:[~2021-01-28 15:48 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-28 14:58 add a new dma_alloc_noncontiguous API Christoph Hellwig
2021-01-28 14:58 ` [PATCH 1/6] dma-mapping: remove the {alloc,free}_noncoherent methods Christoph Hellwig
2021-01-28 14:58 ` [PATCH 2/6] dma-mapping: add a dma_mmap_pages helper Christoph Hellwig
2021-01-28 15:41 ` David Laight [this message]
2021-01-28 14:58 ` [PATCH 3/6] dma-mapping: add a dma_alloc_noncontiguous API Christoph Hellwig
2021-01-28 14:58 ` [PATCH 4/6] dma-iommu: refactor iommu_dma_alloc_remap Christoph Hellwig
2021-01-28 14:58 ` [PATCH 5/6] dma-iommu: implement ->alloc_noncontiguous Christoph Hellwig
2021-01-28 14:58 ` [PATCH 6/6] media: uvcvideo: Use dma_alloc_noncontiguos API Christoph Hellwig
2021-01-28 15:09 ` Christoph Hellwig
2021-01-28 17:00 ` Ricardo Ribalda
2021-02-01 16:37 ` Christoph Hellwig
2021-01-28 16:43 ` Ricardo Ribalda
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=792682fa4a97411a8248abeec29b78ee@AcuMS.aculab.com \
--to=david.laight@aculab.com \
--cc=hch@lst.de \
--cc=iommu@lists.linux-foundation.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=mchehab@kernel.org \
--cc=ribalda@chromium.org \
--cc=robin.murphy@arm.com \
--cc=senozhatsky@google.com \
--cc=tfiga@chromium.org \
/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