[PATCH i-g-t] tests/gem_ccs: Add subtests

apoorva1.singh at intel.com apoorva1.singh at intel.com
Sun Feb 13 10:40:18 UTC 2022


From: Apoorva Singh <apoorva1.singh at intel.com>

- Verify ccs data is binded to physical memory by using
  XY_CTRL_SURF_COPY_BLT command in separate context.

- Introduce suspend/resume and verify validity of objects.

Signed-off-by: Apoorva Singh <apoorva1.singh at intel.com>
Cc: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
---
 tests/i915/gem_ccs.c | 74 ++++++++++++++++++++++++++++++++++++--------
 1 file changed, 61 insertions(+), 13 deletions(-)

diff --git a/tests/i915/gem_ccs.c b/tests/i915/gem_ccs.c
index 33b79d86..5ddc5219 100644
--- a/tests/i915/gem_ccs.c
+++ b/tests/i915/gem_ccs.c
@@ -4,6 +4,7 @@
  */
 
 #include <errno.h>
+#include <glib.h>
 #include <sys/ioctl.h>
 #include <sys/time.h>
 #include <malloc.h>
@@ -42,6 +43,8 @@ struct test_config {
 	bool compression;
 	bool inplace;
 	bool surfcopy;
+	bool new_ctx;
+	bool suspend_resume;
 };
 
 static void set_object(struct blt_copy_object *obj,
@@ -162,21 +165,23 @@ static void surf_copy(int i915,
 		      const struct blt_copy_object *src,
 		      const struct blt_copy_object *mid,
 		      const struct blt_copy_object *dst,
-		      int run_id)
+		      int run_id, bool suspend_resume)
 {
 	struct blt_copy_data blt = {};
 	struct blt_block_copy_data_ext ext = {};
 	struct blt_ctrl_surf_copy_data surf = {};
-	uint32_t bb, bb2, ccs, *ccsmap, bb_size = 4096;
+	uint32_t bb, bb2, ccs, ccs2, *ccsmap, *ccsmap2, bb_size = 4096;
 	uint64_t ccssize = mid->size / CCS_RATIO;
 	uint32_t *ccscopy;
 	int result;
+	char *orig, *orig2, *new, *new2;
 
 	igt_assert(mid->compression);
 	ccscopy = (uint32_t *) malloc(ccssize);
 	bb = gem_create(i915, bb_size);
 	bb2 = gem_create(i915, bb_size);
 	ccs = gem_create(i915, ccssize);
+	ccs2 = gem_create(i915, ccssize);
 
 	surf.i915 = i915;
 	surf.print_bb = param.print_bb;
@@ -192,6 +197,27 @@ static void surf_copy(int i915,
 					   PROT_READ | PROT_WRITE);
 	memcpy(ccscopy, ccsmap, ccssize);
 
+	if (suspend_resume) {
+		orig = g_compute_checksum_for_data(G_CHECKSUM_SHA1, (void *)ccsmap, surf.dst.size);
+		orig2 = g_compute_checksum_for_data(G_CHECKSUM_SHA1, (void *)mid->ptr, mid->size);
+
+		igt_system_suspend_autoresume(SUSPEND_STATE_FREEZE, SUSPEND_TEST_NONE);
+
+		set_surf_object(&surf.dst, ccs2, REGION_SMEM, ccssize,
+				0, DIRECT_ACCESS);
+		blt_ctrl_surf_copy(i915, ctx, e, ahnd, &surf);
+		gem_sync(i915, surf.dst.handle);
+
+		ccsmap2 = gem_mmap__device_coherent(i915, ccs2, 0, surf.dst.size,
+						    PROT_READ | PROT_WRITE);
+		new = g_compute_checksum_for_data(G_CHECKSUM_SHA1, (void *)ccsmap2, surf.dst.size);
+		new2 = g_compute_checksum_for_data(G_CHECKSUM_SHA1, (void *)mid->ptr, mid->size);
+
+		igt_assert(!strcmp(orig, new));
+		igt_assert(!strcmp(orig2, new2));
+		munmap(ccsmap2, ccssize);
+	}
+
 	/* corrupt ccs */
 	for (int i = 0; i < surf.dst.size / sizeof(uint32_t); i++)
 		ccsmap[i] = i;
@@ -229,15 +255,15 @@ static void surf_copy(int i915,
 	gem_close(i915, bb);
 	gem_close(i915, bb2);
 	gem_close(i915, ccs);
+	gem_close(i915, ccs2);
 }
 
 static void block_copy(int i915,
 		       const intel_ctx_t *ctx,
 		       const struct intel_execution_engine2 *e,
 		       uint32_t region1, uint32_t region2,
-		       enum blt_tiling mid_tiling, bool compression,
-		       bool inplace,
-		       bool surfcopy)
+		       enum blt_tiling mid_tiling,
+		       const struct test_config *config)
 {
 	struct blt_copy_data blt = {};
 	struct blt_block_copy_data_ext ext = {}, *pext = &ext;
@@ -251,7 +277,7 @@ static void block_copy(int i915,
 	uint32_t run_id = mid_tiling;
 	uint32_t mid_region = region2, bb;
 	uint32_t width = param.width, height = param.height;
-	enum blt_compression mid_compression = compression;
+	enum blt_compression mid_compression = config->compression;
 	int mid_compression_format = param.compression_format;
 	enum blt_compression_type comp_type = COMPRESSION_TYPE_3D;
 	int result;
@@ -290,8 +316,17 @@ static void block_copy(int i915,
 	WRITE_PNG(i915, run_id, "src", &blt.src, width, height);
 	WRITE_PNG(i915, run_id, "mid", &blt.dst, width, height);
 
-	if (surfcopy && pext)
-		surf_copy(i915, ctx, e, ahnd, src, mid, dst, run_id);
+	if (config->surfcopy && pext) {
+		const intel_ctx_t *surf_ctx = ctx;
+
+		if (config->new_ctx)
+			surf_ctx = intel_ctx_create(i915, &ctx->cfg);
+
+		surf_copy(i915, surf_ctx, e, ahnd, src, mid, dst, run_id, config->suspend_resume);
+
+		if (surf_ctx != ctx)
+			intel_ctx_destroy(i915, surf_ctx);
+	}
 
 	memset(&blt, 0, sizeof(blt));
 	blt.color_depth = CD_32bit;
@@ -300,7 +335,7 @@ static void block_copy(int i915,
 	set_blt_object(&blt.dst, dst);
 	set_object_ext(&ext.src, mid_compression_format, width, height, SURFACE_TYPE_2D);
 	set_object_ext(&ext.dst, 0, width, height, SURFACE_TYPE_2D);
-	if (inplace) {
+	if (config->inplace) {
 		set_object(&blt.dst, mid->handle, dst->size, mid->region, 0,
 			   T_LINEAR, COMPRESSION_DISABLED, comp_type);
 		blt.dst.ptr = mid->ptr;
@@ -364,10 +399,7 @@ static void block_copy_test(int i915,
 					      param.compression_format, regtxt) {
 					block_copy(i915, ctx, e,
 						   region1, region2,
-						   tiling,
-						   config->compression,
-						   config->inplace,
-						   config->surfcopy);
+						   tiling, config);
 				}
 				free(regtxt);
 			}
@@ -478,6 +510,22 @@ igt_main_args("bf:pst:W:H:I:", NULL, help_str, opt_handler, NULL)
 		block_copy_test(i915, &config, ctx, set);
 	}
 
+	igt_subtest_with_dynamic("ctrl-surf-copy-new-ctx") {
+		struct test_config config = { .compression = true,
+					      .surfcopy = true,
+					      .new_ctx = true };
+
+		block_copy_test(i915, &config, ctx, set);
+	}
+
+	igt_subtest_with_dynamic("suspend-resume") {
+		struct test_config config = { .compression = true,
+					      .surfcopy = true,
+					      .suspend_resume = true };
+
+		block_copy_test(i915, &config, ctx, set);
+	}
+
 	igt_fixture {
 		igt_disallow_hang(i915, hang);
 		close(i915);
-- 
2.25.1



More information about the Intel-gfx-trybot mailing list