From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniel Vetter Subject: Re: [PATCH v3] drm/i915: Implement dma-buf mmap() for userspace access Date: Thu, 19 Jun 2014 14:37:01 +0200 Message-ID: <20140619123701.GT5821@phenom.ffwll.local> References: <1403181274-7167-1-git-send-email-conselvan2@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail-wg0-f42.google.com (mail-wg0-f42.google.com [74.125.82.42]) by gabe.freedesktop.org (Postfix) with ESMTP id 525B06E89D for ; Thu, 19 Jun 2014 05:37:09 -0700 (PDT) Received: by mail-wg0-f42.google.com with SMTP id z12so2191645wgg.13 for ; Thu, 19 Jun 2014 05:37:08 -0700 (PDT) Content-Disposition: inline In-Reply-To: <1403181274-7167-1-git-send-email-conselvan2@gmail.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" To: Ander Conselvan de Oliveira Cc: Ander Conselvan de Oliveira , intel-gfx@lists.freedesktop.org List-Id: intel-gfx@lists.freedesktop.org On Thu, Jun 19, 2014 at 03:34:34PM +0300, Ander Conselvan de Oliveira wrote: > From: Rob Bradford > > The aim is that this is functionally equivalent to using the > I915_GEM_MMAP ioctl. > > v2: Add aperture check limit, limit to SNB+ and improve error handling. > > v3 (anderco): Map without using the GTT. Why that? This means you'll have a non-coherent mapping and atm dma-buf doesn't expose and invalidate/flushing ioctls. Which really you want for this. -Daniel > > Signed-off-by: Rob Bradford > Signed-off-by: Ander Conselvan de Oliveira > --- > drivers/gpu/drm/i915/i915_gem_dmabuf.c | 19 ++++++++++++++++++- > 1 file changed, 18 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/i915/i915_gem_dmabuf.c b/drivers/gpu/drm/i915/i915_gem_dmabuf.c > index 580aa42..2d31fca 100644 > --- a/drivers/gpu/drm/i915/i915_gem_dmabuf.c > +++ b/drivers/gpu/drm/i915/i915_gem_dmabuf.c > @@ -193,7 +193,24 @@ static void i915_gem_dmabuf_kunmap(struct dma_buf *dma_buf, unsigned long page_n > > static int i915_gem_dmabuf_mmap(struct dma_buf *dma_buf, struct vm_area_struct *vma) > { > - return -EINVAL; > + struct drm_i915_gem_object *obj = dma_buf_to_obj(dma_buf); > + struct drm_device *dev = obj->base.dev; > + struct drm_i915_private *dev_priv = dev->dev_private; > + int ret; > + > + if (INTEL_INFO(dev)->gen < 6) > + return -EINVAL; > + > + ret = i915_mutex_lock_interruptible(dev); > + if (ret) > + return ret; > + > + ret = obj->base.filp->f_op->mmap(obj->base.filp, vma); > + fput(vma->vm_file); > + vma->vm_file = get_file(obj->base.filp); > + > + mutex_unlock(&dev->struct_mutex); > + return ret; > } > > static int i915_gem_begin_cpu_access(struct dma_buf *dma_buf, size_t start, size_t length, enum dma_data_direction direction) > -- > 1.8.3.2 > > _______________________________________________ > Intel-gfx mailing list > Intel-gfx@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/intel-gfx -- Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch