[PATCH] drm/i915: Implement dma-buf mmap() on systems with LLC

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Rob Bradford <rob@xxxxxxxxxxxxxxx>

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 <rob@xxxxxxxxxxxxxxx>
---
 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

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux