summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2016-01-22 18:02:50 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2016-01-22 18:28:01 +0000
commit0091e6787cf4da668068f82d58f7169516acbc1f (patch)
tree974eaaa229bc940506ddf0a3b1727c88bfc07427 /tests
parent5b675f7b2f6487548a91c01eb9a7e36e808617b4 (diff)
igt/gem_userptr_blits: Exercise applying relocations to a userptr bo
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'tests')
-rw-r--r--tests/gem_userptr_blits.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/gem_userptr_blits.c b/tests/gem_userptr_blits.c
index 6d38260f..0e3a0ba4 100644
--- a/tests/gem_userptr_blits.c
+++ b/tests/gem_userptr_blits.c
@@ -677,6 +677,45 @@ static int test_forbidden_ops(int fd)
return 0;
}
+static void test_relocations(int fd)
+{
+ struct drm_i915_gem_relocation_entry *reloc;
+ struct drm_i915_gem_exec_object2 obj;
+ struct drm_i915_gem_execbuffer2 exec;
+ unsigned size;
+ void *ptr;
+ int i;
+
+ size = PAGE_SIZE + ALIGN(sizeof(*reloc)*256, PAGE_SIZE);
+
+ memset(&obj, 0, sizeof(obj));
+ igt_assert(posix_memalign(&ptr, PAGE_SIZE, size) == 0);
+ igt_assert_eq(gem_userptr(fd, ptr, size, 0, &obj.handle), 0);
+ if (!gem_has_llc(fd))
+ gem_set_caching(fd, obj.handle, 0);
+ *(uint32_t *)ptr = MI_BATCH_BUFFER_END;
+
+ reloc = (typeof(reloc))((char *)ptr + PAGE_SIZE);
+ obj.relocs_ptr = (uintptr_t)reloc;
+ obj.relocation_count = 256;
+
+ memset(reloc, 0, 256*sizeof(*reloc));
+ for (i = 0; i < 256; i++) {
+ reloc[i].offset = 2048 - 4*i;
+ reloc[i].target_handle = obj.handle;
+ reloc[i].read_domains = I915_GEM_DOMAIN_INSTRUCTION;
+ }
+
+ memset(&exec, 0, sizeof(exec));
+ exec.buffers_ptr = (uintptr_t)&obj;
+ exec.buffer_count = 1;
+ gem_execbuf(fd, &exec);
+
+ gem_sync(fd, obj.handle);
+ gem_close(fd, obj.handle);
+ free(ptr);
+}
+
static unsigned char counter;
static void (* volatile orig_sigbus)(int sig, siginfo_t *info, void *param);
@@ -1363,6 +1402,9 @@ int main(int argc, char **argv)
igt_subtest("forbidden-operations")
test_forbidden_ops(fd);
+ igt_subtest("relocations")
+ test_relocations(fd);
+
igt_info("Testing unsynchronized mappings...\n");
gem_userptr_test_unsynchronized();