diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2017-01-26 08:57:29 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2017-01-26 08:59:19 +0000 |
commit | ce9783325933905a4a2f69047583a3c855e424de (patch) | |
tree | ee55255a28f287a0fb5efd3cf1afa988dc2ade3a /tests | |
parent | 9f3369750ca82e952018276b80e196908795ee74 (diff) |
igt/gem_exec_reloc: Pre-emptive defence against gpu relocations
If we do relocations on the gpu, then we have to wait for the gpu to
finish writing to the buffer before the relocations are complete.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/gem_exec_reloc.c | 46 |
1 files changed, 36 insertions, 10 deletions
diff --git a/tests/gem_exec_reloc.c b/tests/gem_exec_reloc.c index 3c8be618..12b23ba4 100644 --- a/tests/gem_exec_reloc.c +++ b/tests/gem_exec_reloc.c @@ -354,14 +354,16 @@ static void basic_cpu(int fd) execbuf.buffers_ptr = to_user_pointer(&obj); execbuf.buffer_count = 1; - wc = gem_mmap__wc(fd, obj.handle, 0, 4096, PROT_WRITE); + gem_set_domain(fd, obj.handle, + I915_GEM_DOMAIN_CPU, I915_GEM_DOMAIN_CPU); + wc = gem_mmap__cpu(fd, obj.handle, 0, 4096, PROT_WRITE); offset = -1; memcpy(wc + 4000, &offset, sizeof(offset)); - gem_set_domain(fd, obj.handle, - I915_GEM_DOMAIN_CPU, I915_GEM_DOMAIN_CPU); gem_execbuf(fd, &execbuf); + gem_set_domain(fd, obj.handle, + I915_GEM_DOMAIN_CPU, 0); offset = 0; memcpy(&offset, wc + 4000, has_64bit_reloc(fd) ? 8 : 4); munmap(wc, 4096); @@ -378,14 +380,18 @@ static void basic_cpu(int fd) gem_write(fd, obj.handle, 0, &bbe, sizeof(bbe)); reloc.target_handle = obj.handle; - wc = gem_mmap__wc(fd, obj.handle, 0, 4096, PROT_WRITE); + gem_set_domain(fd, obj.handle, + I915_GEM_DOMAIN_CPU, I915_GEM_DOMAIN_CPU); + + wc = gem_mmap__cpu(fd, obj.handle, 0, 4096, PROT_WRITE); offset = -1; memcpy(wc + 4000, &offset, sizeof(offset)); - gem_set_domain(fd, obj.handle, - I915_GEM_DOMAIN_CPU, I915_GEM_DOMAIN_CPU); gem_execbuf(fd, &execbuf); + gem_set_domain(fd, obj.handle, + I915_GEM_DOMAIN_CPU, 0); + offset = 0; memcpy(&offset, wc + 4000, has_64bit_reloc(fd) ? 8 : 4); munmap(wc, 4096); @@ -425,14 +431,18 @@ static void basic_gtt(int fd) execbuf.buffers_ptr = to_user_pointer(&obj); execbuf.buffer_count = 1; + gem_set_domain(fd, obj.handle, + I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT); + wc = gem_mmap__wc(fd, obj.handle, 0, 4096, PROT_WRITE); offset = -1; memcpy(wc + 4000, &offset, sizeof(offset)); - gem_set_domain(fd, obj.handle, - I915_GEM_DOMAIN_CPU, I915_GEM_DOMAIN_CPU); gem_execbuf(fd, &execbuf); + gem_set_domain(fd, obj.handle, + I915_GEM_DOMAIN_GTT, 0); + offset = 0; memcpy(&offset, wc + 4000, has_64bit_reloc(fd) ? 8 : 4); @@ -445,6 +455,9 @@ static void basic_gtt(int fd) offset = -1; memcpy(wc + 4000, &offset, sizeof(offset)); + gem_set_domain(fd, obj.handle, + I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT); + /* Simulate relocation */ obj.offset += 4096; reloc.presumed_offset += 4096; @@ -452,6 +465,9 @@ static void basic_gtt(int fd) gem_execbuf(fd, &execbuf); + gem_set_domain(fd, obj.handle, + I915_GEM_DOMAIN_GTT, 0); + offset = 0; memcpy(&offset, wc + 4000, has_64bit_reloc(fd) ? 8 : 4); munmap(wc, 4096); @@ -491,14 +507,18 @@ static void basic_noreloc(int fd) execbuf.buffer_count = 1; execbuf.flags = LOCAL_I915_EXEC_NO_RELOC; + gem_set_domain(fd, obj.handle, + I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT); + wc = gem_mmap__wc(fd, obj.handle, 0, 4096, PROT_WRITE); offset = -1; memcpy(wc + 4000, &offset, sizeof(offset)); - gem_set_domain(fd, obj.handle, - I915_GEM_DOMAIN_CPU, I915_GEM_DOMAIN_CPU); gem_execbuf(fd, &execbuf); + gem_set_domain(fd, obj.handle, + I915_GEM_DOMAIN_GTT, 0); + offset = 0; memcpy(&offset, wc + 4000, has_64bit_reloc(fd) ? 8 : 4); @@ -508,6 +528,9 @@ static void basic_noreloc(int fd) igt_assert_eq_u64(reloc.presumed_offset, offset); igt_assert_eq_u64(obj.offset, offset); + gem_set_domain(fd, obj.handle, + I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT); + /* Simulate relocation */ obj.offset += 4096; reloc.presumed_offset += 4096; @@ -515,6 +538,9 @@ static void basic_noreloc(int fd) gem_execbuf(fd, &execbuf); + gem_set_domain(fd, obj.handle, + I915_GEM_DOMAIN_GTT, 0); + offset = 0; memcpy(&offset, wc + 4000, has_64bit_reloc(fd) ? 8 : 4); munmap(wc, 4096); |