summaryrefslogtreecommitdiff
path: root/tests/gem_fenced_exec_thrash.c
diff options
context:
space:
mode:
authorVille Syrjälä <ville.syrjala@linux.intel.com>2013-04-11 20:43:40 +0300
committerDaniel Vetter <daniel.vetter@ffwll.ch>2013-04-11 20:01:54 +0200
commit2fe3f76c255b08f4b462fc64be12d5e4ac7b37cd (patch)
treef65dfc097af40d586cd3995c5988295fcbcf1e3e /tests/gem_fenced_exec_thrash.c
parenta7ca33b673ee90b0a93ffdb18449256798f67786 (diff)
tests/gem_fenced_exec_thrash: Test with > max fences
Make sure the kernel returns EDEADLK when the number of fences is exceeded for gen2-3. For gen4+ the test makes sure the kernel ignores the EXEC_OBJECT_NEEDS_FENCE flag. Note that I changed the code not to round the num_fences to an even number. Not sure why that was there, and if there's a reason for it, we need to add it back. Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'tests/gem_fenced_exec_thrash.c')
-rw-r--r--tests/gem_fenced_exec_thrash.c38
1 files changed, 25 insertions, 13 deletions
diff --git a/tests/gem_fenced_exec_thrash.c b/tests/gem_fenced_exec_thrash.c
index ca88c532..c8a2c58a 100644
--- a/tests/gem_fenced_exec_thrash.c
+++ b/tests/gem_fenced_exec_thrash.c
@@ -38,6 +38,7 @@
#include <i915_drm.h>
#include "drmtest.h"
+#include "intel_gpu_tools.h"
#define WIDTH 1024
#define HEIGHT 1024
@@ -47,8 +48,6 @@
#define MAX_FENCES 32
-#define MI_BATCH_BUFFER_END (0xA<<23)
-
/*
* Testcase: execbuf fence accounting
*
@@ -95,7 +94,7 @@ static int get_num_fences(int fd)
printf ("total %d fences\n", val);
assert(val > 4);
- return val - 2;
+ return val;
}
static void fill_reloc(struct drm_i915_gem_relocation_entry *reloc, uint32_t handle)
@@ -106,23 +105,19 @@ static void fill_reloc(struct drm_i915_gem_relocation_entry *reloc, uint32_t han
reloc->write_domain = 0;
}
-int
-main(int argc, char **argv)
+static void run_test(int fd, int num_fences, int expected_errno)
{
struct drm_i915_gem_execbuffer2 execbuf[2];
- struct drm_i915_gem_exec_object2 exec[2][2*MAX_FENCES+1];
- struct drm_i915_gem_relocation_entry reloc[2*MAX_FENCES];
+ struct drm_i915_gem_exec_object2 exec[2][2*MAX_FENCES+3];
+ struct drm_i915_gem_relocation_entry reloc[2*MAX_FENCES+2];
- int fd = drm_open_any();
- int i, n, num_fences;
+ int i, n;
int loop = 1000;
memset(execbuf, 0, sizeof(execbuf));
memset(exec, 0, sizeof(exec));
memset(reloc, 0, sizeof(reloc));
- num_fences = get_num_fences(fd) & ~1;
- assert(num_fences <= MAX_FENCES);
for (n = 0; n < 2*num_fences; n++) {
uint32_t handle = tiled_bo_create(fd);
exec[1][2*num_fences - n-1].handle = exec[0][n].handle = handle;
@@ -148,13 +143,30 @@ main(int argc, char **argv)
ret = drmIoctl(fd,
DRM_IOCTL_I915_GEM_EXECBUFFER2,
&execbuf[0]);
- assert(ret == 0);
+ assert(expected_errno ?
+ ret < 0 && errno == expected_errno :
+ ret == 0);
ret = drmIoctl(fd,
DRM_IOCTL_I915_GEM_EXECBUFFER2,
&execbuf[1]);
- assert(ret == 0);
+ assert(expected_errno ?
+ ret < 0 && errno == expected_errno :
+ ret == 0);
} while (--loop);
+}
+
+int
+main(int argc, char **argv)
+{
+ int fd = drm_open_any();
+ int num_fences = get_num_fences(fd);
+ uint32_t devid = intel_get_drm_devid(fd);
+
+ assert(num_fences <= MAX_FENCES);
+
+ run_test(fd, num_fences - 2, 0);
+ run_test(fd, num_fences + 1, intel_gen(devid) >= 4 ? 0 : EDEADLK);
close(fd);