diff mbox series

[RFC,31/42] drm/i915: cpu-map based dumb buffers

Message ID 20190214145740.14521-32-matthew.auld@intel.com (mailing list archive)
State New, archived
Headers show
Series Introduce memory region concept (including device local memory) | expand

Commit Message

Matthew Auld Feb. 14, 2019, 2:57 p.m. UTC
From: Abdiel Janulgue <abdiel.janulgue@linux.intel.com>

If there is no aperture we can't use map_gtt to map dumb buffers, so we
need a cpu-map based path to do it. We prefer map_gtt on platforms that
do have aperture.

Signed-off-by: Abdiel Janulgue <abdiel.janulgue@linux.intel.com>
Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
Cc: Matthew Auld <matthew.auld@intel.com>
---
 drivers/gpu/drm/i915/i915_drv.c        | 2 +-
 drivers/gpu/drm/i915/i915_drv.h        | 2 +-
 drivers/gpu/drm/i915/i915_gem.c        | 8 ++++++--
 drivers/gpu/drm/i915/i915_gem_object.h | 1 +
 4 files changed, 9 insertions(+), 4 deletions(-)

Comments

Chris Wilson Feb. 14, 2019, 4:06 p.m. UTC | #1
Quoting Matthew Auld (2019-02-14 14:57:29)
> From: Abdiel Janulgue <abdiel.janulgue@linux.intel.com>
> 
> If there is no aperture we can't use map_gtt to map dumb buffers, so we
> need a cpu-map based path to do it. We prefer map_gtt on platforms that
> do have aperture.

This is very hard as a standalone patch to see if you the semantics for
dumb buffers correct. Is is coherent for starters?
-Chris
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index 90785030a0dd..90ce9973ce46 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -3040,7 +3040,7 @@  static struct drm_driver driver = {
 	.gem_prime_import = i915_gem_prime_import,
 
 	.dumb_create = i915_gem_dumb_create,
-	.dumb_map_offset = i915_gem_mmap_gtt,
+	.dumb_map_offset = i915_gem_mmap_dumb,
 	.ioctls = i915_ioctls,
 	.num_ioctls = ARRAY_SIZE(i915_ioctls),
 	.fops = &i915_driver_fops,
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index c6ae157d0ede..f0e8567f18f5 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -3030,7 +3030,7 @@  i915_mutex_lock_interruptible(struct drm_device *dev)
 int i915_gem_dumb_create(struct drm_file *file_priv,
 			 struct drm_device *dev,
 			 struct drm_mode_create_dumb *args);
-int i915_gem_mmap_gtt(struct drm_file *file_priv, struct drm_device *dev,
+int i915_gem_mmap_dumb(struct drm_file *file_priv, struct drm_device *dev,
 		      u32 handle, u64 *offset);
 int i915_gem_mmap_gtt_version(void);
 
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index cc6c88ec749d..b426a1ee8d0f 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -2157,12 +2157,16 @@  __assign_gem_object_mmap_data(struct drm_file *file,
 }
 
 int
-i915_gem_mmap_gtt(struct drm_file *file,
+i915_gem_mmap_dumb(struct drm_file *file,
 		  struct drm_device *dev,
 		  u32 handle,
 		  u64 *offset)
 {
-	return __assign_gem_object_mmap_data(file, handle, I915_MMAP_ORIGIN_GTT,
+	struct drm_i915_private *i915 = dev->dev_private;
+	enum i915_cpu_mmap_origin_type mmap_type = HAS_MAPPABLE_APERTURE(i915) ?
+		I915_MMAP_ORIGIN_GTT : I915_MMAP_ORIGIN_DUMB;
+
+	return __assign_gem_object_mmap_data(file, handle, mmap_type,
 					     0, offset);
 }
 
diff --git a/drivers/gpu/drm/i915/i915_gem_object.h b/drivers/gpu/drm/i915/i915_gem_object.h
index b37ffe2e17b6..82f9068f8aed 100644
--- a/drivers/gpu/drm/i915/i915_gem_object.h
+++ b/drivers/gpu/drm/i915/i915_gem_object.h
@@ -90,6 +90,7 @@  enum i915_cpu_mmap_origin_type {
 	I915_MMAP_ORIGIN_NONE = 0,
 	I915_MMAP_ORIGIN_GTT,
 	I915_MMAP_ORIGIN_OFFSET,
+	I915_MMAP_ORIGIN_DUMB,
 };
 
 struct drm_i915_gem_object {