Re: [Intel-gfx] [PATCH 3/4] tests/gem_userptr_blits: Expanded userptr test cases

2014-02-04 Thread Daniel Vetter
On Mon, Feb 03, 2014 at 10:59:42AM +, Tvrtko Ursulin wrote:
 From: Tvrtko Ursulin tvrtko.ursu...@intel.com
 
 A set of userptr test cases to support the new feature.
 
 For the eviction and swapping stress testing I have extracted
 some common behaviour from gem_evict_everything and made both
 test cases use it to avoid duplicating the code.
 
 Both unsynchronized and synchronized userptr objects are
 tested but the latter set of tests will be skipped if kernel
 is compiled without MMU_NOTIFIERS.
 
 Also, with 32-bit userspace swapping tests are skipped if
 the system has a lot more RAM than process address space.
 Forking swapping tests are not skipped since they can still
 trigger swapping by cumulative effect.
 
 Signed-off-by: Tvrtko Ursulin tvrtko.ursu...@intel.com

Nitpick on process: Please keep in per-patch changelog in the commit
message and update it every time you resend the patches (only if something
changed in that patch ofc). Makes it easier to keep track of things.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH 3/4] tests/gem_userptr_blits: Expanded userptr test cases

2014-02-03 Thread Tvrtko Ursulin
From: Tvrtko Ursulin tvrtko.ursu...@intel.com

A set of userptr test cases to support the new feature.

For the eviction and swapping stress testing I have extracted
some common behaviour from gem_evict_everything and made both
test cases use it to avoid duplicating the code.

Both unsynchronized and synchronized userptr objects are
tested but the latter set of tests will be skipped if kernel
is compiled without MMU_NOTIFIERS.

Also, with 32-bit userspace swapping tests are skipped if
the system has a lot more RAM than process address space.
Forking swapping tests are not skipped since they can still
trigger swapping by cumulative effect.

Signed-off-by: Tvrtko Ursulin tvrtko.ursu...@intel.com
---
 tests/.gitignore  |1 +
 tests/Makefile.sources|1 +
 tests/gem_userptr_blits.c | 1185 +
 3 files changed, 1187 insertions(+)
 create mode 100644 tests/gem_userptr_blits.c

diff --git a/tests/.gitignore b/tests/.gitignore
index 7377275..77ab34e 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -92,6 +92,7 @@ gem_tiling_max_stride
 gem_unfence_active_buffers
 gem_unref_active_buffers
 gem_vmap_blits
+gem_userptr_blits
 gem_wait_render_timeout
 gem_write_read_ring_switch
 gen3_mixed_blits
diff --git a/tests/Makefile.sources b/tests/Makefile.sources
index a8c0c96..7699a84 100644
--- a/tests/Makefile.sources
+++ b/tests/Makefile.sources
@@ -116,6 +116,7 @@ TESTS_progs = \
gem_unfence_active_buffers \
gem_unref_active_buffers \
gem_vmap_blits \
+   gem_userptr_blits \
gem_wait_render_timeout \
gen3_mixed_blits \
gen3_render_linear_blits \
diff --git a/tests/gem_userptr_blits.c b/tests/gem_userptr_blits.c
new file mode 100644
index 000..1472b67
--- /dev/null
+++ b/tests/gem_userptr_blits.c
@@ -0,0 +1,1185 @@
+/*
+ * Copyright © 2009-2014 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 e...@anholt.net
+ *Chris Wilson ch...@chris-wilson.co.uk
+ *Tvrtko Ursulin tvrtko.ursu...@intel.com
+ *
+ */
+
+/** @file gem_userptr_blits.c
+ *
+ * This is a test of doing many blits using a mixture of normal system pages
+ * and uncached linear buffers, with a working set larger than the
+ * aperture size.
+ *
+ * The goal is to simply ensure the basics work.
+ */
+
+#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/mman.h
+#include drm.h
+#include i915_drm.h
+#include drmtest.h
+#include intel_bufmgr.h
+#include intel_batchbuffer.h
+#include intel_gpu_tools.h
+
+#include eviction_common.c
+
+#define WIDTH 512
+#define HEIGHT 512
+#define PAGE_SIZE 4096
+
+#define LOCAL_I915_GEM_USERPTR   0x34
+#define LOCAL_IOCTL_I915_GEM_USERPTR DRM_IOWR (DRM_COMMAND_BASE + 
LOCAL_I915_GEM_USERPTR, struct local_i915_gem_userptr)
+struct local_i915_gem_userptr {
+   uint64_t user_ptr;
+   uint64_t user_size;
+   uint32_t flags;
+#define I915_USERPTR_READ_ONLY (10)
+#define I915_USERPTR_UNSYNCHRONIZED (131)
+   uint32_t handle;
+};
+
+static uint32_t userptr_flags;
+
+static uint32_t linear[WIDTH*HEIGHT];
+
+static void gem_userptr_test_unsynchronized(void)
+{
+   userptr_flags = I915_USERPTR_UNSYNCHRONIZED;
+}
+
+static void gem_userptr_test_synchronized(void)
+{
+   userptr_flags = 0;
+}
+
+static int gem_userptr(int fd, void *ptr, int size, int read_only, uint32_t 
*handle)
+{
+   struct local_i915_gem_userptr userptr;
+   int ret;
+
+   userptr.user_ptr = (uintptr_t)ptr;
+   userptr.user_size = size;
+   userptr.flags = userptr_flags;
+   if (read_only)
+   userptr.flags |= I915_USERPTR_READ_ONLY;
+
+   ret = drmIoctl(fd, LOCAL_IOCTL_I915_GEM_USERPTR, userptr);
+   if (ret)
+   ret = errno;
+