[igt-dev] [PATCH i-g-t v5 5/9] tests/i915/gem_mmap_offset_exhaustion.c: Extend test to different mappings.

Antonio Argenziano antonio.argenziano at intel.com
Wed Jun 12 22:57:30 UTC 2019


Signed-off-by: Antonio Argenziano <antonio.argenziano at intel.com>
---
 tests/i915/gem_mmap_offset_exhaustion.c | 39 ++++++++++++++++++-------
 1 file changed, 28 insertions(+), 11 deletions(-)

diff --git a/tests/i915/gem_mmap_offset_exhaustion.c b/tests/i915/gem_mmap_offset_exhaustion.c
index 8c8e3fa2..fd5bc898 100644
--- a/tests/i915/gem_mmap_offset_exhaustion.c
+++ b/tests/i915/gem_mmap_offset_exhaustion.c
@@ -52,15 +52,30 @@ IGT_TEST_DESCRIPTION("Checks whether the kernel handles mmap offset exhaustion"
  * uses unsigned long).
  */
 
+enum mode { CPU, WC, GTT };
+const char* modes[] = {[CPU] = "cpu", [WC] = "wc", [GTT] = "gtt"};
+
 static void
-create_and_map_bo(int fd)
+create_and_map_bo(int fd, unsigned mode)
 {
 	uint32_t handle;
 	char *ptr;
 
 	handle = gem_create(fd, OBJECT_SIZE);
 
-	ptr = gem_mmap__gtt(fd, handle, OBJECT_SIZE, PROT_READ | PROT_WRITE);
+	switch (mode) {
+		case GTT:
+			ptr = gem_mmap__gtt(fd, handle, OBJECT_SIZE, PROT_READ | PROT_WRITE);
+			break;
+		case CPU:
+			igt_require(gem_has_mmap_offset(fd));
+			ptr = gem_mmap__cpu(fd, handle, 0, OBJECT_SIZE, PROT_READ | PROT_WRITE);
+			break;
+		case WC:
+			igt_require(gem_has_mmap_offset(fd));
+			ptr = gem_mmap__wc(fd, handle, 0, OBJECT_SIZE, PROT_READ | PROT_WRITE);
+			break;
+	}
 
 	/* touch it to force it into the gtt */
 	*ptr = 0;
@@ -74,18 +89,20 @@ create_and_map_bo(int fd)
 	gem_madvise(fd, handle, I915_MADV_DONTNEED);
 }
 
-igt_simple_main
+igt_main
 {
-	int fd, i;
+	for (unsigned mapping = CPU; mapping <= GTT; mapping++) {
 
-	igt_skip_on_simulation();
+		igt_subtest_f("basic-%s", modes[mapping]) {
+			int fd = drm_open_driver(DRIVER_INTEL);
 
-	fd = drm_open_driver(DRIVER_INTEL);
+			/* we have 32bit of address space, so try to fit one MB more
+			 * than that. */
+			for (int i = 0; i < 4096 + 1; i++)
+				create_and_map_bo(fd, mapping);
 
-	/* we have 32bit of address space, so try to fit one MB more
-	 * than that. */
-	for (i = 0; i < 4096 + 1; i++)
-		create_and_map_bo(fd);
+			close(fd);
+		}
 
-	close(fd);
+	}
 }
-- 
2.21.0



More information about the igt-dev mailing list