diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2015-01-15 09:36:05 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2015-01-15 09:41:03 +0000 |
commit | a263cc87958de96acd77fdae6bf8a09bdf46204e (patch) | |
tree | 27d30c52145b3b98837139128593591ce3c23e4d | |
parent | d3bf83af031a2e1c937b3f66fd3fbaec72864525 (diff) |
igt/gem_tiled_swapping: Cycle through the bo a couple of times
In order to exercise coherency across swapin/swapout of the same bo,
explicitly loop over all bo a couple of times.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r-- | tests/gem_tiled_swapping.c | 64 |
1 files changed, 44 insertions, 20 deletions
diff --git a/tests/gem_tiled_swapping.c b/tests/gem_tiled_swapping.c index d4ffd65e..16566be0 100644 --- a/tests/gem_tiled_swapping.c +++ b/tests/gem_tiled_swapping.c @@ -73,34 +73,38 @@ static uint32_t current_tiling_mode; #define AVAIL_RAM 512 static uint32_t -create_bo_and_fill(int fd) +create_bo(int fd) { uint32_t handle; uint32_t *data; - int i; handle = gem_create(fd, LINEAR_DWORDS); gem_set_tiling(fd, handle, current_tiling_mode, WIDTH * sizeof(uint32_t)); - /* Fill the BO with dwords starting at start_val */ data = gem_mmap(fd, handle, LINEAR_DWORDS, PROT_READ | PROT_WRITE); - if (data == NULL && errno == ENOSPC) + if (data == NULL) { + gem_close(fd, handle); return 0; - - for (i = 0; i < WIDTH*HEIGHT; i++) - data[i] = i; + } munmap(data, LINEAR_DWORDS); return handle; } -uint32_t *bo_handles; +static void +fill_bo(int fd, uint32_t handle) +{ + uint32_t *data; + int i; -struct thread { - pthread_t thread; - int *idx_arr; - int fd, count; -}; + data = gem_mmap(fd, handle, LINEAR_DWORDS, PROT_READ | PROT_WRITE); + igt_assert(data); + + gem_set_domain(fd, handle, I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT); + for (i = 0; i < WIDTH*HEIGHT; i++) + data[i] = i; + munmap(data, LINEAR_DWORDS); +} static void check_bo(int fd, uint32_t handle) @@ -108,13 +112,21 @@ check_bo(int fd, uint32_t handle) uint32_t *data; int j; - /* Check the target bo's contents. */ - data = gem_mmap(fd, handle, LINEAR_DWORDS, PROT_READ | PROT_WRITE); + data = gem_mmap(fd, handle, LINEAR_DWORDS, PROT_READ); + gem_set_domain(fd, handle, I915_GEM_DOMAIN_GTT, 0); j = rand() % (WIDTH * HEIGHT); igt_assert_f(data[j] == j, "mismatch at %i: %i\n", j, data[j]); munmap(data, LINEAR_DWORDS); } +uint32_t *bo_handles; + +struct thread { + pthread_t thread; + int *idx_arr; + int fd, count; +}; + static void *thread_run(void *data) { struct thread *t = data; @@ -181,28 +193,40 @@ igt_main intel_require_memory(count, 1024*1024, CHECK_RAM | CHECK_SWAP); for (n = 0; n < count; n++) { - bo_handles[n] = create_bo_and_fill(fd); + bo_handles[n] = create_bo(fd); /* Not enough mmap address space possible. */ igt_require(bo_handles[n]); } } igt_subtest("non-threaded") { + for (n = 0; n < count; n++) + fill_bo(fd, bo_handles[n]); + thread_init(&threads[0], fd, count); thread_run(&threads[0]); + thread_run(&threads[0]); + thread_run(&threads[0]); thread_fini(&threads[0]); } /* Once more with threads */ igt_subtest("threaded") { - for (n = 0; n < num_threads; n++) { + for (n = 0; n < count; n++) + fill_bo(fd, bo_handles[n]); + + for (n = 0; n < num_threads; n++) thread_init(&threads[n], fd, count); + + thread_run(&threads[0]); + for (n = 0; n < num_threads; n++) pthread_create(&threads[n].thread, NULL, thread_run, &threads[n]); - } - for (n = 0; n < num_threads; n++) { + for (n = 0; n < num_threads; n++) pthread_join(threads[n].thread, NULL); + thread_run(&threads[0]); + + for (n = 0; n < num_threads; n++) thread_fini(&threads[n]); - } } close(fd); |