diff mbox series

[v2] drm/i915: Create dumb buffer from LMEM

Message ID 20190923095958.21546-1-ramalingam.c@intel.com (mailing list archive)
State New, archived
Headers show
Series [v2] drm/i915: Create dumb buffer from LMEM | expand

Commit Message

Ramalingam C Sept. 23, 2019, 9:59 a.m. UTC
When LMEM is supported, dumb buffer preferred to be created from LMEM.

This is developed on top of v3 LMEM series
https://patchwork.freedesktop.org/series/56683/.

v2:
  Parameters are reshuffled. [Chris]

Signed-off-by: Ramalingam C <ramalingam.c@intel.com>
cc: Matthew Auld <matthew.auld@intel.com>
---
 drivers/gpu/drm/i915/i915_gem.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index e458507b1558..a34a87d192da 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -160,6 +160,7 @@  i915_gem_phys_pwrite(struct drm_i915_gem_object *obj,
 static int
 i915_gem_create(struct drm_file *file,
 		struct drm_i915_private *dev_priv,
+		enum intel_region_id mem_region,
 		u64 *size_p,
 		u32 *handle_p)
 {
@@ -173,7 +174,12 @@  i915_gem_create(struct drm_file *file,
 		return -EINVAL;
 
 	/* Allocate the new object */
-	obj = i915_gem_object_create_shmem(dev_priv, size);
+	if (mem_region == INTEL_MEMORY_LMEM)
+		obj = i915_gem_object_create_lmem(dev_priv, size, 0);
+	else if (mem_region == INTEL_MEMORY_STOLEN)
+		obj = i915_gem_object_create_stolen(dev_priv, size);
+	else
+		obj = i915_gem_object_create_shmem(dev_priv, size);
 	if (IS_ERR(obj))
 		return PTR_ERR(obj);
 
@@ -193,6 +199,7 @@  i915_gem_dumb_create(struct drm_file *file,
 		     struct drm_device *dev,
 		     struct drm_mode_create_dumb *args)
 {
+	enum intel_region_id mem_region = INTEL_MEMORY_UKNOWN;
 	int cpp = DIV_ROUND_UP(args->bpp, 8);
 	u32 format;
 
@@ -219,7 +226,11 @@  i915_gem_dumb_create(struct drm_file *file,
 		args->pitch = ALIGN(args->pitch, 4096);
 
 	args->size = args->pitch * args->height;
-	return i915_gem_create(file, to_i915(dev),
+
+	if (HAS_LMEM(to_i915(dev)))
+		mem_region = INTEL_MEMORY_LMEM;
+
+	return i915_gem_create(file, to_i915(dev), mem_region,
 			       &args->size, &args->handle);
 }
 
@@ -238,7 +249,7 @@  i915_gem_create_ioctl(struct drm_device *dev, void *data,
 
 	i915_gem_flush_free_objects(dev_priv);
 
-	return i915_gem_create(file, dev_priv,
+	return i915_gem_create(file, dev_priv, INTEL_MEMORY_UKNOWN,
 			       &args->size, &args->handle);
 }