All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vanshidhar Konda <vanshidhar.r.konda@intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH] i915/gem_linear_blits: Use buffer with variable width and height
Date: Mon,  4 Nov 2019 17:03:37 -0800	[thread overview]
Message-ID: <20191105010337.153654-1-vanshidhar.r.konda@intel.com> (raw)

Currently the test uses a hardcoded width and height of 512 each. The
test is being extended to take width and height as variables instead.
The function used to copy the buffer is also passed as an argument -
this allows us to extend the test with different copy functions.

Signed-off-by: Vanshidhar Konda <vanshidhar.r.konda@intel.com>
---
 tests/i915/gem_linear_blits.c | 74 ++++++++++++++++++++---------------
 1 file changed, 42 insertions(+), 32 deletions(-)

diff --git a/tests/i915/gem_linear_blits.c b/tests/i915/gem_linear_blits.c
index 07ca2f29..8010679b 100644
--- a/tests/i915/gem_linear_blits.c
+++ b/tests/i915/gem_linear_blits.c
@@ -49,13 +49,8 @@
 IGT_TEST_DESCRIPTION("Test doing many blits with a working set larger than the"
 		     " aperture size.");
 
-#define WIDTH 512
-#define HEIGHT 512
-
-static uint32_t linear[WIDTH*HEIGHT];
-
 static void
-copy(int fd, uint32_t dst, uint32_t src)
+copy(int fd, uint32_t dst, uint32_t src, uint32_t width, uint32_t height)
 {
 	uint32_t batch[12];
 	struct drm_i915_gem_relocation_entry reloc[2];
@@ -73,14 +68,14 @@ copy(int fd, uint32_t dst, uint32_t src)
 
 	batch[i++] = (3 << 24) | /* 32 bits */
 		  (0xcc << 16) | /* copy ROP */
-		  WIDTH*4;
+		  width*4;
 	batch[i++] = 0; /* dst x1,y1 */
-	batch[i++] = (HEIGHT << 16) | WIDTH; /* dst x2,y2 */
+	batch[i++] = (height << 16) | width; /* dst x2,y2 */
 	batch[i++] = 0; /* dst reloc */
 	if (intel_gen(intel_get_drm_devid(fd)) >= 8)
 		batch[i++] = 0;
 	batch[i++] = 0; /* src x1,y1 */
-	batch[i++] = WIDTH*4;
+	batch[i++] = width*4;
 	batch[i++] = 0; /* src reloc */
 	if (intel_gen(intel_get_drm_devid(fd)) >= 8)
 		batch[i++] = 0;
@@ -123,31 +118,33 @@ copy(int fd, uint32_t dst, uint32_t src)
 }
 
 static uint32_t
-create_bo(int fd, uint32_t val)
+create_bo(int fd, uint32_t val, uint32_t width, uint32_t height,
+	  uint32_t *linear)
 {
 	uint32_t handle;
 	int i;
 
-	handle = gem_create(fd, sizeof(linear));
+	handle = gem_create(fd, (sizeof(uint32_t)*width*height));
 
 	/* Fill the BO with dwords starting at val */
-	for (i = 0; i < WIDTH*HEIGHT; i++)
+	for (i = 0; i < width*height; i++)
 		linear[i] = val++;
-	gem_write(fd, handle, 0, linear, sizeof(linear));
+	gem_write(fd, handle, 0, linear, sizeof(uint32_t)*width*height);
 
 	return handle;
 }
 
 static void
-check_bo(int fd, uint32_t handle, uint32_t val)
+check_bo(int fd, uint32_t handle, uint32_t val, uint32_t width,
+	 uint32_t height, uint32_t *linear)
 {
 	int num_errors;
 	int i;
 
-	gem_read(fd, handle, 0, linear, sizeof(linear));
+	gem_read(fd, handle, 0, linear, sizeof(uint32_t)*width*height);
 
 	num_errors = 0;
-	for (i = 0; i < WIDTH*HEIGHT; i++) {
+	for (i = 0; i < width*height; i++) {
 		if (linear[i] != val && num_errors++ < 32)
 			igt_warn("[%08x] Expected 0x%08x, found 0x%08x (difference 0x%08x)\n",
 				 i * 4, val, linear[i], val ^ linear[i]);
@@ -156,7 +153,10 @@ check_bo(int fd, uint32_t handle, uint32_t val)
 	igt_assert_eq(num_errors, 0);
 }
 
-static void run_test(int fd, int count)
+static void run_test(int fd, int count, uint32_t width,
+		     uint32_t height, uint32_t *linear,
+		     void (*copy_func)(int, uint32_t, uint32_t,
+				       uint32_t, uint32_t))
 {
 	uint32_t *handle, *start_val;
 	uint32_t start = 0;
@@ -168,36 +168,36 @@ static void run_test(int fd, int count)
 	start_val = handle + count;
 
 	for (i = 0; i < count; i++) {
-		handle[i] = create_bo(fd, start);
+		handle[i] = create_bo(fd, start, width, height, linear);
 		start_val[i] = start;
 		start += 1024 * 1024 / 4;
 	}
 
 	igt_debug("Verifying initialisation...\n");
 	for (i = 0; i < count; i++)
-		check_bo(fd, handle[i], start_val[i]);
+		check_bo(fd, handle[i], start_val[i], width, height, linear);
 
 	igt_debug("Cyclic blits, forward...\n");
 	for (i = 0; i < count * 4; i++) {
 		int src = i % count;
 		int dst = (i + 1) % count;
 
-		copy(fd, handle[dst], handle[src]);
+		copy_func(fd, handle[dst], handle[src], width, height);
 		start_val[dst] = start_val[src];
 	}
 	for (i = 0; i < count; i++)
-		check_bo(fd, handle[i], start_val[i]);
+		check_bo(fd, handle[i], start_val[i], width, height, linear);
 
 	igt_debug("Cyclic blits, backward...\n");
 	for (i = 0; i < count * 4; i++) {
 		int src = (i + 1) % count;
 		int dst = i % count;
 
-		copy(fd, handle[dst], handle[src]);
+		copy_func(fd, handle[dst], handle[src], width, height);
 		start_val[dst] = start_val[src];
 	}
 	for (i = 0; i < count; i++)
-		check_bo(fd, handle[i], start_val[i]);
+		check_bo(fd, handle[i], start_val[i], width, height, linear);
 
 	igt_debug("Random blits...\n");
 	for (i = 0; i < count * 4; i++) {
@@ -207,11 +207,11 @@ static void run_test(int fd, int count)
 		if (src == dst)
 			continue;
 
-		copy(fd, handle[dst], handle[src]);
+		copy_func(fd, handle[dst], handle[src], width, height);
 		start_val[dst] = start_val[src];
 	}
 	for (i = 0; i < count; i++) {
-		check_bo(fd, handle[i], start_val[i]);
+		check_bo(fd, handle[i], start_val[i], width, height, linear);
 		gem_close(fd, handle[i]);
 	}
 
@@ -223,6 +223,8 @@ static void run_test(int fd, int count)
 igt_main
 {
 	int fd = 0;
+	uint32_t width, height;
+	uint32_t *linear;
 
 	igt_fixture {
 		fd = drm_open_driver(DRIVER_INTEL);
@@ -230,34 +232,42 @@ igt_main
 		gem_require_blitter(fd);
 	}
 
-	igt_subtest("basic")
-		run_test(fd, 2);
+	igt_subtest("basic") {
+		width = 1024;
+		height = 512;
+		linear = malloc(sizeof(uint32_t)*width*height);
+		run_test(fd, 2, width, height, linear, copy);
+	}
 
 	igt_subtest("normal") {
 		uint64_t count;
+		width = 512;
+		height = 512;
 
 		count = gem_aperture_size(fd);
 		if (count >> 32)
 			count = MAX_32b;
 		count = 3 * count / (1024*1024) / 2;
 		igt_require(count > 1);
-		intel_require_memory(count, sizeof(linear), CHECK_RAM);
+		intel_require_memory(count, sizeof(uint32_t), CHECK_RAM);
 
-		run_test(fd, count);
+		run_test(fd, count, width, height, linear, copy);
 	}
 
 	igt_subtest("interruptible") {
 		uint64_t count;
-
+		width = 512;
+		height = 512;
 		count = gem_aperture_size(fd);
 		if (count >> 32)
 			count = MAX_32b;
 		count = 3 * count / (1024*1024) / 2;
 		igt_require(count > 1);
-		intel_require_memory(count, sizeof(linear), CHECK_RAM);
+		intel_require_memory(count, sizeof(uint32_t), CHECK_RAM);
 
+		linear = malloc(sizeof(uint32_t)*width*height);
 		igt_fork_signal_helper();
-		run_test(fd, count);
+		run_test(fd, count, width, height, linear, copy);
 		igt_stop_signal_helper();
 	}
 }
-- 
2.23.0

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

             reply	other threads:[~2019-11-05  1:03 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-05  1:03 Vanshidhar Konda [this message]
2019-11-05  2:01 ` [igt-dev] ✓ Fi.CI.BAT: success for i915/gem_linear_blits: Use buffer with variable width and height Patchwork
2019-11-05 11:10 ` [igt-dev] [PATCH] " Chris Wilson
2019-11-05 14:26 ` [igt-dev] ✗ Fi.CI.IGT: failure for " Patchwork

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=20191105010337.153654-1-vanshidhar.r.konda@intel.com \
    --to=vanshidhar.r.konda@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.