<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<body>
<div dir="auto">
<div dir="auto"><span style="font-size: 12pt;">On July 28, 2021 10:57:23 Matthew Auld <matthew.auld@intel.com> wrote:</span></div><div id="aqm-original" style="color: black;">
<div><br></div>
<blockquote type="cite" class="gmail_quote" style="margin: 0 0 0 0.75ex; border-left: 1px solid #808080; padding-left: 0.75ex;">
<div dir="auto">No need to hand roll the set_placements stuff, now that that we have a</div>
<div dir="auto">helper for this. Also no need to handle the -ENODEV case here, since</div>
<div dir="auto">NULL mr implies missing device support, where the for_each_memory_region</div>
<div dir="auto">helper will always skip over such regions.</div>
<div dir="auto"><br></div>
<div dir="auto">Signed-off-by: Matthew Auld <matthew.auld@intel.com></div>
<div dir="auto">Cc: Jason Ekstrand <jason@jlekstrand.net></div></blockquote></div><div dir="auto"><br></div><div dir="auto">Reviewed-by: Jason Ekstrand <jason@jlekstrand.net></div><div dir="auto"><br></div><div dir="auto"><br></div><div id="aqm-original" style="color: black;" dir="auto"><blockquote type="cite" class="gmail_quote" style="margin: 0 0 0 0.75ex; border-left: 1px solid #808080; padding-left: 0.75ex;"><div dir="auto"></div>
<div dir="auto">---</div>
<div dir="auto"> .../drm/i915/gem/selftests/i915_gem_mman.c    | 46 ++-----------------</div>
<div dir="auto"> 1 file changed, 4 insertions(+), 42 deletions(-)</div>
<div dir="auto"><br></div>
<div dir="auto">diff --git a/drivers/gpu/drm/i915/gem/selftests/i915_gem_mman.c b/drivers/gpu/drm/i915/gem/selftests/i915_gem_mman.c</div>
<div dir="auto">index 0b2b73d8a364..eed1c2c64e75 100644</div>
<div dir="auto">--- a/drivers/gpu/drm/i915/gem/selftests/i915_gem_mman.c</div>
<div dir="auto">+++ b/drivers/gpu/drm/i915/gem/selftests/i915_gem_mman.c</div>
<div dir="auto">@@ -860,24 +860,6 @@ static bool can_mmap(struct drm_i915_gem_object *obj, enum i915_mmap_type type)</div>
<div dir="auto">   return !no_map;</div>
<div dir="auto"> }</div>
<div dir="auto"> </div>
<div dir="auto">-static void object_set_placements(struct drm_i915_gem_object *obj,</div>
<div dir="auto">-                                 struct intel_memory_region **placements,</div>
<div dir="auto">-                                 unsigned int n_placements)</div>
<div dir="auto">-{</div>
<div dir="auto">-       GEM_BUG_ON(!n_placements);</div>
<div dir="auto">-</div>
<div dir="auto">-       if (n_placements == 1) {</div>
<div dir="auto">-               struct drm_i915_private *i915 = to_i915(obj->base.dev);</div>
<div dir="auto">-               struct intel_memory_region *mr = placements[0];</div>
<div dir="auto">-</div>
<div dir="auto">-               obj->mm.placements = &i915->mm.regions[mr->id];</div>
<div dir="auto">-               obj->mm.n_placements = 1;</div>
<div dir="auto">-       } else {</div>
<div dir="auto">-               obj->mm.placements = placements;</div>
<div dir="auto">-               obj->mm.n_placements = n_placements;</div>
<div dir="auto">-       }</div>
<div dir="auto">-}</div>
<div dir="auto">-</div>
<div dir="auto"> #define expand32(x) (((x) << 0) | ((x) << 8) | ((x) << 16) | ((x) << 24))</div>
<div dir="auto"> static int __igt_mmap(struct drm_i915_private *i915,</div>
<div dir="auto">                 struct drm_i915_gem_object *obj,</div>
<div dir="auto">@@ -972,15 +954,10 @@ static int igt_mmap(void *arg)</div>
<div dir="auto">                   struct drm_i915_gem_object *obj;</div>
<div dir="auto">                   int err;</div>
<div dir="auto"> </div>
<div dir="auto">-                       obj = i915_gem_object_create_region(mr, sizes[i], 0, I915_BO_ALLOC_USER);</div>
<div dir="auto">-                       if (obj == ERR_PTR(-ENODEV))</div>
<div dir="auto">-                               continue;</div>
<div dir="auto">-</div>
<div dir="auto">+                       obj = __i915_gem_object_create_user(i915, sizes[i], &mr, 1);</div>
<div dir="auto">                   if (IS_ERR(obj))</div>
<div dir="auto">                           return PTR_ERR(obj);</div>
<div dir="auto"> </div>
<div dir="auto">-                       object_set_placements(obj, &mr, 1);</div>
<div dir="auto">-</div>
<div dir="auto">                   err = __igt_mmap(i915, obj, I915_MMAP_TYPE_GTT);</div>
<div dir="auto">                   if (err == 0)</div>
<div dir="auto">                           err = __igt_mmap(i915, obj, I915_MMAP_TYPE_WC);</div>
<div dir="auto">@@ -1101,15 +1078,10 @@ static int igt_mmap_access(void *arg)</div>
<div dir="auto">           struct drm_i915_gem_object *obj;</div>
<div dir="auto">           int err;</div>
<div dir="auto"> </div>
<div dir="auto">-               obj = i915_gem_object_create_region(mr, PAGE_SIZE, 0, I915_BO_ALLOC_USER);</div>
<div dir="auto">-               if (obj == ERR_PTR(-ENODEV))</div>
<div dir="auto">-                       continue;</div>
<div dir="auto">-</div>
<div dir="auto">+               obj = __i915_gem_object_create_user(i915, PAGE_SIZE, &mr, 1);</div>
<div dir="auto">           if (IS_ERR(obj))</div>
<div dir="auto">                   return PTR_ERR(obj);</div>
<div dir="auto"> </div>
<div dir="auto">-               object_set_placements(obj, &mr, 1);</div>
<div dir="auto">-</div>
<div dir="auto">           err = __igt_mmap_access(i915, obj, I915_MMAP_TYPE_GTT);</div>
<div dir="auto">           if (err == 0)</div>
<div dir="auto">                   err = __igt_mmap_access(i915, obj, I915_MMAP_TYPE_WB);</div>
<div dir="auto">@@ -1248,15 +1220,10 @@ static int igt_mmap_gpu(void *arg)</div>
<div dir="auto">           struct drm_i915_gem_object *obj;</div>
<div dir="auto">           int err;</div>
<div dir="auto"> </div>
<div dir="auto">-               obj = i915_gem_object_create_region(mr, PAGE_SIZE, 0, I915_BO_ALLOC_USER);</div>
<div dir="auto">-               if (obj == ERR_PTR(-ENODEV))</div>
<div dir="auto">-                       continue;</div>
<div dir="auto">-</div>
<div dir="auto">+               obj = __i915_gem_object_create_user(i915, PAGE_SIZE, &mr, 1);</div>
<div dir="auto">           if (IS_ERR(obj))</div>
<div dir="auto">                   return PTR_ERR(obj);</div>
<div dir="auto"> </div>
<div dir="auto">-               object_set_placements(obj, &mr, 1);</div>
<div dir="auto">-</div>
<div dir="auto">           err = __igt_mmap_gpu(i915, obj, I915_MMAP_TYPE_GTT);</div>
<div dir="auto">           if (err == 0)</div>
<div dir="auto">                   err = __igt_mmap_gpu(i915, obj, I915_MMAP_TYPE_WC);</div>
<div dir="auto">@@ -1405,15 +1372,10 @@ static int igt_mmap_revoke(void *arg)</div>
<div dir="auto">           struct drm_i915_gem_object *obj;</div>
<div dir="auto">           int err;</div>
<div dir="auto"> </div>
<div dir="auto">-               obj = i915_gem_object_create_region(mr, PAGE_SIZE, 0, I915_BO_ALLOC_USER);</div>
<div dir="auto">-               if (obj == ERR_PTR(-ENODEV))</div>
<div dir="auto">-                       continue;</div>
<div dir="auto">-</div>
<div dir="auto">+               obj = __i915_gem_object_create_user(i915, PAGE_SIZE, &mr, 1);</div>
<div dir="auto">           if (IS_ERR(obj))</div>
<div dir="auto">                   return PTR_ERR(obj);</div>
<div dir="auto"> </div>
<div dir="auto">-               object_set_placements(obj, &mr, 1);</div>
<div dir="auto">-</div>
<div dir="auto">           err = __igt_mmap_revoke(i915, obj, I915_MMAP_TYPE_GTT);</div>
<div dir="auto">           if (err == 0)</div>
<div dir="auto">                   err = __igt_mmap_revoke(i915, obj, I915_MMAP_TYPE_WC);</div>
<div dir="auto">-- </div>
<div dir="auto">2.26.3</div>
</blockquote>
</div><div dir="auto"><br></div>
</div></body>
</html>