@@ -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;
@@ -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 *
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@intel.com> Signed-off-by: Ramalingam C <ramalingam.c@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(+)