diff options
-rw-r--r-- | lib/drmtest.c | 17 | ||||
-rw-r--r-- | lib/drmtest.h | 1 | ||||
-rw-r--r-- | tests/gem_exec_faulting_reloc.c | 11 | ||||
-rw-r--r-- | tests/gem_gtt_speed.c | 16 | ||||
-rw-r--r-- | tests/gem_mmap_gtt.c | 11 | ||||
-rw-r--r-- | tests/gem_tiled_pread.c | 16 | ||||
-rw-r--r-- | tests/gem_tiled_pread_pwrite.c | 16 | ||||
-rw-r--r-- | tests/gen3_mixed_blits.c | 22 | ||||
-rw-r--r-- | tests/gen3_render_mixed_blits.c | 22 | ||||
-rw-r--r-- | tests/gen3_render_tiledx_blits.c | 22 | ||||
-rw-r--r-- | tests/gen3_render_tiledy_blits.c | 22 | ||||
-rw-r--r-- | tests/testdisplay.c | 16 |
12 files changed, 28 insertions, 164 deletions
diff --git a/lib/drmtest.c b/lib/drmtest.c index ae7e6dd7..f3f05347 100644 --- a/lib/drmtest.c +++ b/lib/drmtest.c @@ -30,6 +30,7 @@ #include <sys/stat.h> #include <sys/ioctl.h> #include <string.h> +#include <sys/mman.h> #include "drmtest.h" #include "i915_drm.h" #include "intel_chipset.h" @@ -202,3 +203,19 @@ uint32_t gem_create(int fd, int size) return create.handle; } +void *gem_mmap(int fd, uint32_t handle, int size, int prot) +{ + struct drm_i915_gem_mmap_gtt mmap_arg; + void *ptr; + + mmap_arg.handle = handle; + if (drmIoctl(fd, DRM_IOCTL_I915_GEM_MMAP_GTT, &mmap_arg)) + return NULL; + + ptr = mmap(0, size, prot, MAP_SHARED, fd, mmap_arg.offset); + if (ptr == MAP_FAILED) + ptr = NULL; + + return ptr; +} + diff --git a/lib/drmtest.h b/lib/drmtest.h index a3066c27..38118f17 100644 --- a/lib/drmtest.h +++ b/lib/drmtest.h @@ -45,3 +45,4 @@ void gem_set_domain(int fd, uint32_t handle, uint32_t read_domains, uint32_t write_domain); void gem_sync(int fd, uint32_t handle); uint32_t gem_create(int fd, int size); +void *gem_mmap(int fd, uint32_t handle, int size, int prot); diff --git a/tests/gem_exec_faulting_reloc.c b/tests/gem_exec_faulting_reloc.c index 40438f06..303f2d80 100644 --- a/tests/gem_exec_faulting_reloc.c +++ b/tests/gem_exec_faulting_reloc.c @@ -60,18 +60,9 @@ static void * mmap_bo(int fd, uint32_t handle) { - struct drm_i915_gem_mmap_gtt arg; void *ptr; - int ret; - - memset(&arg, 0, sizeof(arg)); - - arg.handle = handle; - ret = ioctl(fd, DRM_IOCTL_I915_GEM_MMAP_GTT, &arg); - assert(ret == 0); - ptr = mmap(0, 4096, PROT_READ | PROT_WRITE, - MAP_SHARED, fd, arg.offset); + ptr = gem_mmap(fd, handle, 4096, PROT_READ | PROT_WRITE); assert(ptr != MAP_FAILED); return ptr; diff --git a/tests/gem_gtt_speed.c b/tests/gem_gtt_speed.c index 54ed64d1..8c66aee9 100644 --- a/tests/gem_gtt_speed.c +++ b/tests/gem_gtt_speed.c @@ -45,22 +45,6 @@ #define OBJECT_SIZE 16384 -static void *gem_mmap(int fd, uint32_t handle, int size, int prot) -{ - struct drm_i915_gem_mmap_gtt mmap_arg; - void *ptr; - - mmap_arg.handle = handle; - if (drmIoctl(fd, DRM_IOCTL_I915_GEM_MMAP_GTT, &mmap_arg)) - return NULL; - - ptr = mmap(0, size, prot, MAP_SHARED, fd, mmap_arg.offset); - if (ptr == MAP_FAILED) - ptr = NULL; - - return ptr; -} - static double elapsed(const struct timeval *start, const struct timeval *end, int loop) diff --git a/tests/gem_mmap_gtt.c b/tests/gem_mmap_gtt.c index 529e2c97..e7a48679 100644 --- a/tests/gem_mmap_gtt.c +++ b/tests/gem_mmap_gtt.c @@ -50,18 +50,9 @@ static void set_domain(int fd, uint32_t handle) static void * mmap_bo(int fd, uint32_t handle) { - struct drm_i915_gem_mmap_gtt arg; void *ptr; - int ret; - memset(&arg, 0, sizeof(arg)); - - arg.handle = handle; - ret = ioctl(fd, DRM_IOCTL_I915_GEM_MMAP_GTT, &arg); - assert(ret == 0); - - ptr = mmap(0, OBJECT_SIZE, PROT_READ | PROT_WRITE, - MAP_SHARED, fd, arg.offset); + ptr = gem_mmap(fd, handle, OBJECT_SIZE, PROT_READ | PROT_WRITE); assert(ptr != MAP_FAILED); return ptr; diff --git a/tests/gem_tiled_pread.c b/tests/gem_tiled_pread.c index 872f9eb0..189affce 100644 --- a/tests/gem_tiled_pread.c +++ b/tests/gem_tiled_pread.c @@ -61,22 +61,6 @@ static int tile_width; static int tile_height; static int tile_size; -static void *gem_mmap(int fd, uint32_t handle, int size, int prot) -{ - struct drm_i915_gem_mmap_gtt mmap_arg; - void *ptr; - - mmap_arg.handle = handle; - if (drmIoctl(fd, DRM_IOCTL_I915_GEM_MMAP_GTT, &mmap_arg)) - return NULL; - - ptr = mmap(0, size, prot, MAP_SHARED, fd, mmap_arg.offset); - if (ptr == MAP_FAILED) - ptr = NULL; - - return ptr; -} - static void gem_get_tiling(int fd, uint32_t handle, uint32_t *tiling, uint32_t *swizzle) { diff --git a/tests/gem_tiled_pread_pwrite.c b/tests/gem_tiled_pread_pwrite.c index e2ff8865..17de6588 100644 --- a/tests/gem_tiled_pread_pwrite.c +++ b/tests/gem_tiled_pread_pwrite.c @@ -67,22 +67,6 @@ static uint32_t current_tiling_mode; #define PAGE_SIZE 4096 -static void *gem_mmap(int fd, uint32_t handle, int size, int prot) -{ - struct drm_i915_gem_mmap_gtt mmap_arg; - void *ptr; - - mmap_arg.handle = handle; - if (drmIoctl(fd, DRM_IOCTL_I915_GEM_MMAP_GTT, &mmap_arg)) - return NULL; - - ptr = mmap(0, size, prot, MAP_SHARED, fd, mmap_arg.offset); - if (ptr == MAP_FAILED) - ptr = NULL; - - return ptr; -} - static void gem_get_tiling(int fd, uint32_t handle, uint32_t *tiling, uint32_t *swizzle) { diff --git a/tests/gen3_mixed_blits.c b/tests/gen3_mixed_blits.c index 367ebd63..c60dbd1e 100644 --- a/tests/gen3_mixed_blits.c +++ b/tests/gen3_mixed_blits.c @@ -428,26 +428,6 @@ retry: } } -static void *gem_mmap(int fd, uint32_t handle, int size, int prot) -{ - struct drm_i915_gem_mmap_gtt mmap_arg; - void *ptr; - - mmap_arg.handle = handle; - if (drmIoctl(fd, DRM_IOCTL_I915_GEM_MMAP_GTT, &mmap_arg)) { - assert(0); - return NULL; - } - - ptr = mmap(0, size, prot, MAP_SHARED, fd, mmap_arg.offset); - if (ptr == MAP_FAILED) { - assert(0); - ptr = NULL; - } - - return ptr; -} - static uint32_t create_bo(int fd, uint32_t val, int tiling) { @@ -460,6 +440,7 @@ create_bo(int fd, uint32_t val, int tiling) /* Fill the BO with dwords starting at val */ v = gem_mmap(fd, handle, WIDTH*HEIGHT*4, PROT_READ | PROT_WRITE); + assert(v); for (i = 0; i < WIDTH*HEIGHT; i++) v[i] = val++; munmap(v, WIDTH*HEIGHT*4); @@ -474,6 +455,7 @@ check_bo(int fd, uint32_t handle, uint32_t val) int i; v = gem_mmap(fd, handle, WIDTH*HEIGHT*4, PROT_READ); + assert(v); for (i = 0; i < WIDTH*HEIGHT; i++) { if (v[i] != val) { fprintf(stderr, "Expected 0x%08x, found 0x%08x " diff --git a/tests/gen3_render_mixed_blits.c b/tests/gen3_render_mixed_blits.c index 1244b2a3..b03cc65f 100644 --- a/tests/gen3_render_mixed_blits.c +++ b/tests/gen3_render_mixed_blits.c @@ -317,26 +317,6 @@ copy(int fd, gem_close(fd, handle); } -static void *gem_mmap(int fd, uint32_t handle, int size, int prot) -{ - struct drm_i915_gem_mmap_gtt mmap_arg; - void *ptr; - - mmap_arg.handle = handle; - if (drmIoctl(fd, DRM_IOCTL_I915_GEM_MMAP_GTT, &mmap_arg)) { - assert(0); - return NULL; - } - - ptr = mmap(0, size, prot, MAP_SHARED, fd, mmap_arg.offset); - if (ptr == MAP_FAILED) { - assert(0); - ptr = NULL; - } - - return ptr; -} - static uint32_t create_bo(int fd, uint32_t val, int tiling) { @@ -349,6 +329,7 @@ create_bo(int fd, uint32_t val, int tiling) /* Fill the BO with dwords starting at val */ v = gem_mmap(fd, handle, WIDTH*HEIGHT*4, PROT_READ | PROT_WRITE); + assert(v); for (i = 0; i < WIDTH*HEIGHT; i++) v[i] = val++; munmap(v, WIDTH*HEIGHT*4); @@ -363,6 +344,7 @@ check_bo(int fd, uint32_t handle, uint32_t val) int i; v = gem_mmap(fd, handle, WIDTH*HEIGHT*4, PROT_READ); + assert(v); for (i = 0; i < WIDTH*HEIGHT; i++) { if (v[i] != val) { fprintf(stderr, "Expected 0x%08x, found 0x%08x " diff --git a/tests/gen3_render_tiledx_blits.c b/tests/gen3_render_tiledx_blits.c index e34d2f77..ce1ed3e0 100644 --- a/tests/gen3_render_tiledx_blits.c +++ b/tests/gen3_render_tiledx_blits.c @@ -304,26 +304,6 @@ copy(int fd, uint32_t dst, uint32_t src) gem_close(fd, handle); } -static void *gem_mmap(int fd, uint32_t handle, int size, int prot) -{ - struct drm_i915_gem_mmap_gtt mmap_arg; - void *ptr; - - mmap_arg.handle = handle; - if (drmIoctl(fd, DRM_IOCTL_I915_GEM_MMAP_GTT, &mmap_arg)) { - assert(0); - return NULL; - } - - ptr = mmap(0, size, prot, MAP_SHARED, fd, mmap_arg.offset); - if (ptr == MAP_FAILED) { - assert(0); - ptr = NULL; - } - - return ptr; -} - static uint32_t create_bo(int fd, uint32_t val) { @@ -336,6 +316,7 @@ create_bo(int fd, uint32_t val) /* Fill the BO with dwords starting at val */ v = gem_mmap(fd, handle, WIDTH*HEIGHT*4, PROT_READ | PROT_WRITE); + assert(v); for (i = 0; i < WIDTH*HEIGHT; i++) v[i] = val++; munmap(v, WIDTH*HEIGHT*4); @@ -350,6 +331,7 @@ check_bo(int fd, uint32_t handle, uint32_t val) int i; v = gem_mmap(fd, handle, WIDTH*HEIGHT*4, PROT_READ); + assert(v); for (i = 0; i < WIDTH*HEIGHT; i++) { if (v[i] != val) { fprintf(stderr, "Expected 0x%08x, found 0x%08x " diff --git a/tests/gen3_render_tiledy_blits.c b/tests/gen3_render_tiledy_blits.c index cc9131b7..dfc9c25b 100644 --- a/tests/gen3_render_tiledy_blits.c +++ b/tests/gen3_render_tiledy_blits.c @@ -304,26 +304,6 @@ copy(int fd, uint32_t dst, uint32_t src) gem_close(fd, handle); } -static void *gem_mmap(int fd, uint32_t handle, int size, int prot) -{ - struct drm_i915_gem_mmap_gtt mmap_arg; - void *ptr; - - mmap_arg.handle = handle; - if (drmIoctl(fd, DRM_IOCTL_I915_GEM_MMAP_GTT, &mmap_arg)) { - assert(0); - return NULL; - } - - ptr = mmap(0, size, prot, MAP_SHARED, fd, mmap_arg.offset); - if (ptr == MAP_FAILED) { - assert(0); - ptr = NULL; - } - - return ptr; -} - static uint32_t create_bo(int fd, uint32_t val) { @@ -336,6 +316,7 @@ create_bo(int fd, uint32_t val) /* Fill the BO with dwords starting at val */ v = gem_mmap(fd, handle, WIDTH*HEIGHT*4, PROT_READ | PROT_WRITE); + assert(v); for (i = 0; i < WIDTH*HEIGHT; i++) v[i] = val++; munmap(v, WIDTH*HEIGHT*4); @@ -350,6 +331,7 @@ check_bo(int fd, uint32_t handle, uint32_t val) int i; v = gem_mmap(fd, handle, WIDTH*HEIGHT*4, PROT_READ); + assert(v); for (i = 0; i < WIDTH*HEIGHT; i++) { if (v[i] != val) { fprintf(stderr, "Expected 0x%08x, found 0x%08x " diff --git a/tests/testdisplay.c b/tests/testdisplay.c index bde62104..6a35307d 100644 --- a/tests/testdisplay.c +++ b/tests/testdisplay.c @@ -384,22 +384,6 @@ static void connector_find_preferred_mode(struct connector *c) c->connector = connector; } -static void *gem_mmap(int fd, uint32_t handle, int size, int prot) -{ - struct drm_i915_gem_mmap_gtt mmap_arg; - void *ptr; - - mmap_arg.handle = handle; - if (drmIoctl(fd, DRM_IOCTL_I915_GEM_MMAP_GTT, &mmap_arg)) - return NULL; - - ptr = mmap(0, size, prot, MAP_SHARED, fd, mmap_arg.offset); - if (ptr == MAP_FAILED) - ptr = NULL; - - return ptr; -} - static cairo_surface_t * allocate_surface(int fd, int width, int height, uint32_t depth, uint32_t *handle, int tiled) |