summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/ioctl_wrappers.c15
-rw-r--r--tests/eviction_common.c2
-rw-r--r--tests/gem_evict_everything.c16
-rw-r--r--tests/gem_userptr_blits.c343
4 files changed, 183 insertions, 193 deletions
diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
index ddd71af9..110465e0 100644
--- a/lib/ioctl_wrappers.c
+++ b/lib/ioctl_wrappers.c
@@ -954,7 +954,6 @@ void gem_context_require_ban_period(int fd)
int __gem_userptr(int fd, void *ptr, int size, int read_only, uint32_t flags, uint32_t *handle)
{
struct local_i915_gem_userptr userptr;
- int ret;
memset(&userptr, 0, sizeof(userptr));
userptr.user_ptr = (uintptr_t)ptr;
@@ -963,17 +962,11 @@ int __gem_userptr(int fd, void *ptr, int size, int read_only, uint32_t flags, ui
if (read_only)
userptr.flags |= LOCAL_I915_USERPTR_READ_ONLY;
- ret = igt_ioctl(fd, LOCAL_IOCTL_I915_GEM_USERPTR, &userptr);
- if (ret)
- ret = errno;
- igt_skip_on_f(ret == ENODEV &&
- (flags & LOCAL_I915_USERPTR_UNSYNCHRONIZED) == 0 &&
- !read_only,
- "Skipping, synchronized mappings with no kernel CONFIG_MMU_NOTIFIER?");
- if (ret == 0)
- *handle = userptr.handle;
+ if (igt_ioctl(fd, LOCAL_IOCTL_I915_GEM_USERPTR, &userptr))
+ return -errno;
- return ret;
+ *handle = userptr.handle;
+ return 0;
}
/**
diff --git a/tests/eviction_common.c b/tests/eviction_common.c
index c8bfe8eb..e39555de 100644
--- a/tests/eviction_common.c
+++ b/tests/eviction_common.c
@@ -91,7 +91,7 @@ static int minor_evictions(int fd, struct igt_eviction_test_ops *ops,
igt_assert_eq(ret, 0);
}
ret = ops->copy(fd, bo[0], bo[0], bo, total_surfaces);
- igt_assert(ret == ENOSPC);
+ igt_assert_eq(ret, -ENOSPC);
}
for (n = 0; n < total_surfaces; n++)
diff --git a/tests/gem_evict_everything.c b/tests/gem_evict_everything.c
index 51ed2931..14668915 100644
--- a/tests/gem_evict_everything.c
+++ b/tests/gem_evict_everything.c
@@ -109,20 +109,12 @@ copy(int fd, uint32_t dst, uint32_t src, uint32_t *all_bo, int n_bo)
obj[n].relocation_count = 2;
obj[n].relocs_ptr = (uintptr_t)reloc;
+ memset(&exec, 0, sizeof(exec));
exec.buffers_ptr = (uintptr_t)obj;
exec.buffer_count = n_bo + 1;
- exec.batch_start_offset = 0;
- exec.batch_len = i * 4;
- exec.DR1 = exec.DR4 = 0;
- exec.num_cliprects = 0;
- exec.cliprects_ptr = 0;
- exec.flags = HAS_BLT_RING(intel_get_drm_devid(fd)) ? I915_EXEC_BLT : 0;
- i915_execbuffer2_set_context_id(exec, 0);
- exec.rsvd2 = 0;
-
- ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &exec);
- if (ret)
- ret = errno;
+ if (HAS_BLT_RING(intel_get_drm_devid(fd)))
+ exec.flags |= I915_EXEC_BLT;
+ ret = __gem_execbuf(fd, &exec);
gem_close(fd, handle);
free(obj);
diff --git a/tests/gem_userptr_blits.c b/tests/gem_userptr_blits.c
index d1546571..f30e1436 100644
--- a/tests/gem_userptr_blits.c
+++ b/tests/gem_userptr_blits.c
@@ -437,6 +437,10 @@ static int test_input_checking(int fd)
static int test_access_control(int fd)
{
+ /* CAP_SYS_ADMIN is needed for UNSYNCHRONIZED mappings. */
+ gem_userptr_test_unsynchronized();
+ igt_require(has_userptr(fd));
+
igt_fork(child, 1) {
void *ptr;
int ret;
@@ -444,16 +448,13 @@ static int test_access_control(int fd)
igt_drop_root();
- /* CAP_SYS_ADMIN is needed for UNSYNCHRONIZED mappings. */
- gem_userptr_test_unsynchronized();
-
igt_assert(posix_memalign(&ptr, PAGE_SIZE, PAGE_SIZE) == 0);
ret = __gem_userptr(fd, ptr, PAGE_SIZE, 0, userptr_flags, &handle);
if (ret == 0)
gem_close(fd, handle);
free(ptr);
- igt_assert(ret == EPERM);
+ igt_assert_eq(ret, -EPERM);
}
igt_waitchildren();
@@ -575,35 +576,32 @@ static int test_forbidden_ops(int fd)
{
struct drm_i915_gem_pread gem_pread;
struct drm_i915_gem_pwrite gem_pwrite;
- void *ptr;
- int ret;
uint32_t handle;
- char buf[PAGE_SIZE];
-
- memset(&gem_pread, 0, sizeof(gem_pread));
- memset(&gem_pwrite, 0, sizeof(gem_pwrite));
+ void *ptr;
igt_assert(posix_memalign(&ptr, PAGE_SIZE, PAGE_SIZE) == 0);
-
gem_userptr(fd, ptr, PAGE_SIZE, 0, userptr_flags, &handle);
/* pread/pwrite are not always forbidden, but when they
* are they should fail with EINVAL.
*/
+ memset(&gem_pread, 0, sizeof(gem_pread));
gem_pread.handle = handle;
gem_pread.offset = 0;
gem_pread.size = PAGE_SIZE;
- gem_pread.data_ptr = (uintptr_t)buf;
- ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_PREAD, &gem_pread);
- igt_assert(ret == 0 || errno == EINVAL);
+ gem_pread.data_ptr = (uintptr_t)ptr;
+ if (drmIoctl(fd, DRM_IOCTL_I915_GEM_PREAD, &gem_pread))
+ igt_assert_eq(errno, EINVAL);
+ memset(&gem_pwrite, 0, sizeof(gem_pwrite));
gem_pwrite.handle = handle;
gem_pwrite.offset = 0;
gem_pwrite.size = PAGE_SIZE;
- gem_pwrite.data_ptr = (uintptr_t)buf;
- ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_PWRITE, &gem_pwrite);
- igt_assert(ret == 0 || errno == EINVAL);
+ gem_pwrite.data_ptr = (uintptr_t)ptr;
+ if (drmIoctl(fd, DRM_IOCTL_I915_GEM_PWRITE, &gem_pwrite))
+ igt_assert_eq(errno, EINVAL);
+
gem_close(fd, handle);
free(ptr);
@@ -845,7 +843,7 @@ static int test_create_destroy(int fd, int time)
for (n = 0; n < 1000; n++) {
igt_assert(posix_memalign(&ptr, PAGE_SIZE, PAGE_SIZE) == 0);
- do_or_die(__gem_userptr(fd, ptr, PAGE_SIZE, 0, userptr_flags, &handle));
+ gem_userptr(fd, ptr, PAGE_SIZE, 0, userptr_flags, &handle);
gem_close(fd, handle);
free(ptr);
@@ -1285,15 +1283,9 @@ int main(int argc, char **argv)
igt_subtest_init(argc, argv);
igt_fixture {
- int ret;
-
fd = drm_open_driver(DRIVER_INTEL);
igt_assert(fd >= 0);
- ret = has_userptr(fd);
- igt_skip_on_f(ret == 0, "No userptr support - %s (%d)\n",
- strerror(errno), ret);
-
size = sizeof(linear);
aperture_size = gem_aperture_size(fd);
@@ -1313,209 +1305,222 @@ int main(int argc, char **argv)
}
}
- igt_subtest("input-checking")
- test_input_checking(fd);
+ igt_subtest_group {
+ igt_fixture {
+ igt_require(has_userptr(fd));
+ }
- igt_subtest("usage-restrictions")
- test_usage_restrictions(fd);
+ igt_subtest("input-checking")
+ test_input_checking(fd);
- igt_subtest("invalid-null-pointer")
- test_invalid_null_pointer(fd);
+ igt_subtest("usage-restrictions")
+ test_usage_restrictions(fd);
- igt_subtest("invalid-gtt-mapping")
- test_invalid_gtt_mapping(fd);
+ igt_subtest("invalid-null-pointer")
+ test_invalid_null_pointer(fd);
- igt_subtest("forked-access")
- test_forked_access(fd);
+ igt_subtest("invalid-gtt-mapping")
+ test_invalid_gtt_mapping(fd);
- igt_subtest("forbidden-operations")
- test_forbidden_ops(fd);
+ igt_subtest("forked-access")
+ test_forked_access(fd);
- igt_subtest("relocations")
- test_relocations(fd);
+ igt_subtest("forbidden-operations")
+ test_forbidden_ops(fd);
- igt_info("Testing unsynchronized mappings...\n");
- gem_userptr_test_unsynchronized();
+ igt_subtest("relocations")
+ test_relocations(fd);
+ }
- igt_subtest("create-destroy-unsync")
- test_create_destroy(fd, 5);
+ igt_subtest_group {
+ gem_userptr_test_unsynchronized();
- igt_subtest("unsync-overlap")
- test_overlap(fd, 0);
+ igt_fixture {
+ igt_require(has_userptr(fd));
+ }
- igt_subtest("unsync-unmap")
- test_unmap(fd, 0);
+ igt_subtest("create-destroy-unsync")
+ test_create_destroy(fd, 5);
- igt_subtest("unsync-unmap-cycles")
- test_unmap_cycles(fd, 0);
+ igt_subtest("unsync-overlap")
+ test_overlap(fd, 0);
- igt_subtest("unsync-unmap-after-close")
- test_unmap_after_close(fd);
+ igt_subtest("unsync-unmap")
+ test_unmap(fd, 0);
- igt_subtest("coherency-unsync")
- test_coherency(fd, count);
+ igt_subtest("unsync-unmap-cycles")
+ test_unmap_cycles(fd, 0);
- igt_subtest("dmabuf-unsync")
- test_dmabuf();
+ igt_subtest("unsync-unmap-after-close")
+ test_unmap_after_close(fd);
- for (unsigned flags = 0; flags < ALL_FORKING_EVICTIONS + 1; flags++) {
- igt_subtest_f("forked-unsync%s%s%s-%s",
- flags & FORKING_EVICTIONS_SWAPPING ? "-swapping" : "",
- flags & FORKING_EVICTIONS_DUP_DRMFD ? "-multifd" : "",
- flags & FORKING_EVICTIONS_MEMORY_PRESSURE ?
- "-mempressure" : "",
- flags & FORKING_EVICTIONS_INTERRUPTIBLE ?
- "interruptible" : "normal") {
- test_forking_evictions(fd, size, count, flags);
- }
- }
+ igt_subtest("coherency-unsync")
+ test_coherency(fd, count);
- igt_subtest("mlocked-unsync-normal")
- test_mlocked_evictions(fd, size, count);
+ igt_subtest("dmabuf-unsync")
+ test_dmabuf();
- igt_subtest("swapping-unsync-normal")
- test_swapping_evictions(fd, size, count);
+ for (unsigned flags = 0; flags < ALL_FORKING_EVICTIONS + 1; flags++) {
+ igt_subtest_f("forked-unsync%s%s%s-%s",
+ flags & FORKING_EVICTIONS_SWAPPING ? "-swapping" : "",
+ flags & FORKING_EVICTIONS_DUP_DRMFD ? "-multifd" : "",
+ flags & FORKING_EVICTIONS_MEMORY_PRESSURE ?
+ "-mempressure" : "",
+ flags & FORKING_EVICTIONS_INTERRUPTIBLE ?
+ "interruptible" : "normal") {
+ test_forking_evictions(fd, size, count, flags);
+ }
+ }
- igt_subtest("minor-unsync-normal")
- test_minor_evictions(fd, size, count);
+ igt_subtest("mlocked-unsync-normal")
+ test_mlocked_evictions(fd, size, count);
- igt_subtest("major-unsync-normal") {
- size = 200 * 1024 * 1024;
- count = (gem_aperture_size(fd) / size) + 2;
- test_major_evictions(fd, size, count);
- }
+ igt_subtest("swapping-unsync-normal")
+ test_swapping_evictions(fd, size, count);
- igt_fixture {
- size = sizeof(linear);
- count = 2 * gem_aperture_size(fd) / (1024*1024) / 3;
- if (count > total_ram * 3 / 4)
- count = intel_get_total_ram_mb() * 3 / 4;
- }
+ igt_subtest("minor-unsync-normal")
+ test_minor_evictions(fd, size, count);
- igt_fork_signal_helper();
+ igt_subtest("major-unsync-normal") {
+ size = 200 * 1024 * 1024;
+ count = (gem_aperture_size(fd) / size) + 2;
+ test_major_evictions(fd, size, count);
+ }
- igt_subtest("mlocked-unsync-interruptible")
- test_mlocked_evictions(fd, size, count);
+ igt_fixture {
+ size = sizeof(linear);
+ count = 2 * gem_aperture_size(fd) / (1024*1024) / 3;
+ if (count > total_ram * 3 / 4)
+ count = intel_get_total_ram_mb() * 3 / 4;
+ }
- igt_subtest("swapping-unsync-interruptible")
- test_swapping_evictions(fd, size, count);
+ igt_fork_signal_helper();
- igt_subtest("minor-unsync-interruptible")
- test_minor_evictions(fd, size, count);
+ igt_subtest("mlocked-unsync-interruptible")
+ test_mlocked_evictions(fd, size, count);
- igt_subtest("major-unsync-interruptible") {
- size = 200 * 1024 * 1024;
- count = (gem_aperture_size(fd) / size) + 2;
- test_major_evictions(fd, size, count);
- }
+ igt_subtest("swapping-unsync-interruptible")
+ test_swapping_evictions(fd, size, count);
- igt_stop_signal_helper();
+ igt_subtest("minor-unsync-interruptible")
+ test_minor_evictions(fd, size, count);
- igt_info("Testing synchronized mappings...\n");
+ igt_subtest("major-unsync-interruptible") {
+ size = 200 * 1024 * 1024;
+ count = (gem_aperture_size(fd) / size) + 2;
+ test_major_evictions(fd, size, count);
+ }
- igt_fixture {
- size = sizeof(linear);
- count = 2 * gem_aperture_size(fd) / (1024*1024) / 3;
- if (count > total_ram * 3 / 4)
- count = intel_get_total_ram_mb() * 3 / 4;
+ igt_stop_signal_helper();
}
- gem_userptr_test_synchronized();
+ igt_subtest_group {
+ gem_userptr_test_synchronized();
- igt_subtest("process-exit")
- test_process_exit(fd, 0);
+ igt_fixture {
+ igt_require(has_userptr(fd));
+ size = sizeof(linear);
+ count = 2 * gem_aperture_size(fd) / (1024*1024) / 3;
+ if (count > total_ram * 3 / 4)
+ count = intel_get_total_ram_mb() * 3 / 4;
+ }
+
+ igt_subtest("process-exit")
+ test_process_exit(fd, 0);
- igt_subtest("process-exit-gtt")
- test_process_exit(fd, PE_GTT_MAP);
+ igt_subtest("process-exit-gtt")
+ test_process_exit(fd, PE_GTT_MAP);
- igt_subtest("process-exit-busy")
- test_process_exit(fd, PE_BUSY);
+ igt_subtest("process-exit-busy")
+ test_process_exit(fd, PE_BUSY);
- igt_subtest("process-exit-gtt-busy")
- test_process_exit(fd, PE_GTT_MAP | PE_BUSY);
+ igt_subtest("process-exit-gtt-busy")
+ test_process_exit(fd, PE_GTT_MAP | PE_BUSY);
- igt_subtest("create-destroy-sync")
- test_create_destroy(fd, 5);
+ igt_subtest("create-destroy-sync")
+ test_create_destroy(fd, 5);
- igt_subtest("sync-overlap")
- test_overlap(fd, EINVAL);
+ igt_subtest("sync-overlap")
+ test_overlap(fd, EINVAL);
- igt_subtest("sync-unmap")
- test_unmap(fd, EFAULT);
+ igt_subtest("sync-unmap")
+ test_unmap(fd, EFAULT);
- igt_subtest("sync-unmap-cycles")
- test_unmap_cycles(fd, EFAULT);
+ igt_subtest("sync-unmap-cycles")
+ test_unmap_cycles(fd, EFAULT);
- igt_subtest("sync-unmap-after-close")
- test_unmap_after_close(fd);
+ igt_subtest("sync-unmap-after-close")
+ test_unmap_after_close(fd);
- igt_subtest("stress-mm")
- test_stress_mm(fd);
+ igt_subtest("stress-mm")
+ test_stress_mm(fd);
- igt_subtest("stress-mm-invalidate-close")
- test_invalidate_close_race(fd, false);
+ igt_subtest("stress-mm-invalidate-close")
+ test_invalidate_close_race(fd, false);
- igt_subtest("stress-mm-invalidate-close-overlap")
- test_invalidate_close_race(fd, true);
+ igt_subtest("stress-mm-invalidate-close-overlap")
+ test_invalidate_close_race(fd, true);
- igt_subtest("coherency-sync")
- test_coherency(fd, count);
+ igt_subtest("coherency-sync")
+ test_coherency(fd, count);
- igt_subtest("dmabuf-sync")
- test_dmabuf();
+ igt_subtest("dmabuf-sync")
+ test_dmabuf();
- for (unsigned flags = 0; flags < ALL_FORKING_EVICTIONS + 1; flags++) {
- igt_subtest_f("forked-sync%s%s%s-%s",
- flags & FORKING_EVICTIONS_SWAPPING ? "-swapping" : "",
- flags & FORKING_EVICTIONS_DUP_DRMFD ? "-multifd" : "",
- flags & FORKING_EVICTIONS_MEMORY_PRESSURE ?
- "-mempressure" : "",
- flags & FORKING_EVICTIONS_INTERRUPTIBLE ?
- "interruptible" : "normal") {
- test_forking_evictions(fd, size, count, flags);
+ for (unsigned flags = 0; flags < ALL_FORKING_EVICTIONS + 1; flags++) {
+ igt_subtest_f("forked-sync%s%s%s-%s",
+ flags & FORKING_EVICTIONS_SWAPPING ? "-swapping" : "",
+ flags & FORKING_EVICTIONS_DUP_DRMFD ? "-multifd" : "",
+ flags & FORKING_EVICTIONS_MEMORY_PRESSURE ?
+ "-mempressure" : "",
+ flags & FORKING_EVICTIONS_INTERRUPTIBLE ?
+ "interruptible" : "normal") {
+ test_forking_evictions(fd, size, count, flags);
+ }
}
- }
- igt_subtest("mlocked-normal-sync")
- test_mlocked_evictions(fd, size, count);
+ igt_subtest("mlocked-normal-sync")
+ test_mlocked_evictions(fd, size, count);
- igt_subtest("swapping-normal-sync")
- test_swapping_evictions(fd, size, count);
+ igt_subtest("swapping-normal-sync")
+ test_swapping_evictions(fd, size, count);
- igt_subtest("minor-normal-sync")
- test_minor_evictions(fd, size, count);
+ igt_subtest("minor-normal-sync")
+ test_minor_evictions(fd, size, count);
- igt_subtest("major-normal-sync") {
- size = 200 * 1024 * 1024;
- count = (gem_aperture_size(fd) / size) + 2;
- test_major_evictions(fd, size, count);
- }
+ igt_subtest("major-normal-sync") {
+ size = 200 * 1024 * 1024;
+ count = (gem_aperture_size(fd) / size) + 2;
+ test_major_evictions(fd, size, count);
+ }
- igt_fixture {
- size = 1024 * 1024;
- count = 2 * gem_aperture_size(fd) / (1024*1024) / 3;
- if (count > total_ram * 3 / 4)
- count = intel_get_total_ram_mb() * 3 / 4;
- }
+ igt_fixture {
+ size = 1024 * 1024;
+ count = 2 * gem_aperture_size(fd) / (1024*1024) / 3;
+ if (count > total_ram * 3 / 4)
+ count = intel_get_total_ram_mb() * 3 / 4;
+ }
- igt_fork_signal_helper();
+ igt_fork_signal_helper();
- igt_subtest("mlocked-sync-interruptible")
- test_mlocked_evictions(fd, size, count);
+ igt_subtest("mlocked-sync-interruptible")
+ test_mlocked_evictions(fd, size, count);
- igt_subtest("swapping-sync-interruptible")
- test_swapping_evictions(fd, size, count);
+ igt_subtest("swapping-sync-interruptible")
+ test_swapping_evictions(fd, size, count);
- igt_subtest("minor-sync-interruptible")
- test_minor_evictions(fd, size, count);
+ igt_subtest("minor-sync-interruptible")
+ test_minor_evictions(fd, size, count);
- igt_subtest("major-sync-interruptible") {
- size = 200 * 1024 * 1024;
- count = (gem_aperture_size(fd) / size) + 2;
- test_major_evictions(fd, size, count);
+ igt_subtest("major-sync-interruptible") {
+ size = 200 * 1024 * 1024;
+ count = (gem_aperture_size(fd) / size) + 2;
+ test_major_evictions(fd, size, count);
+ }
+
+ igt_stop_signal_helper();
}
- igt_stop_signal_helper();
igt_subtest("access-control")
test_access_control(fd);