[RFC PATCH i-g-t] tests/gem_userptr_blits: Refresh map-fixed-invalidate* subtests

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



map-fixed-invalidate* subtests utilize gem_set_tiling() which may fail,
e.g. on hardware with no mappable aperture, due to missing fences.
Skip those subtests if fences are not available.

Moreover, those subtests use GEM_MMAP_GTT IOCTL which may also fail,
e.g. on hardware with no mappable aperture.  Use GEM_MMAP_OFFSET
instead and iterate MMAP_OFFSET coherent types to find one that works.

Signed-off-by: Janusz Krzysztofik <janusz.krzysztofik@xxxxxxxxxxxxxxx>
Cc: Michał Winiarski <michal.winiarski@xxxxxxxxx>
---
Hi Michał,

As you are the author of those subtests, let me ask you a few questions
I'm not sure about:
1. How critical is the use of gem_set_tiling() to those subtests?  Can
   we just skip those operations if not supported?  If not, can you
   propose a replacement that should work on hardware with no mappable
   aperture?
2. Which of MMAP_OFFSET types should do the job if mappable aperture is
   not available?  Should any of them work, as I've assumed?  Is my
   approach of succeeding a subtest on first successful MMAP_OFFSET
   type correct?  Or should we examine all types?

Thanks,
Janusz

 tests/i915/gem_userptr_blits.c | 49 ++++++++++++++++++++++++----------
 1 file changed, 35 insertions(+), 14 deletions(-)

diff --git a/tests/i915/gem_userptr_blits.c b/tests/i915/gem_userptr_blits.c
index 74d441a60..83c7468dc 100644
--- a/tests/i915/gem_userptr_blits.c
+++ b/tests/i915/gem_userptr_blits.c
@@ -730,7 +730,8 @@ static void test_forked_access(int fd)
 				  MAP_FIXED_INVALIDATE_BUSY | \
 				  MAP_FIXED_INVALIDATE_GET_PAGES)
 
-static int test_map_fixed_invalidate(int fd, uint32_t flags)
+static int test_map_fixed_invalidate(int fd, uint32_t flags,
+				     const struct mmap_offset *t)
 {
 	const size_t ptr_size = sizeof(linear) + 2*PAGE_SIZE;
 	const int num_handles = (flags & MAP_FIXED_INVALIDATE_OVERLAP) ? 2 : 1;
@@ -749,7 +750,7 @@ static int test_map_fixed_invalidate(int fd, uint32_t flags)
 	for (char *fixed = (char *)ptr, *end = fixed + ptr_size;
 	     fixed + 2*PAGE_SIZE <= end;
 	     fixed += PAGE_SIZE) {
-		struct drm_i915_gem_mmap_gtt mmap_gtt;
+		struct drm_i915_gem_mmap_offset mmap_offset;
 		uint32_t *map;
 
 		map = mmap(ptr, ptr_size, PROT_READ | PROT_WRITE,
@@ -758,9 +759,13 @@ static int test_map_fixed_invalidate(int fd, uint32_t flags)
 		igt_assert(map != MAP_FAILED);
 		igt_assert(map == ptr);
 
-		memset(&mmap_gtt, 0, sizeof(mmap_gtt));
-		mmap_gtt.handle = gem_create(fd, 2*PAGE_SIZE);
-		do_ioctl(fd, DRM_IOCTL_I915_GEM_MMAP_GTT, &mmap_gtt);
+		memset(&mmap_offset, 0, sizeof(mmap_offset));
+		mmap_offset.handle = gem_create(fd, 2 * PAGE_SIZE);
+		mmap_offset.flags = t->type;
+		igt_skip_on_f(igt_ioctl(fd, DRM_IOCTL_I915_GEM_MMAP_OFFSET,
+					&mmap_offset),
+			      "HW & kernel support for mmap_offset(%s)\n",
+			      t->name);
 
 		if (flags & MAP_FIXED_INVALIDATE_GET_PAGES)
 			igt_assert_eq(__gem_set_domain(fd, handle[0],
@@ -774,11 +779,11 @@ static int test_map_fixed_invalidate(int fd, uint32_t flags)
 		map = mmap(fixed, 2*PAGE_SIZE,
 			   PROT_READ | PROT_WRITE,
 			   MAP_SHARED | MAP_FIXED,
-			   fd, mmap_gtt.offset);
+			   fd, mmap_offset.offset);
 		igt_assert(map != MAP_FAILED);
 		igt_assert(map == (uint32_t *)fixed);
 
-		gem_set_tiling(fd, mmap_gtt.handle, I915_TILING_NONE, 0);
+		gem_set_tiling(fd, mmap_offset.handle, I915_TILING_NONE, 0);
 		*map = 0xdead;
 
 		if (flags & MAP_FIXED_INVALIDATE_GET_PAGES) {
@@ -792,10 +797,10 @@ static int test_map_fixed_invalidate(int fd, uint32_t flags)
 			handle[0] = create_userptr(fd, 0, ptr + PAGE_SIZE/sizeof(*ptr));
 		}
 
-		gem_set_tiling(fd, mmap_gtt.handle, I915_TILING_Y, 512 * 4);
+		gem_set_tiling(fd, mmap_offset.handle, I915_TILING_Y, 512 * 4);
 		*(uint32_t*)map = 0xbeef;
 
-		gem_close(fd, mmap_gtt.handle);
+		gem_close(fd, mmap_offset.handle);
 	}
 
 	for (int i = 0; i < num_handles; i++)
@@ -2177,11 +2182,27 @@ igt_main_args("c:", NULL, help_str, opt_handler, NULL)
 			test_invalidate_close_race(fd, true);
 
 		for (unsigned flags = 0; flags < ALL_MAP_FIXED_INVALIDATE + 1; flags++) {
-			igt_subtest_f("map-fixed-invalidate%s%s%s",
-				      flags & MAP_FIXED_INVALIDATE_OVERLAP ? "-overlap" : "",
-				      flags & MAP_FIXED_INVALIDATE_BUSY ? "-busy" : "",
-				      flags & MAP_FIXED_INVALIDATE_GET_PAGES ? "-gup" : "") {
-				test_map_fixed_invalidate(fd, flags);
+			igt_subtest_with_dynamic_f("map-fixed-invalidate%s%s%s",
+					flags & MAP_FIXED_INVALIDATE_OVERLAP ?
+							"-overlap" : "",
+					flags & MAP_FIXED_INVALIDATE_BUSY ?
+							"-busy" : "",
+					flags & MAP_FIXED_INVALIDATE_GET_PAGES ?
+							"-gup" : "") {
+				igt_require_f(gem_available_fences(fd),
+					      "HW & kernel support for tiling\n");
+
+				/* use a coherent mmap-offset type that works */
+				for_each_mmap_offset_type(t) {
+					int ret = -1;
+
+					igt_dynamic_f("%s", t->name)
+						ret = test_map_fixed_invalidate(
+								fd, flags, t);
+
+					if (!ret)
+						break;
+				}
 			}
 		}
 
-- 
2.21.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux