]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm/i915/selftests: prefer the create_user helper
authorMatthew Auld <matthew.auld@intel.com>
Thu, 29 Jul 2021 09:47:31 +0000 (10:47 +0100)
committerMatthew Auld <matthew.auld@intel.com>
Fri, 30 Jul 2021 09:23:44 +0000 (10:23 +0100)
No need to hand roll the set_placements stuff, now that we have a helper
for this.

v2: add back the -ENODEV checking since it's possible for stolen to be
probed, and yet still be non-functional

Signed-off-by: Matthew Auld <matthew.auld@intel.com>
Cc: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Link: https://patchwork.freedesktop.org/patch/msgid/20210729094731.1953091-1-matthew.auld@intel.com
drivers/gpu/drm/i915/gem/selftests/i915_gem_mman.c

index 0b2b73d8a36480f4692f08fd488f7ccd9f97e0cd..b20f5621f62b127a21cd5d5b8c3b311c02405738 100644 (file)
@@ -860,24 +860,6 @@ static bool can_mmap(struct drm_i915_gem_object *obj, enum i915_mmap_type type)
        return !no_map;
 }
 
-static void object_set_placements(struct drm_i915_gem_object *obj,
-                                 struct intel_memory_region **placements,
-                                 unsigned int n_placements)
-{
-       GEM_BUG_ON(!n_placements);
-
-       if (n_placements == 1) {
-               struct drm_i915_private *i915 = to_i915(obj->base.dev);
-               struct intel_memory_region *mr = placements[0];
-
-               obj->mm.placements = &i915->mm.regions[mr->id];
-               obj->mm.n_placements = 1;
-       } else {
-               obj->mm.placements = placements;
-               obj->mm.n_placements = n_placements;
-       }
-}
-
 #define expand32(x) (((x) << 0) | ((x) << 8) | ((x) << 16) | ((x) << 24))
 static int __igt_mmap(struct drm_i915_private *i915,
                      struct drm_i915_gem_object *obj,
@@ -972,15 +954,13 @@ static int igt_mmap(void *arg)
                        struct drm_i915_gem_object *obj;
                        int err;
 
-                       obj = i915_gem_object_create_region(mr, sizes[i], 0, I915_BO_ALLOC_USER);
+                       obj = __i915_gem_object_create_user(i915, sizes[i], &mr, 1);
                        if (obj == ERR_PTR(-ENODEV))
                                continue;
 
                        if (IS_ERR(obj))
                                return PTR_ERR(obj);
 
-                       object_set_placements(obj, &mr, 1);
-
                        err = __igt_mmap(i915, obj, I915_MMAP_TYPE_GTT);
                        if (err == 0)
                                err = __igt_mmap(i915, obj, I915_MMAP_TYPE_WC);
@@ -1101,15 +1081,13 @@ static int igt_mmap_access(void *arg)
                struct drm_i915_gem_object *obj;
                int err;
 
-               obj = i915_gem_object_create_region(mr, PAGE_SIZE, 0, I915_BO_ALLOC_USER);
+               obj = __i915_gem_object_create_user(i915, PAGE_SIZE, &mr, 1);
                if (obj == ERR_PTR(-ENODEV))
                        continue;
 
                if (IS_ERR(obj))
                        return PTR_ERR(obj);
 
-               object_set_placements(obj, &mr, 1);
-
                err = __igt_mmap_access(i915, obj, I915_MMAP_TYPE_GTT);
                if (err == 0)
                        err = __igt_mmap_access(i915, obj, I915_MMAP_TYPE_WB);
@@ -1248,15 +1226,13 @@ static int igt_mmap_gpu(void *arg)
                struct drm_i915_gem_object *obj;
                int err;
 
-               obj = i915_gem_object_create_region(mr, PAGE_SIZE, 0, I915_BO_ALLOC_USER);
+               obj = __i915_gem_object_create_user(i915, PAGE_SIZE, &mr, 1);
                if (obj == ERR_PTR(-ENODEV))
                        continue;
 
                if (IS_ERR(obj))
                        return PTR_ERR(obj);
 
-               object_set_placements(obj, &mr, 1);
-
                err = __igt_mmap_gpu(i915, obj, I915_MMAP_TYPE_GTT);
                if (err == 0)
                        err = __igt_mmap_gpu(i915, obj, I915_MMAP_TYPE_WC);
@@ -1405,15 +1381,13 @@ static int igt_mmap_revoke(void *arg)
                struct drm_i915_gem_object *obj;
                int err;
 
-               obj = i915_gem_object_create_region(mr, PAGE_SIZE, 0, I915_BO_ALLOC_USER);
+               obj = __i915_gem_object_create_user(i915, PAGE_SIZE, &mr, 1);
                if (obj == ERR_PTR(-ENODEV))
                        continue;
 
                if (IS_ERR(obj))
                        return PTR_ERR(obj);
 
-               object_set_placements(obj, &mr, 1);
-
                err = __igt_mmap_revoke(i915, obj, I915_MMAP_TYPE_GTT);
                if (err == 0)
                        err = __igt_mmap_revoke(i915, obj, I915_MMAP_TYPE_WC);