All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steven Price <steven.price@arm.com>
To: Sumit Semwal <sumit.semwal@linaro.org>, Daniel Vetter <daniel@ffwll.ch>
Cc: dri-devel@lists.freedesktop.org,
	Steven Price <steven.price@arm.com>,
	Rob Herring <robh+dt@kernel.org>,
	Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>,
	Boris Brezillon <boris.brezillon@collabora.com>,
	ML mesa-dev <mesa-dev@lists.freedesktop.org>
Subject: [PATCH] dma-buf: Update docs to discourage use of dma_buf_mmap()
Date: Thu,  4 Jul 2019 17:37:25 +0100	[thread overview]
Message-ID: <20190704163725.18050-1-steven.price@arm.com> (raw)
In-Reply-To: <CAKMK7uHkvaFBLdO=gTf30BDujHrx90YkA9O0O1Mgy_80TeL8iw@mail.gmail.com>

dma_buf_mmap() allows a device driver to forward a mmap() call to the
dma_buf exporter. However this mechanism provides no way for userspace
to use the DMA_BUF_IOCTL_SYNC mechanism to ensure coherency with the
mapped buffer.

Because of this it is wise to migrate away from providing this
mmap() forwarding mechanism and update drivers to avoid using it.
However the user ABI must be maintained, so this existing mmap()
forwarding cannot be removed.

Signed-off-by: Steven Price <steven.price@arm.com>
---
 drivers/dma-buf/dma-buf.c | 23 ++++++++++-------------
 1 file changed, 10 insertions(+), 13 deletions(-)

diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
index bf4d4c80fbc6..2a7a2c8c4182 100644
--- a/drivers/dma-buf/dma-buf.c
+++ b/drivers/dma-buf/dma-buf.c
@@ -731,20 +731,17 @@ EXPORT_SYMBOL_GPL(dma_buf_unmap_attachment);
  *
  * - And as a CPU fallback in userspace processing pipelines.
  *
- *   Similar to the motivation for kernel cpu access it is again important that
- *   the userspace code of a given importing subsystem can use the same
- *   interfaces with a imported dma-buf buffer object as with a native buffer
- *   object. This is especially important for drm where the userspace part of
- *   contemporary OpenGL, X, and other drivers is huge, and reworking them to
- *   use a different way to mmap a buffer rather invasive.
+ *   Ideally userspace code should directly mmap the dma-buf fd which allows
+ *   the use of the SYNC_START/SYNC_END ioctls as detailed above. However there
+ *   are situations where there is a large body of existing code and reworking
+ *   it to support a different way to mmap a buffer is rather invasive.
  *
- *   The assumption in the current dma-buf interfaces is that redirecting the
- *   initial mmap is all that's needed. A survey of some of the existing
- *   subsystems shows that no driver seems to do any nefarious thing like
- *   syncing up with outstanding asynchronous processing on the device or
- *   allocating special resources at fault time. So hopefully this is good
- *   enough, since adding interfaces to intercept pagefaults and allow pte
- *   shootdowns would increase the complexity quite a bit.
+ *   Some drivers therefore provide an interface that simply redirects the
+ *   mmap to the dma-buf exporter. This is fine as long as the SYNC_START and
+ *   SYNC_END ioctls don't do anything, but may lead to coherency issues
+ *   if they are required. New code should avoid using this because of
+ *   potentially hard to debug coherency problems. The interface, however,
+ *   remains for backwards compatibility.
  *
  *   Interface::
  *      int dma_buf_mmap(struct dma_buf \*, struct vm_area_struct \*,
-- 
2.20.1

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

  reply	other threads:[~2019-07-04 16:37 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-03 13:33 [RFC PATCH] mesa: Export BOs in RW mode Boris Brezillon
2019-07-03 13:45 ` Rob Herring
2019-07-03 13:56   ` Boris Brezillon
2019-07-03 14:13     ` Steven Price
2019-07-03 14:33       ` Boris Brezillon
2019-07-03 14:50         ` Steven Price
2019-07-03 15:07           ` Boris Brezillon
2019-07-03 16:18           ` Daniel Vetter
2019-07-04  9:26             ` Steven Price
2019-07-04  9:46               ` [Mesa-dev] " Daniel Vetter
2019-07-04 16:37                 ` Steven Price [this message]
2019-07-03 15:59       ` Rob Herring
2019-07-03 16:15         ` Steven Price
2019-07-03 15:47   ` Daniel Vetter
2019-07-03 15:49     ` Daniel Vetter
2019-07-03 16:07     ` Alyssa Rosenzweig

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=20190704163725.18050-1-steven.price@arm.com \
    --to=steven.price@arm.com \
    --cc=alyssa.rosenzweig@collabora.com \
    --cc=boris.brezillon@collabora.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=mesa-dev@lists.freedesktop.org \
    --cc=robh+dt@kernel.org \
    --cc=sumit.semwal@linaro.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.