From: Rob Bradford Subject: [PATCH] drm/i915: Implement dma-buf mmap() on systems with LLC Date: Mon, 24 Feb 2014 19:50:49 +0000 Message-ID: <1393271449-4385-1-git-send-email-robert.bradford@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail-wi0-f180.google.com (mail-wi0-f180.google.com [209.85.212.180]) by gabe.freedesktop.org (Postfix) with ESMTP id BFD3BFABF9 for ; Mon, 24 Feb 2014 11:50:51 -0800 (PST) Received: by mail-wi0-f180.google.com with SMTP id hm4so3516260wib.13 for ; Mon, 24 Feb 2014 11:50:50 -0800 (PST) Received: from zeus.icx.intel.com ([83.217.123.106]) by mx.google.com with ESMTPSA id ju6sm44624641wjc.1.2014.02.24.11.50.49 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 24 Feb 2014 11:50:49 -0800 (PST) List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: intel-gfx-bounces@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org To: intel-gfx@lists.freedesktop.org List-Id: intel-gfx@lists.freedesktop.org From: Rob Bradford The LLC check echoes the check made by i915_gem_fault() which will handle the mapping the pages through the GTT. The aim is that this is functionally equivalent to using the I915_GEM_MMAP_GTT ioctl and then mmaping using the offset returned. Signed-off-by: Rob Bradford --- drivers/gpu/drm/i915/i915_gem_dmabuf.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/i915_gem_dmabuf.c b/drivers/gpu/drm/i915/i915_gem_dmabuf.c index 9bb533e..55ff592 100644 --- a/drivers/gpu/drm/i915/i915_gem_dmabuf.c +++ b/drivers/gpu/drm/i915/i915_gem_dmabuf.c @@ -197,7 +197,25 @@ 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; + int ret; + + if (!HAS_LLC(dev)) + return -EINVAL; + + ret = i915_mutex_lock_interruptible(dev); + if (ret) + goto unlock; + + ret = drm_gem_mmap_obj(&obj->base, vma_pages(vma) << PAGE_SHIFT, vma); + + if (ret) + goto unlock; + +unlock: + 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.1