[igt-dev] [PATCH i-g-t 22/35] tests/api_intel_bb: Add purge-bb test

Zbigniew Kempczyński zbigniew.kempczynski at intel.com
Tue Feb 16 11:39:54 UTC 2021


Check address acquired is same after purging bb. For relocations
we expect 0 twice, for allocator release and alloc same address.

Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
Cc: Chris Wilson <chris at chris-wilson.co.uk>
---
 tests/i915/api_intel_bb.c | 36 ++++++++++++++++++++++++++++++++++--
 1 file changed, 34 insertions(+), 2 deletions(-)

diff --git a/tests/i915/api_intel_bb.c b/tests/i915/api_intel_bb.c
index 351fdc9f1..7b714af8e 100644
--- a/tests/i915/api_intel_bb.c
+++ b/tests/i915/api_intel_bb.c
@@ -142,6 +142,33 @@ static void reset_bb(struct buf_ops *bops)
 	intel_bb_destroy(ibb);
 }
 
+static void purge_bb(struct buf_ops *bops)
+{
+	int i915 = buf_ops_get_fd(bops);
+	struct intel_buf *buf;
+	struct intel_bb *ibb;
+	uint64_t offset0, offset1;
+
+	buf = intel_buf_create(bops, 512, 512, 32, 0, I915_TILING_NONE,
+			       I915_COMPRESSION_NONE);
+	ibb = intel_bb_create(i915, 4096);
+	intel_bb_set_debug(ibb, true);
+
+	intel_bb_add_intel_buf(ibb, buf, false);
+	offset0 = buf->addr.offset;
+
+	intel_bb_reset(ibb, true);
+	buf->addr.offset = INTEL_BUF_INVALID_ADDRESS;
+
+	intel_bb_add_intel_buf(ibb, buf, false);
+	offset1 = buf->addr.offset;
+
+	igt_assert(offset0 == offset1);
+
+	intel_buf_destroy(buf);
+	intel_bb_destroy(ibb);
+}
+
 static void simple_bb(struct buf_ops *bops, bool use_context)
 {
 	int i915 = buf_ops_get_fd(bops);
@@ -240,13 +267,15 @@ static void check_canonical(struct buf_ops *bops)
 	/* Twice same addresses to verify will be unreserved in remove path */
 	uint64_t addresses[] = { 0x800000000000, 0x800000000000, 0x400000000000 };
 	uint64_t address, start, end;
-	bool supports_48bit;
+	bool supports_48bit, relocs;
 
 	ibb = intel_bb_create(i915, PAGE_SIZE);
 	supports_48bit = ibb->supports_48b_address;
-	if (!supports_48bit)
+	relocs = ibb->enforce_relocs;
+	if (!supports_48bit || relocs)
 		intel_bb_destroy(ibb);
 	igt_require_f(supports_48bit, "We need 48bit ppgtt for testing\n");
+	igt_require_f(!relocs, "We need to use allocator instead of relocations\n");
 
 	if (debug_bb)
 		intel_bb_set_debug(ibb, true);
@@ -1527,6 +1556,9 @@ igt_main_args("dpib", NULL, help_str, opt_handler, NULL)
 	igt_subtest("reset-bb")
 		reset_bb(bops);
 
+	igt_subtest_f("purge-bb")
+		purge_bb(bops);
+
 	igt_subtest("simple-bb")
 		simple_bb(bops, false);
 
-- 
2.26.0



More information about the igt-dev mailing list