[Intel-gfx] [PATCH v2 2/3] drm/i915: Allowed memory region for GEM obj

Ramalingam C ramalingam.c at intel.com
Fri Sep 27 09:08:33 UTC 2019


Each GEM object is initialized with allowed memory regions for
it's migration across memory region.

In future patch we are restricting the memory regions or few objects.

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

v2:
  dev_priv is retrieved from obj [Chris]

CC: Matthew Auld <matthew.auld at intel.com>
Signed-off-by: Ramalingam C <ramalingam.c at intel.com>
---
 drivers/gpu/drm/i915/gem/i915_gem_object.c       | 9 +++++++++
 drivers/gpu/drm/i915/gem/i915_gem_object_types.h | 3 +++
 2 files changed, 12 insertions(+)

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_object.c b/drivers/gpu/drm/i915/gem/i915_gem_object.c
index 0f33da5e541d..165ae03c6774 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_object.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_object.c
@@ -51,6 +51,8 @@ void i915_gem_object_free(struct drm_i915_gem_object *obj)
 void i915_gem_object_init(struct drm_i915_gem_object *obj,
 			  const struct drm_i915_gem_object_ops *ops)
 {
+	struct drm_i915_file_private *dev_priv = to_i915(obj->base.drm);
+
 	mutex_init(&obj->mm.lock);
 
 	spin_lock_init(&obj->vma.lock);
@@ -70,6 +72,8 @@ void i915_gem_object_init(struct drm_i915_gem_object *obj,
 	obj->mm.madv = I915_MADV_WILLNEED;
 	INIT_RADIX_TREE(&obj->mm.get_page.radix, GFP_KERNEL | __GFP_NOWARN);
 	mutex_init(&obj->mm.get_page.lock);
+
+	obj->memory_regions = INTEL_INFO(dev_priv)->memory_regions;
 }
 
 /**
@@ -534,6 +538,11 @@ static int i915_gem_object_region_select(struct drm_i915_private *dev_priv,
 		u32 region = uregions_copy[i];
 		enum intel_region_id id = __region_id(region);
 
+		if (!(obj->memory_regions & region)) {
+			ret = -EINVAL;
+			continue;
+		}
+
 		if (id == INTEL_MEMORY_UKNOWN) {
 			ret = -EINVAL;
 			goto err;
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_object_types.h b/drivers/gpu/drm/i915/gem/i915_gem_object_types.h
index 7b93450a860b..af5505e0bd0a 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_object_types.h
+++ b/drivers/gpu/drm/i915/gem/i915_gem_object_types.h
@@ -286,6 +286,9 @@ struct drm_i915_gem_object {
 
 	/** for phys allocated objects */
 	struct drm_dma_handle *phys_handle;
+
+	/* Allowed memory regions for this obj to reside in. */
+	u32 memory_regions;
 };
 
 static inline struct drm_i915_gem_object *
-- 
2.20.1



More information about the Intel-gfx mailing list