Commit e70a27d7 authored by Maarten Lankhorst's avatar Maarten Lankhorst Committed by Daniel Vetter

drm/i915/selftests: Prepare memory region tests for obj->mm.lock removal

Use the unlocked variants for pin_map and pin_pages, and add lock
around unpinning/putting pages.
Signed-off-by: default avatarMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
Reviewed-by: default avatarThomas Hellström <thomas.hellstrom@linux.intel.com>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20210323155059.628690-59-maarten.lankhorst@linux.intel.com
parent aa8b70be
...@@ -31,10 +31,12 @@ static void close_objects(struct intel_memory_region *mem, ...@@ -31,10 +31,12 @@ static void close_objects(struct intel_memory_region *mem,
struct drm_i915_gem_object *obj, *on; struct drm_i915_gem_object *obj, *on;
list_for_each_entry_safe(obj, on, objects, st_link) { list_for_each_entry_safe(obj, on, objects, st_link) {
i915_gem_object_lock(obj, NULL);
if (i915_gem_object_has_pinned_pages(obj)) if (i915_gem_object_has_pinned_pages(obj))
i915_gem_object_unpin_pages(obj); i915_gem_object_unpin_pages(obj);
/* No polluting the memory region between tests */ /* No polluting the memory region between tests */
__i915_gem_object_put_pages(obj); __i915_gem_object_put_pages(obj);
i915_gem_object_unlock(obj);
list_del(&obj->st_link); list_del(&obj->st_link);
i915_gem_object_put(obj); i915_gem_object_put(obj);
} }
...@@ -69,7 +71,7 @@ static int igt_mock_fill(void *arg) ...@@ -69,7 +71,7 @@ static int igt_mock_fill(void *arg)
break; break;
} }
err = i915_gem_object_pin_pages(obj); err = i915_gem_object_pin_pages_unlocked(obj);
if (err) { if (err) {
i915_gem_object_put(obj); i915_gem_object_put(obj);
break; break;
...@@ -109,7 +111,7 @@ igt_object_create(struct intel_memory_region *mem, ...@@ -109,7 +111,7 @@ igt_object_create(struct intel_memory_region *mem,
if (IS_ERR(obj)) if (IS_ERR(obj))
return obj; return obj;
err = i915_gem_object_pin_pages(obj); err = i915_gem_object_pin_pages_unlocked(obj);
if (err) if (err)
goto put; goto put;
...@@ -123,8 +125,10 @@ igt_object_create(struct intel_memory_region *mem, ...@@ -123,8 +125,10 @@ igt_object_create(struct intel_memory_region *mem,
static void igt_object_release(struct drm_i915_gem_object *obj) static void igt_object_release(struct drm_i915_gem_object *obj)
{ {
i915_gem_object_lock(obj, NULL);
i915_gem_object_unpin_pages(obj); i915_gem_object_unpin_pages(obj);
__i915_gem_object_put_pages(obj); __i915_gem_object_put_pages(obj);
i915_gem_object_unlock(obj);
list_del(&obj->st_link); list_del(&obj->st_link);
i915_gem_object_put(obj); i915_gem_object_put(obj);
} }
...@@ -433,7 +437,7 @@ static int igt_cpu_check(struct drm_i915_gem_object *obj, u32 dword, u32 val) ...@@ -433,7 +437,7 @@ static int igt_cpu_check(struct drm_i915_gem_object *obj, u32 dword, u32 val)
if (err) if (err)
return err; return err;
ptr = i915_gem_object_pin_map(obj, I915_MAP_WC); ptr = i915_gem_object_pin_map_unlocked(obj, I915_MAP_WC);
if (IS_ERR(ptr)) if (IS_ERR(ptr))
return PTR_ERR(ptr); return PTR_ERR(ptr);
...@@ -538,7 +542,7 @@ static int igt_lmem_create(void *arg) ...@@ -538,7 +542,7 @@ static int igt_lmem_create(void *arg)
if (IS_ERR(obj)) if (IS_ERR(obj))
return PTR_ERR(obj); return PTR_ERR(obj);
err = i915_gem_object_pin_pages(obj); err = i915_gem_object_pin_pages_unlocked(obj);
if (err) if (err)
goto out_put; goto out_put;
...@@ -577,7 +581,7 @@ static int igt_lmem_write_gpu(void *arg) ...@@ -577,7 +581,7 @@ static int igt_lmem_write_gpu(void *arg)
goto out_file; goto out_file;
} }
err = i915_gem_object_pin_pages(obj); err = i915_gem_object_pin_pages_unlocked(obj);
if (err) if (err)
goto out_put; goto out_put;
...@@ -649,7 +653,7 @@ static int igt_lmem_write_cpu(void *arg) ...@@ -649,7 +653,7 @@ static int igt_lmem_write_cpu(void *arg)
if (IS_ERR(obj)) if (IS_ERR(obj))
return PTR_ERR(obj); return PTR_ERR(obj);
vaddr = i915_gem_object_pin_map(obj, I915_MAP_WC); vaddr = i915_gem_object_pin_map_unlocked(obj, I915_MAP_WC);
if (IS_ERR(vaddr)) { if (IS_ERR(vaddr)) {
err = PTR_ERR(vaddr); err = PTR_ERR(vaddr);
goto out_put; goto out_put;
...@@ -753,7 +757,7 @@ create_region_for_mapping(struct intel_memory_region *mr, u64 size, u32 type, ...@@ -753,7 +757,7 @@ create_region_for_mapping(struct intel_memory_region *mr, u64 size, u32 type,
return obj; return obj;
} }
addr = i915_gem_object_pin_map(obj, type); addr = i915_gem_object_pin_map_unlocked(obj, type);
if (IS_ERR(addr)) { if (IS_ERR(addr)) {
i915_gem_object_put(obj); i915_gem_object_put(obj);
if (PTR_ERR(addr) == -ENXIO) if (PTR_ERR(addr) == -ENXIO)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment