From: Daniel Vetter <daniel@ffwll.ch>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Daniel Vetter <daniel@ffwll.ch>,
Marek Szyprowski <m.szyprowski@samsung.com>,
Tomasz Stanislawski <t.stanislaws@samsung.com>,
Sumit Semwal <sumit.semwal@linaro.org>,
Pawel Osciak <pawel@osciak.com>,
Sumit Semwal <sumit.semwal@ti.com>,
linaro-mm-sig@lists.linaro.org, linux-media@vger.kernel.org,
arnd@arndb.de, jesse.barker@linaro.org, rob@ti.com,
patches@linaro.org
Subject: Re: [RFCv1 2/4] v4l:vb2: add support for shared buffer (dma_buf)
Date: Mon, 30 Jan 2012 17:29:31 +0100 [thread overview]
Message-ID: <20120130162931.GA4360@phenom.ffwll.local> (raw)
In-Reply-To: <201201301544.22168.laurent.pinchart@ideasonboard.com>
On Mon, Jan 30, 2012 at 03:44:20PM +0100, Laurent Pinchart wrote:
> Hi Daniel,
>
> On Tuesday 24 January 2012 14:03:22 Daniel Vetter wrote:
> > On Mon, Jan 23, 2012 at 11:54:20AM +0100, Laurent Pinchart wrote:
> > > On Monday 23 January 2012 11:35:01 Daniel Vetter wrote:
> > > > See my other mail, dma_buf v1 does not support cpu access.
> > >
> > > v1 is in the kernel now, let's start discussing v2 ;-)
> >
> > Ok, I'm in ;-)
> >
> > I've thought a bit about this, and I think a reasonable next step would be
> > to enable cpu access from kernelspace. Userspace and mmap support is a hole
> > different beast altogether and I think we should postpone that until we've
> > got the kernel part hashed out.
>
> Userspace access through mmap can already be handled by the subsystem that
> exports the buffer, so I'm fine with postponing implementing this inside dma-
> buf.
Actually I think the interface for mmap won't be that horribly. If we add
a bit of magic clue so that the exporter can intercept pagefaults we
should be able to fake coherent mmaps in all cases. And hence avoid
exposing importers and userspace to a lot of ugly things.
> > I'm thinking about adding 3 pairs of function to dma_buf (not to
> > dma_buf_attachment).
> >
> > dma_buf_get_backing_storage/put_backing_storage
> > This will be used before/after kernel cpu access to ensure that the
> > backing storage is in memory. E.g. gem objects can be swapped out, so
> > they need to be pinned before we can access them. For exporters with
> > static allocations this would be a no-op.
> >
> > I think a start, length range would make sense, but the exporter is free
> > to just swap in the entire object unconditionally. The range is specified
> > in multiples of PAGE_SIZE - I don't think there's any usescase for a
> > get/put_backing_storage which deals in smaller units.
> >
> > The get/put functions are allowed to block and grab all kinds of looks.
> > get is allowed to fail with e.g. -ENOMEM.
> >
> > dma_buf_kmap/kunmap
> > This maps _one_ page into the kernels address space and out of it. This
> > function also flushes/invalidates any caches required. Importers are not
> > allowed to map more than 2 pages at the same time in total (to allow
> > copies). This is because at least for gem objects the backing storage can
> > be in high-mem.
> >
> > Importers are allowed to sleep while holding such a kernel mapping.
> >
> > These functions are not allowed to fail (like kmap/kunmap).
> >
> > dma_buf_kmap_atomic/kunmap_atomic
> > For performance we want to also allow atomic mappigns. Only difference is
> > that importers are not allowed to sleep while holding an atomic mapping.
> >
> > These functions are again not allowed to fail.
> >
> > Comments, flames?
>
> Before commenting (I don't plan on flaming :-)), I'd like to take a small step
> back. Could you describe the use case(s) you think of for kernel mappings ?
One is simply for devices where the kernel has to shove around the data -
I've heard some complaints in the v4l dma_buf threads that this seems to
be dearly in need. E.g. when the v4l devices is attached to usb or behind
another slow(er) bus where direct dma is not possible.
The other is that currently importers are 2nd class citizens and can't do
any cpu access. Making kernel cpu access would be the first step
(afterswards getting mmap working for userspace cpu access). Now for some
simple use-case we can just say "use the access paths provided by the
exporter". But for gpu drivers this gets really ugly because the
upload/download paths aren't standardized within drm/* and they're all
highly optimized. So to make buffer sharing possible among gpu's we need
this - the current gem prime code just grabs the underlying struct page
with sg_page and horribly fails if that doesn't work ;-)
On my proposal itself I think I'll change get/put_backing_storage to
begin/end_cpu_access - these functions must also do any required flushing
to ensure coherency (besides actually grabbing the backing storage). So I
think that's a better name.
-Daniel
--
Daniel Vetter
Mail: daniel@ffwll.ch
Mobile: +41 (0)79 365 57 48
next prev parent reply other threads:[~2012-01-30 16:29 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-05 10:41 [RFCv1 0/4] v4l: DMA buffer sharing support as a user Sumit Semwal
2012-01-05 10:41 ` [RFCv1 1/4] v4l: Add DMABUF as a memory type Sumit Semwal
2012-01-05 10:41 ` [RFCv1 2/4] v4l:vb2: add support for shared buffer (dma_buf) Sumit Semwal
2012-01-14 20:38 ` [Linaro-mm-sig] " Sakari Ailus
[not found] ` <CAB2ybb83ub=A45-m6o+RXqFOTUmXCgeFqs03WZDHeWeLe2+29w@mail.gmail.com>
2012-01-16 5:35 ` Semwal, Sumit
2012-01-20 15:04 ` Laurent Pinchart
2012-01-19 19:07 ` Pawel Osciak
2012-01-20 10:41 ` Sumit Semwal
2012-01-20 10:58 ` Tomasz Stanislawski
2012-01-20 15:12 ` Laurent Pinchart
2012-01-20 15:53 ` Tomasz Stanislawski
2012-01-20 16:11 ` Laurent Pinchart
2012-01-20 16:20 ` Tomasz Stanislawski
2012-01-20 16:28 ` Laurent Pinchart
2012-01-23 9:06 ` Marek Szyprowski
2012-01-23 9:40 ` Daniel Vetter
2012-01-23 9:45 ` Daniel Vetter
2012-01-23 9:48 ` Laurent Pinchart
2012-01-23 10:35 ` Daniel Vetter
2012-01-23 10:54 ` Laurent Pinchart
2012-01-24 0:26 ` Clark, Rob
2012-01-24 9:34 ` Laurent Pinchart
2012-01-24 10:52 ` Daniel Vetter
2012-01-24 13:03 ` Daniel Vetter
2012-01-25 8:09 ` Daniel Vetter
2012-01-30 14:44 ` Laurent Pinchart
2012-01-30 16:29 ` Daniel Vetter [this message]
2012-01-25 23:28 ` Sakari Ailus
2012-01-26 11:27 ` Daniel Vetter
2012-01-29 11:03 ` Sakari Ailus
2012-01-29 13:03 ` Daniel Vetter
2012-01-30 14:33 ` Laurent Pinchart
2012-01-30 22:01 ` Sakari Ailus
2012-01-31 15:38 ` Clark, Rob
2012-02-02 10:19 ` Laurent Pinchart
2012-02-02 14:01 ` Clark, Rob
2012-02-02 14:40 ` Sumit Semwal
2012-02-02 20:23 ` Daniel Vetter
2012-02-02 20:49 ` Clark, Rob
2012-02-04 11:43 ` Sakari Ailus
2012-02-05 15:08 ` Clark, Rob
2012-01-20 14:55 ` [Linaro-mm-sig] " Laurent Pinchart
2012-01-05 10:41 ` [RFCv1 3/4] v4l:vb: remove warnings about MEMORY_DMABUF Sumit Semwal
2012-01-05 10:41 ` [RFCv1 4/4] v4l:vb2: Add dma-contig allocator as dma_buf user Sumit Semwal
2012-01-16 7:57 ` [RFCv1 0/4] v4l: DMA buffer sharing support as a user Kyungmin Park
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=20120130162931.GA4360@phenom.ffwll.local \
--to=daniel@ffwll.ch \
--cc=arnd@arndb.de \
--cc=jesse.barker@linaro.org \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-media@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=patches@linaro.org \
--cc=pawel@osciak.com \
--cc=rob@ti.com \
--cc=sumit.semwal@linaro.org \
--cc=sumit.semwal@ti.com \
--cc=t.stanislaws@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;
as well as URLs for NNTP newsgroup(s).