[igt-dev] [PATCH i-g-t 4/4] tests/i915_api_intel_allocator: Add the BST allocator

Andrzej Turko andrzej.turko at linux.intel.com
Tue Jul 20 13:27:40 UTC 2021


Include the BST allocator in the allocator test.

Signed-off-by: Andrzej Turko <andrzej.turko at linux.intel.com>
Cc: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
---
 tests/i915/api_intel_allocator.c | 55 ++++++++++++++++++++------------
 1 file changed, 35 insertions(+), 20 deletions(-)

diff --git a/tests/i915/api_intel_allocator.c b/tests/i915/api_intel_allocator.c
index 4b74317ed..45e62cd59 100644
--- a/tests/i915/api_intel_allocator.c
+++ b/tests/i915/api_intel_allocator.c
@@ -25,13 +25,13 @@ static inline uint32_t gem_handle_gen(void)
 	return atomic_fetch_add(&next_handle, 1);
 }
 
-static void alloc_simple(int fd)
+static void alloc_sanity_check(int fd, uint8_t type)
 {
 	uint64_t ahnd;
 	uint64_t offset0, offset1, size = 0x1000, align = 0x1000, start, end;
 	bool is_allocated, freed;
 
-	ahnd = intel_allocator_open(fd, 0, INTEL_ALLOCATOR_SIMPLE);
+	ahnd = intel_allocator_open(fd, 0, type);
 
 	offset0 = intel_allocator_alloc(ahnd, 1, size, align);
 	offset1 = intel_allocator_alloc(ahnd, 1, size, align);
@@ -67,12 +67,12 @@ static void alloc_simple(int fd)
 	igt_assert_eq(intel_allocator_close(ahnd), true);
 }
 
-static void reserve_simple(int fd)
+static void reserve_sanity_check(int fd, uint8_t type)
 {
 	uint64_t ahnd, start, size = 0x1000;
 	bool reserved, unreserved;
 
-	ahnd = intel_allocator_open(fd, 0, INTEL_ALLOCATOR_SIMPLE);
+	ahnd = intel_allocator_open(fd, 0, type);
 	intel_allocator_get_address_range(ahnd, &start, NULL);
 
 	reserved = intel_allocator_reserve(ahnd, 0, size, start);
@@ -194,17 +194,19 @@ static void reuse(int fd, uint8_t type)
 	}
 	i--;
 
-	/* free previously allocated bo */
-	intel_allocator_free(ahnd, obj[i].handle);
-	/* alloc different buffer to fill freed hole */
-	tmp.handle = gem_handle_gen();
-	tmp.offset = intel_allocator_alloc(ahnd, tmp.handle, OBJ_SIZE, 0);
-	igt_assert(prev_offset == tmp.offset);
+	if (type == INTEL_ALLOCATOR_SIMPLE) {
+		/* free previously allocated bo */
+		intel_allocator_free(ahnd, obj[i].handle);
+		/* alloc different buffer to fill freed hole */
+		tmp.handle = gem_handle_gen();
+		tmp.offset = intel_allocator_alloc(ahnd, tmp.handle, OBJ_SIZE, 0);
+		igt_assert(prev_offset == tmp.offset);
 
-	obj[i].offset = intel_allocator_alloc(ahnd, obj[i].handle,
-					      obj[i].size, 0);
-	igt_assert(prev_offset != obj[i].offset);
-	intel_allocator_free(ahnd, tmp.handle);
+		obj[i].offset = intel_allocator_alloc(ahnd, obj[i].handle,
+						      obj[i].size, 0);
+		igt_assert(prev_offset != obj[i].offset);
+		intel_allocator_free(ahnd, tmp.handle);
+	}
 
 	for (i = 0; i < 128; i++)
 		intel_allocator_free(ahnd, obj[i].handle);
@@ -665,6 +667,7 @@ struct allocators {
 	{"simple", INTEL_ALLOCATOR_SIMPLE},
 	{"reloc",  INTEL_ALLOCATOR_RELOC},
 	{"random", INTEL_ALLOCATOR_RANDOM},
+	{"bst", INTEL_ALLOCATOR_BST},
 	{NULL, 0},
 };
 
@@ -679,18 +682,30 @@ igt_main
 		srandom(0xdeadbeef);
 	}
 
-	igt_subtest_f("alloc-simple")
-		alloc_simple(fd);
+	igt_subtest_f("alloc-sanity-check-simple")
+		alloc_sanity_check(fd, INTEL_ALLOCATOR_SIMPLE);
 
-	igt_subtest_f("reserve-simple")
-		reserve_simple(fd);
+	igt_subtest_f("alloc-sanity-check-bst")
+		alloc_sanity_check(fd, INTEL_ALLOCATOR_BST);
+
+	igt_subtest_f("reserve-sanity-check-simple")
+		reserve_sanity_check(fd, INTEL_ALLOCATOR_SIMPLE);
+
+	igt_subtest_f("reserve-sanity-check-bst")
+		reserve_sanity_check(fd, INTEL_ALLOCATOR_BST);
 
-	igt_subtest_f("reuse")
+	igt_subtest_f("reuse-simple")
 		reuse(fd, INTEL_ALLOCATOR_SIMPLE);
 
-	igt_subtest_f("reserve")
+	igt_subtest_f("reuse-bst")
+		reuse(fd, INTEL_ALLOCATOR_BST);
+
+	igt_subtest_f("reserve-simple")
 		reserve(fd, INTEL_ALLOCATOR_SIMPLE);
 
+	igt_subtest_f("reserve-bst")
+		reserve(fd, INTEL_ALLOCATOR_BST);
+
 	for (a = als; a->name; a++) {
 		igt_subtest_with_dynamic_f("%s-allocator", a->name) {
 			igt_dynamic("basic")
-- 
2.25.1



More information about the igt-dev mailing list