summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2014-11-04 07:30:57 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2014-11-04 12:09:26 +0000
commitc45216b26d223ffd7f68c5794870214445a64b5c (patch)
tree8a731aec64c5348e5a7044c5fe8dd761f4b6603d
parent6fff1f8787687a08f66c28007abe1f1edebd5124 (diff)
igt/gem_tiled_wb: Exercise CPU mmaps with swizzling
This exercises the the extended get_tiling ioctl in order to determine proper swizzling for direct access to objects through WB. Userspace cannot handle bit17 swizzling through wc mmaps (because bit17 requires swizzling based on the actual physical address of the page - which is unknown to userspace) and so we need an extended get_tiling ioctl to report the actual as well as the logical swizzling on an object. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--tests/.gitignore1
-rw-r--r--tests/12
-rw-r--r--tests/Makefile.sources1
-rwxr-xr-xtests/blt_stressbin0 -> 98316 bytes
-rwxr-xr-xtests/ddi_compute_wrpllbin0 -> 280432 bytes
-rwxr-xr-xtests/drm_get_client_authbin0 -> 137168 bytes
-rwxr-xr-xtests/flip_testbin0 -> 176334 bytes
-rwxr-xr-xtests/gem_cacheingbin0 -> 151711 bytes
-rwxr-xr-xtests/gem_cpu_concurrent_blitbin0 -> 148260 bytes
-rwxr-xr-xtests/gem_gtt_concurrent_blitbin0 -> 149984 bytes
-rwxr-xr-xtests/gem_mmap_wcbin0 -> 293152 bytes
-rwxr-xr-xtests/gem_suspendbin0 -> 143313 bytes
-rw-r--r--tests/gem_tiled_wb.c240
-rwxr-xr-xtests/gem_tiled_wcbin0 -> 281656 bytes
-rwxr-xr-xtests/gem_userptr_copybin0 -> 121643 bytes
-rwxr-xr-xtests/gem_userptr_mmapbin0 -> 116904 bytes
-rwxr-xr-xtests/gem_vmap_blitsbin0 -> 206089 bytes
-rwxr-xr-xtests/gem_wait_render_timeoutbin0 -> 812824 bytes
-rwxr-xr-xtests/getclientbin0 -> 136312 bytes
-rwxr-xr-xtests/getstatsbin0 -> 136511 bytes
-rwxr-xr-xtests/getversionbin0 -> 136599 bytes
-rwxr-xr-xtests/igt_fork_helperbin0 -> 269200 bytes
-rwxr-xr-xtests/igt_list_onlybin0 -> 269344 bytes
-rwxr-xr-xtests/igt_no_exitbin0 -> 269272 bytes
-rwxr-xr-xtests/igt_no_exit_list_onlybin0 -> 269352 bytes
-rwxr-xr-xtests/igt_no_subtestbin0 -> 269120 bytes
-rwxr-xr-xtests/igt_simulationbin0 -> 276256 bytes
-rwxr-xr-xtests/llc_exec_bltbin0 -> 109364 bytes
-rwxr-xr-xtests/pc8bin0 -> 228389 bytes
-rwxr-xr-xtests/pm_pc8bin0 -> 615365 bytes
-rwxr-xr-xtests/skl_ddb_allocationbin0 -> 20216 bytes
-rwxr-xr-xtests/sysfs_rc6_residencybin0 -> 143709 bytes
-rwxr-xr-xtests/sysfs_rpsbin0 -> 146269 bytes
-rw-r--r--tests/trace.datbin0 -> 1212416 bytes
34 files changed, 244 insertions, 0 deletions
diff --git a/tests/.gitignore b/tests/.gitignore
index da8b4170..3d8b9148 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -99,6 +99,7 @@ gem_tiled_partial_pwrite_pread
gem_tiled_pread
gem_tiled_pread_pwrite
gem_tiled_swapping
+gem_tiled_wb
gem_tiling_max_stride
gem_unfence_active_buffers
gem_unref_active_buffers
diff --git a/tests/1 b/tests/1
new file mode 100644
index 00000000..9b64bfe8
--- /dev/null
+++ b/tests/1
@@ -0,0 +1,2 @@
+cat: /sys/kernel/debug/dri/0/i915_emon_status: No such device
+cat: 2: No such file or directory
diff --git a/tests/Makefile.sources b/tests/Makefile.sources
index 8debfec9..afbe597c 100644
--- a/tests/Makefile.sources
+++ b/tests/Makefile.sources
@@ -132,6 +132,7 @@ TESTS_progs = \
gem_tiled_pread \
gem_tiled_pread_pwrite \
gem_tiled_swapping \
+ gem_tiled_wb \
gem_tiling_max_stride \
gem_unfence_active_buffers \
gem_unref_active_buffers \
diff --git a/tests/blt_stress b/tests/blt_stress
new file mode 100755
index 00000000..31251a79
--- /dev/null
+++ b/tests/blt_stress
Binary files differ
diff --git a/tests/ddi_compute_wrpll b/tests/ddi_compute_wrpll
new file mode 100755
index 00000000..8be91200
--- /dev/null
+++ b/tests/ddi_compute_wrpll
Binary files differ
diff --git a/tests/drm_get_client_auth b/tests/drm_get_client_auth
new file mode 100755
index 00000000..6500ef35
--- /dev/null
+++ b/tests/drm_get_client_auth
Binary files differ
diff --git a/tests/flip_test b/tests/flip_test
new file mode 100755
index 00000000..f722a926
--- /dev/null
+++ b/tests/flip_test
Binary files differ
diff --git a/tests/gem_cacheing b/tests/gem_cacheing
new file mode 100755
index 00000000..d3111f55
--- /dev/null
+++ b/tests/gem_cacheing
Binary files differ
diff --git a/tests/gem_cpu_concurrent_blit b/tests/gem_cpu_concurrent_blit
new file mode 100755
index 00000000..2b93bd81
--- /dev/null
+++ b/tests/gem_cpu_concurrent_blit
Binary files differ
diff --git a/tests/gem_gtt_concurrent_blit b/tests/gem_gtt_concurrent_blit
new file mode 100755
index 00000000..1fcdd893
--- /dev/null
+++ b/tests/gem_gtt_concurrent_blit
Binary files differ
diff --git a/tests/gem_mmap_wc b/tests/gem_mmap_wc
new file mode 100755
index 00000000..8ef36e9d
--- /dev/null
+++ b/tests/gem_mmap_wc
Binary files differ
diff --git a/tests/gem_suspend b/tests/gem_suspend
new file mode 100755
index 00000000..b7c189c2
--- /dev/null
+++ b/tests/gem_suspend
Binary files differ
diff --git a/tests/gem_tiled_wb.c b/tests/gem_tiled_wb.c
new file mode 100644
index 00000000..9d9a5a95
--- /dev/null
+++ b/tests/gem_tiled_wb.c
@@ -0,0 +1,240 @@
+/*
+ * 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.
+ */
+
+/** @file gem_tiled_wc.c
+ *
+ * This is a test of write-combining mmap's behavior on tiled objects
+ * with respect to the reported swizzling value.
+ *
+ * The goal is to exercise the complications that arise when using a linear
+ * view of a tiled object that is subject to hardware swizzling. This is
+ * useful to check that we are presenting the correct view of the object
+ * to userspace, and that userspace has to respect the swizzle.
+ */
+
+#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"
+#include "ioctl_wrappers.h"
+#include "drmtest.h"
+#include "intel_io.h"
+#include "intel_chipset.h"
+
+#define WIDTH 512
+#define HEIGHT 512
+#define SIZE (WIDTH*HEIGHT*sizeof(uint32_t))
+
+#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, SIZE);
+ gem_set_tiling(fd, handle, I915_TILING_X, WIDTH * sizeof(uint32_t));
+
+ /* Write throught the fence to tiled the data.
+ * We then manually detile on reading back through the mmap(wc).
+ */
+ data = gem_mmap__gtt(fd, handle, SIZE, PROT_READ | PROT_WRITE);
+ for (i = 0; i < WIDTH*HEIGHT; i++)
+ data[i] = i;
+ munmap(data, SIZE);
+
+ gem_set_domain(fd, handle, I915_GEM_DOMAIN_CPU, 0);
+ 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
+get_tiling(int fd, uint32_t handle, uint32_t *tiling, uint32_t *swizzle)
+{
+ struct drm_i915_gem_get_tiling2 {
+ uint32_t handle;
+ uint32_t tiling_mode;
+ uint32_t swizzle_mode;
+ uint32_t phys_swizzle_mode;
+ } arg;
+#define DRM_IOCTL_I915_GEM_GET_TILING2 DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_GET_TILING, struct drm_i915_gem_get_tiling2)
+
+ memset(&arg, 0, sizeof(arg));
+ arg.handle = handle;
+
+ do_or_die(drmIoctl(fd, DRM_IOCTL_I915_GEM_GET_TILING2, &arg));
+ igt_require(arg.phys_swizzle_mode == arg.swizzle_mode);
+
+ *tiling = arg.tiling_mode;
+ *swizzle = arg.swizzle_mode;
+}
+
+igt_simple_main
+{
+ int fd;
+ int i, iter = 100;
+ uint32_t tiling, swizzle;
+ uint32_t handle;
+
+ fd = drm_open_any();
+ igt_require_mmap_wc(fd);
+
+ handle = create_bo(fd);
+ get_tiling(fd, handle, &tiling, &swizzle);
+
+ if (IS_GEN2(intel_get_drm_devid(fd))) {
+ 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 first_page, last_page;
+ uint32_t *linear;
+ int j;
+
+ if (len == 0)
+ len = 4;
+
+ if (offset + len > size)
+ len = size - offset;
+
+ if (i == 0) {
+ offset = 0;
+ len = size;
+ }
+
+ first_page = offset & ~(PAGE_SIZE-1);
+ last_page = (offset + len + PAGE_SIZE) & ~(PAGE_SIZE-1);
+ offset -= first_page;
+
+ linear = gem_mmap__cpu(fd, handle, first_page, last_page - first_page, PROT_READ);
+ igt_assert(linear);
+
+
+ /* 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 = j + first_page;
+ const char *swizzle_str;
+
+ switch (swizzle) {
+ case I915_BIT_6_SWIZZLE_NONE:
+ swizzle_str = "none";
+ break;
+ case I915_BIT_6_SWIZZLE_9:
+ swizzled_offset ^=
+ swizzle_bit(9, swizzled_offset);
+ swizzle_str = "bit9";
+ break;
+ case I915_BIT_6_SWIZZLE_9_10:
+ swizzled_offset ^=
+ swizzle_bit(9, swizzled_offset) ^
+ swizzle_bit(10, swizzled_offset);
+ swizzle_str = "bit9^10";
+ break;
+ case I915_BIT_6_SWIZZLE_9_11:
+ swizzled_offset ^=
+ swizzle_bit(9, swizzled_offset) ^
+ swizzle_bit(11, swizzled_offset);
+ swizzle_str = "bit9^11";
+ break;
+ case I915_BIT_6_SWIZZLE_9_10_11:
+ swizzled_offset ^=
+ swizzle_bit(9, swizzled_offset) ^
+ swizzle_bit(10, swizzled_offset) ^
+ swizzle_bit(11, swizzled_offset);
+ swizzle_str = "bit9^10^11";
+ break;
+ default:
+ igt_skip("unknown swizzling");
+ break;
+ }
+ expected_val = calculate_expected(swizzled_offset);
+ found_val = linear[j / 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 + first_page,
+ offset, offset + len,
+ swizzle_str);
+ }
+ munmap(linear, last_page - first_page);
+ }
+
+ close(fd);
+}
diff --git a/tests/gem_tiled_wc b/tests/gem_tiled_wc
new file mode 100755
index 00000000..49670616
--- /dev/null
+++ b/tests/gem_tiled_wc
Binary files differ
diff --git a/tests/gem_userptr_copy b/tests/gem_userptr_copy
new file mode 100755
index 00000000..11880649
--- /dev/null
+++ b/tests/gem_userptr_copy
Binary files differ
diff --git a/tests/gem_userptr_mmap b/tests/gem_userptr_mmap
new file mode 100755
index 00000000..a946149a
--- /dev/null
+++ b/tests/gem_userptr_mmap
Binary files differ
diff --git a/tests/gem_vmap_blits b/tests/gem_vmap_blits
new file mode 100755
index 00000000..d5696807
--- /dev/null
+++ b/tests/gem_vmap_blits
Binary files differ
diff --git a/tests/gem_wait_render_timeout b/tests/gem_wait_render_timeout
new file mode 100755
index 00000000..13593d2d
--- /dev/null
+++ b/tests/gem_wait_render_timeout
Binary files differ
diff --git a/tests/getclient b/tests/getclient
new file mode 100755
index 00000000..8a615ef2
--- /dev/null
+++ b/tests/getclient
Binary files differ
diff --git a/tests/getstats b/tests/getstats
new file mode 100755
index 00000000..ae763db5
--- /dev/null
+++ b/tests/getstats
Binary files differ
diff --git a/tests/getversion b/tests/getversion
new file mode 100755
index 00000000..6ea9d1ac
--- /dev/null
+++ b/tests/getversion
Binary files differ
diff --git a/tests/igt_fork_helper b/tests/igt_fork_helper
new file mode 100755
index 00000000..86a330fe
--- /dev/null
+++ b/tests/igt_fork_helper
Binary files differ
diff --git a/tests/igt_list_only b/tests/igt_list_only
new file mode 100755
index 00000000..9861b725
--- /dev/null
+++ b/tests/igt_list_only
Binary files differ
diff --git a/tests/igt_no_exit b/tests/igt_no_exit
new file mode 100755
index 00000000..a55fa1fd
--- /dev/null
+++ b/tests/igt_no_exit
Binary files differ
diff --git a/tests/igt_no_exit_list_only b/tests/igt_no_exit_list_only
new file mode 100755
index 00000000..bf30876e
--- /dev/null
+++ b/tests/igt_no_exit_list_only
Binary files differ
diff --git a/tests/igt_no_subtest b/tests/igt_no_subtest
new file mode 100755
index 00000000..8fc79b6e
--- /dev/null
+++ b/tests/igt_no_subtest
Binary files differ
diff --git a/tests/igt_simulation b/tests/igt_simulation
new file mode 100755
index 00000000..1d3717c5
--- /dev/null
+++ b/tests/igt_simulation
Binary files differ
diff --git a/tests/llc_exec_blt b/tests/llc_exec_blt
new file mode 100755
index 00000000..0c8a115d
--- /dev/null
+++ b/tests/llc_exec_blt
Binary files differ
diff --git a/tests/pc8 b/tests/pc8
new file mode 100755
index 00000000..5175580a
--- /dev/null
+++ b/tests/pc8
Binary files differ
diff --git a/tests/pm_pc8 b/tests/pm_pc8
new file mode 100755
index 00000000..16b216e8
--- /dev/null
+++ b/tests/pm_pc8
Binary files differ
diff --git a/tests/skl_ddb_allocation b/tests/skl_ddb_allocation
new file mode 100755
index 00000000..7858f918
--- /dev/null
+++ b/tests/skl_ddb_allocation
Binary files differ
diff --git a/tests/sysfs_rc6_residency b/tests/sysfs_rc6_residency
new file mode 100755
index 00000000..3ccef436
--- /dev/null
+++ b/tests/sysfs_rc6_residency
Binary files differ
diff --git a/tests/sysfs_rps b/tests/sysfs_rps
new file mode 100755
index 00000000..d5349bcc
--- /dev/null
+++ b/tests/sysfs_rps
Binary files differ
diff --git a/tests/trace.dat b/tests/trace.dat
new file mode 100644
index 00000000..a56d21d2
--- /dev/null
+++ b/tests/trace.dat
Binary files differ