All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marius Vlad <marius.c.vlad@intel.com>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH i-g-t 7/8] tests/gem_tiled_pread_basic: Rename test and BATify.
Date: Fri, 27 May 2016 14:50:37 +0300	[thread overview]
Message-ID: <1464349838-9959-7-git-send-email-marius.c.vlad@intel.com> (raw)
In-Reply-To: <1464349838-9959-1-git-send-email-marius.c.vlad@intel.com>

Add a extended subtest and reduce the number of iteration to qualify
for BAT. Renamed to test to gem_tiled_pread.

Signed-off-by: Marius Vlad <marius.c.vlad@intel.com>
---
 tests/Makefile.sources        |   2 +-
 tests/gem_tiled_pread.c       | 231 ++++++++++++++++++++++++++++++++++++++++++
 tests/gem_tiled_pread_basic.c | 215 ---------------------------------------
 3 files changed, 232 insertions(+), 216 deletions(-)
 create mode 100644 tests/gem_tiled_pread.c
 delete mode 100644 tests/gem_tiled_pread_basic.c

diff --git a/tests/Makefile.sources b/tests/Makefile.sources
index c81eeeb..86328cb 100644
--- a/tests/Makefile.sources
+++ b/tests/Makefile.sources
@@ -175,7 +175,7 @@ TESTS_progs = \
 	gem_sync \
 	gem_threaded_access_tiled \
 	gem_tiled_fence_blits \
-	gem_tiled_pread_basic \
+	gem_tiled_pread \
 	gem_tiled_pread_pwrite \
 	gem_tiled_swapping \
 	gem_tiled_wb \
diff --git a/tests/gem_tiled_pread.c b/tests/gem_tiled_pread.c
new file mode 100644
index 0000000..bb05ac3
--- /dev/null
+++ b/tests/gem_tiled_pread.c
@@ -0,0 +1,231 @@
+/*
+ * Copyright © 2009 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ * Authors:
+ *    Eric Anholt <eric@anholt.net>
+ *
+ */
+
+/** @file gem_tiled_pread.c
+ *
+ * This is a test of pread's behavior on tiled objects with respect to the
+ * reported swizzling value.
+ *
+ * The goal is to exercise the slow_bit17_copy path for reading on bit17
+ * machines, but will also be useful for catching swizzling value bugs on
+ * other systems.
+ */
+
+#include "igt.h"
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <sys/ioctl.h>
+#include "drm.h"
+
+
+IGT_TEST_DESCRIPTION("Test pread behavior on tiled objects with respect to the"
+		     " reported swizzling value.");
+
+#define WIDTH 512
+#define HEIGHT 512
+static uint32_t linear[WIDTH * HEIGHT];
+
+#define PAGE_SIZE 4096
+
+static int tile_width;
+static int tile_height;
+static int tile_size;
+
+static uint32_t
+create_bo(int fd)
+{
+	uint32_t handle;
+	uint32_t *data;
+	int i;
+
+	handle = gem_create(fd, sizeof(linear));
+	gem_set_tiling(fd, handle, I915_TILING_X, WIDTH * sizeof(uint32_t));
+
+	/* Fill the BO with dwords starting at start_val */
+	data = gem_mmap__gtt(fd, handle, sizeof(linear),
+			     PROT_READ | PROT_WRITE);
+	for (i = 0; i < WIDTH*HEIGHT; i++)
+		data[i] = i;
+	munmap(data, sizeof(linear));
+
+	return handle;
+}
+
+static int
+swizzle_bit(int bit, int offset)
+{
+	return (offset & (1 << bit)) >> (bit - 6);
+}
+
+/* Translate from a swizzled offset in the tiled buffer to the corresponding
+ * value from the original linear buffer.
+ */
+static uint32_t
+calculate_expected(int offset)
+{
+	int tile_off = offset & (tile_size - 1);
+	int tile_base = offset & -tile_size;
+	int tile_index = tile_base / tile_size;
+	int tiles_per_row = 4*WIDTH / tile_width;
+
+	/* base x,y values from the tile (page) index. */
+	int base_y = tile_index / tiles_per_row * tile_height;
+	int base_x = tile_index % tiles_per_row * (tile_width/4);
+
+	/* x, y offsets within the tile */
+	int tile_y = tile_off / tile_width;
+	int tile_x = (tile_off % tile_width) / 4;
+
+	igt_debug("%3d, %3d, %3d,%3d\n", base_x, base_y, tile_x, tile_y);
+	return (base_y + tile_y) * WIDTH + base_x + tile_x;
+}
+
+static void
+run(int fd, uint32_t handle, uint32_t swizzle, int iter)
+{
+	int i;
+
+	/* Read a bunch of random subsets of the data and check that they come
+	 * out right.
+	 */
+	for (i = 0; i < iter; i++) {
+		int size = WIDTH * HEIGHT * 4;
+		int offset = (random() % size) & ~3;
+		int len = (random() % size) & ~3;
+		int j;
+
+		if (len == 0)
+			len = 4;
+
+		if (offset + len > size)
+			len = size - offset;
+
+		if (i == 0) {
+			offset = 0;
+			len = size;
+		}
+
+		gem_read(fd, handle, offset, linear, len);
+
+		/* Translate from offsets in the read buffer to the swizzled
+		 * address that it corresponds to.  This is the opposite of
+		 * what Mesa does (calculate offset to be read given the linear
+		 * offset it's looking for).
+		 */
+		for (j = offset; j < offset + len; j += 4) {
+			uint32_t expected_val, found_val;
+			int swizzled_offset;
+			const char *swizzle_str;
+
+			switch (swizzle) {
+			case I915_BIT_6_SWIZZLE_NONE:
+				swizzled_offset = j;
+				swizzle_str = "none";
+				break;
+			case I915_BIT_6_SWIZZLE_9:
+				swizzled_offset = j ^
+					swizzle_bit(9, j);
+				swizzle_str = "bit9";
+				break;
+			case I915_BIT_6_SWIZZLE_9_10:
+				swizzled_offset = j ^
+					swizzle_bit(9, j) ^
+					swizzle_bit(10, j);
+				swizzle_str = "bit9^10";
+				break;
+			case I915_BIT_6_SWIZZLE_9_11:
+				swizzled_offset = j ^
+					swizzle_bit(9, j) ^
+					swizzle_bit(11, j);
+				swizzle_str = "bit9^11";
+				break;
+			case I915_BIT_6_SWIZZLE_9_10_11:
+				swizzled_offset = j ^
+					swizzle_bit(9, j) ^
+					swizzle_bit(10, j) ^
+					swizzle_bit(11, j);
+				swizzle_str = "bit9^10^11";
+				break;
+			default:
+				igt_assert_f(0, "Bad swizzle bits; %d\n",
+					     swizzle);
+			}
+			expected_val = calculate_expected(swizzled_offset);
+			found_val = linear[(j - offset) / 4];
+			igt_assert_f(expected_val == found_val,
+				     "Bad read [%d]: %d instead of %d at 0x%08x "
+				     "for read from 0x%08x to 0x%08x, swizzle=%s\n",
+				     i, found_val, expected_val, j,
+				     offset, offset + len,
+				     swizzle_str);
+		}
+	}
+}
+
+igt_main
+{
+	int fd;
+
+	uint32_t tiling, swizzle;
+	uint32_t handle;
+	uint32_t devid;
+
+	igt_fixture {
+		fd = drm_open_driver(DRIVER_INTEL);
+
+		handle = create_bo(fd);
+		gem_get_tiling(fd, handle, &tiling, &swizzle);
+
+		devid = intel_get_drm_devid(fd);
+	}
+
+	if (IS_GEN2(devid)) {
+		tile_height = 16;
+		tile_width = 128;
+		tile_size = 2048;
+	} else {
+		tile_height = 8;
+		tile_width = 512;
+		tile_size = PAGE_SIZE;
+	}
+
+	igt_subtest("basic")
+		run(fd, handle, swizzle, 10);
+
+	igt_subtest("extended")
+		run(fd, handle, swizzle, 100);
+
+	igt_fixture {
+		close(fd);
+	}
+}
diff --git a/tests/gem_tiled_pread_basic.c b/tests/gem_tiled_pread_basic.c
deleted file mode 100644
index 1dfd87c..0000000
--- a/tests/gem_tiled_pread_basic.c
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
- * Copyright © 2009 Intel Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
- * IN THE SOFTWARE.
- *
- * Authors:
- *    Eric Anholt <eric@anholt.net>
- *
- */
-
-/** @file gem_tiled_pread.c
- *
- * This is a test of pread's behavior on tiled objects with respect to the
- * reported swizzling value.
- *
- * The goal is to exercise the slow_bit17_copy path for reading on bit17
- * machines, but will also be useful for catching swizzling value bugs on
- * other systems.
- */
-
-#include "igt.h"
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <fcntl.h>
-#include <inttypes.h>
-#include <errno.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-#include <sys/ioctl.h>
-#include "drm.h"
-
-
-IGT_TEST_DESCRIPTION("Test pread behavior on tiled objects with respect to the"
-		     " reported swizzling value.");
-
-#define WIDTH 512
-#define HEIGHT 512
-static uint32_t linear[WIDTH * HEIGHT];
-
-#define PAGE_SIZE 4096
-
-static int tile_width;
-static int tile_height;
-static int tile_size;
-
-static uint32_t
-create_bo(int fd)
-{
-	uint32_t handle;
-	uint32_t *data;
-	int i;
-
-	handle = gem_create(fd, sizeof(linear));
-	gem_set_tiling(fd, handle, I915_TILING_X, WIDTH * sizeof(uint32_t));
-
-	/* Fill the BO with dwords starting at start_val */
-	data = gem_mmap__gtt(fd, handle, sizeof(linear),
-			     PROT_READ | PROT_WRITE);
-	for (i = 0; i < WIDTH*HEIGHT; i++)
-		data[i] = i;
-	munmap(data, sizeof(linear));
-
-	return handle;
-}
-
-static int
-swizzle_bit(int bit, int offset)
-{
-	return (offset & (1 << bit)) >> (bit - 6);
-}
-
-/* Translate from a swizzled offset in the tiled buffer to the corresponding
- * value from the original linear buffer.
- */
-static uint32_t
-calculate_expected(int offset)
-{
-	int tile_off = offset & (tile_size - 1);
-	int tile_base = offset & -tile_size;
-	int tile_index = tile_base / tile_size;
-	int tiles_per_row = 4*WIDTH / tile_width;
-
-	/* base x,y values from the tile (page) index. */
-	int base_y = tile_index / tiles_per_row * tile_height;
-	int base_x = tile_index % tiles_per_row * (tile_width/4);
-
-	/* x, y offsets within the tile */
-	int tile_y = tile_off / tile_width;
-	int tile_x = (tile_off % tile_width) / 4;
-
-	igt_debug("%3d, %3d, %3d,%3d\n", base_x, base_y, tile_x, tile_y);
-	return (base_y + tile_y) * WIDTH + base_x + tile_x;
-}
-
-igt_simple_main
-{
-	int fd;
-	int i, iter = 100;
-	uint32_t tiling, swizzle;
-	uint32_t handle;
-	uint32_t devid;
-
-	fd = drm_open_driver(DRIVER_INTEL);
-
-	handle = create_bo(fd);
-	gem_get_tiling(fd, handle, &tiling, &swizzle);
-
-	devid = intel_get_drm_devid(fd);
-
-	if (IS_GEN2(devid)) {
-		tile_height = 16;
-		tile_width = 128;
-		tile_size = 2048;
-	} else {
-		tile_height = 8;
-		tile_width = 512;
-		tile_size = PAGE_SIZE;
-	}
-
-	/* Read a bunch of random subsets of the data and check that they come
-	 * out right.
-	 */
-	for (i = 0; i < iter; i++) {
-		int size = WIDTH * HEIGHT * 4;
-		int offset = (random() % size) & ~3;
-		int len = (random() % size) & ~3;
-		int j;
-
-		if (len == 0)
-			len = 4;
-
-		if (offset + len > size)
-			len = size - offset;
-
-		if (i == 0) {
-			offset = 0;
-			len = size;
-		}
-
-		gem_read(fd, handle, offset, linear, len);
-
-		/* Translate from offsets in the read buffer to the swizzled
-		 * address that it corresponds to.  This is the opposite of
-		 * what Mesa does (calculate offset to be read given the linear
-		 * offset it's looking for).
-		 */
-		for (j = offset; j < offset + len; j += 4) {
-			uint32_t expected_val, found_val;
-			int swizzled_offset;
-			const char *swizzle_str;
-
-			switch (swizzle) {
-			case I915_BIT_6_SWIZZLE_NONE:
-				swizzled_offset = j;
-				swizzle_str = "none";
-				break;
-			case I915_BIT_6_SWIZZLE_9:
-				swizzled_offset = j ^
-					swizzle_bit(9, j);
-				swizzle_str = "bit9";
-				break;
-			case I915_BIT_6_SWIZZLE_9_10:
-				swizzled_offset = j ^
-					swizzle_bit(9, j) ^
-					swizzle_bit(10, j);
-				swizzle_str = "bit9^10";
-				break;
-			case I915_BIT_6_SWIZZLE_9_11:
-				swizzled_offset = j ^
-					swizzle_bit(9, j) ^
-					swizzle_bit(11, j);
-				swizzle_str = "bit9^11";
-				break;
-			case I915_BIT_6_SWIZZLE_9_10_11:
-				swizzled_offset = j ^
-					swizzle_bit(9, j) ^
-					swizzle_bit(10, j) ^
-					swizzle_bit(11, j);
-				swizzle_str = "bit9^10^11";
-				break;
-			default:
-				igt_assert_f(0, "Bad swizzle bits; %d\n",
-					     swizzle);
-			}
-			expected_val = calculate_expected(swizzled_offset);
-			found_val = linear[(j - offset) / 4];
-			igt_assert_f(expected_val == found_val,
-				     "Bad read [%d]: %d instead of %d at 0x%08x "
-				     "for read from 0x%08x to 0x%08x, swizzle=%s\n",
-				     i, found_val, expected_val, j,
-				     offset, offset + len,
-				     swizzle_str);
-		}
-	}
-
-	close(fd);
-}
-- 
2.5.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2016-05-27 11:47 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-27 11:50 [PATCH i-g-t 1/8] tests/gem_exec_flush: Tune down BAT timeout to ~1sec Marius Vlad
2016-05-27 11:50 ` [PATCH i-g-t 2/8] tests/gem_ctx_switch: Tune down for BAT ~1s Marius Vlad
2016-05-27 12:00   ` Chris Wilson
2016-05-27 11:50 ` [PATCH i-g-t 3/8] tests/gem_exec_nop: Tune down timeout " Marius Vlad
2016-05-27 12:06   ` Chris Wilson
2016-05-27 11:50 ` [PATCH i-g-t 4/8] tests/gem_close_race: Tune down " Marius Vlad
2016-05-27 11:58   ` Chris Wilson
2016-05-27 12:10     ` Tvrtko Ursulin
2016-05-27 12:16       ` Chris Wilson
2016-05-27 12:31         ` Tvrtko Ursulin
2016-05-27 12:44           ` Chris Wilson
2016-05-27 12:44           ` Mika Kuoppala
2016-05-27 14:28             ` Marius Vlad
2016-05-27 14:26         ` Marius Vlad
2016-05-27 14:25       ` Marius Vlad
2016-05-27 11:50 ` [PATCH i-g-t 5/8] tests/gem_sync: Tune down for BAT to ~1s for basic-each and ~2s for basic-all Marius Vlad
2016-05-27 11:59   ` Chris Wilson
2016-05-27 11:50 ` [PATCH i-g-t 6/8] tests/gem_exec_fault: Decrease the counts to lower the time for BAT Marius Vlad
2016-05-27 12:01   ` Chris Wilson
2016-05-27 11:50 ` Marius Vlad [this message]
2016-05-27 12:03   ` [PATCH i-g-t 7/8] tests/gem_tiled_pread_basic: Rename test and BATify Chris Wilson
2016-05-27 11:50 ` [PATCH i-g-t 8/8] tests/gem_exec_suspend: Remove hibernate test from BAT Marius Vlad
2016-05-27 12:00   ` Chris Wilson
2016-05-27 11:58 ` [PATCH i-g-t 1/8] tests/gem_exec_flush: Tune down BAT timeout to ~1sec Chris Wilson

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=1464349838-9959-7-git-send-email-marius.c.vlad@intel.com \
    --to=marius.c.vlad@intel.com \
    --cc=intel-gfx@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.