All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrzej Turko <andrzej.turko@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t 4/4] tests/i915_api_intel_allocator: Add the BST allocator
Date: Tue, 20 Jul 2021 16:12:32 +0200	[thread overview]
Message-ID: <20210720141232.12812-5-andrzej.turko@linux.intel.com> (raw)
In-Reply-To: <20210720141232.12812-1-andrzej.turko@linux.intel.com>

Include the BST allocator in the allocator test.

Signed-off-by: Andrzej Turko <andrzej.turko@linux.intel.com>
Cc: Zbigniew Kempczyński <zbigniew.kempczynski@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

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

  parent reply	other threads:[~2021-07-20 14:12 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-20 14:12 [igt-dev] [PATCH i-g-t v2 0/4] Implement the BST allocator Andrzej Turko
2021-07-20 14:12 ` [igt-dev] [PATCH i-g-t 1/4] lib/intel_allocator: Fix argument names in declarations Andrzej Turko
2021-07-21  9:19   ` Zbigniew Kempczyński
2021-07-20 14:12 ` [igt-dev] [PATCH i-g-t 2/4] lib/igt_bst: Add a BST interface and an AVL implementation Andrzej Turko
2021-07-20 14:12 ` [igt-dev] [PATCH i-g-t 3/4] lib/intel_allocator_bst: Implement the allocator with a BST Andrzej Turko
2021-07-20 14:12 ` Andrzej Turko [this message]
2021-07-20 15:21 ` [igt-dev] ✓ Fi.CI.BAT: success for Implement the BST allocator (rev2) Patchwork
2021-07-20 16:31 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
  -- strict thread matches above, loose matches on Subject: below --
2021-07-20 13:27 [igt-dev] [PATCH i-g-t 0/4] Implement the BST allocator Andrzej Turko
2021-07-20 13:27 ` [igt-dev] [PATCH i-g-t 4/4] tests/i915_api_intel_allocator: Add " Andrzej Turko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210720141232.12812-5-andrzej.turko@linux.intel.com \
    --to=andrzej.turko@linux.intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.