All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
To: dri-devel@lists.freedesktop.org
Subject: [PATCH v2 2/5] drm/omap: Use drm_gem_mmap_obj() to implement dma-buf mmap
Date: Tue,  4 Jun 2013 04:20:19 +0200	[thread overview]
Message-ID: <1370312422-25027-3-git-send-email-laurent.pinchart+renesas@ideasonboard.com> (raw)
In-Reply-To: <1370312422-25027-1-git-send-email-laurent.pinchart+renesas@ideasonboard.com>

The dma-buf mmap code was copied from the GEM mmap implementation.
Replace it with the new drm_gem_mmap_obj() function.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c | 32 +++----------------------------
 1 file changed, 3 insertions(+), 29 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c b/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c
index be7cd97..3256693 100644
--- a/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c
+++ b/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c
@@ -136,10 +136,6 @@ static void omap_gem_dmabuf_kunmap(struct dma_buf *buffer,
 	kunmap(pages[page_num]);
 }
 
-/*
- * TODO maybe we can split up drm_gem_mmap to avoid duplicating
- * some here.. or at least have a drm_dmabuf_mmap helper.
- */
 static int omap_gem_dmabuf_mmap(struct dma_buf *buffer,
 		struct vm_area_struct *vma)
 {
@@ -149,31 +145,9 @@ static int omap_gem_dmabuf_mmap(struct dma_buf *buffer,
 	if (WARN_ON(!obj->filp))
 		return -EINVAL;
 
-	/* Check for valid size. */
-	if (omap_gem_mmap_size(obj) < vma->vm_end - vma->vm_start) {
-		ret = -EINVAL;
-		goto out_unlock;
-	}
-
-	if (!obj->dev->driver->gem_vm_ops) {
-		ret = -EINVAL;
-		goto out_unlock;
-	}
-
-	vma->vm_flags |= VM_IO | VM_PFNMAP | VM_DONTEXPAND | VM_DONTDUMP;
-	vma->vm_ops = obj->dev->driver->gem_vm_ops;
-	vma->vm_private_data = obj;
-	vma->vm_page_prot =  pgprot_writecombine(vm_get_page_prot(vma->vm_flags));
-
-	/* Take a ref for this mapping of the object, so that the fault
-	 * handler can dereference the mmap offset's pointer to the object.
-	 * This reference is cleaned up by the corresponding vm_close
-	 * (which should happen whether the vma was created by this call, or
-	 * by a vm_open due to mremap or partial unmap or whatever).
-	 */
-	vma->vm_ops->open(vma);
-
-out_unlock:
+	ret = drm_gem_mmap_obj(obj, omap_gem_mmap_size(obj), vma);
+	if (ret < 0)
+		return ret;
 
 	return omap_gem_mmap_obj(obj, vma);
 }
-- 
1.8.1.5

  parent reply	other threads:[~2013-06-04  2:20 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-04  2:20 [PATCH v2 0/5] GEM CMA DMA-BUF support Laurent Pinchart
2013-06-04  2:20 ` [PATCH v2 1/5] drm/gem: Split drm_gem_mmap() into object search and object mapping Laurent Pinchart
2013-06-04 11:33   ` Rob Clark
2013-06-04  2:20 ` Laurent Pinchart [this message]
2013-06-04 11:33   ` [PATCH v2 2/5] drm/omap: Use drm_gem_mmap_obj() to implement dma-buf mmap Rob Clark
2013-06-04 18:03     ` Laurent Pinchart
2013-06-04  2:20 ` [PATCH v2 3/5] drm: GEM CMA: Split object creation into object alloc and DMA memory alloc Laurent Pinchart
2013-06-04 20:07   ` Rob Clark
2013-06-04  2:20 ` [PATCH v2 4/5] drm: GEM CMA: Split object mapping into GEM mapping and CMA mapping Laurent Pinchart
2013-06-04 20:19   ` Rob Clark
2013-06-04  2:20 ` [PATCH v2 5/5] drm: GEM CMA: Add DRM PRIME support Laurent Pinchart
2013-06-04 21:56   ` Rob Clark
2013-06-05  1:22     ` Laurent Pinchart
2013-06-05  3:05       ` Rob Clark
2013-06-05  8:44         ` Daniel Vetter
2013-06-05 11:00           ` Rob Clark
2013-06-07 19:25             ` Laurent Pinchart

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=1370312422-25027-3-git-send-email-laurent.pinchart+renesas@ideasonboard.com \
    --to=laurent.pinchart+renesas@ideasonboard.com \
    --cc=dri-devel@lists.freedesktop.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.