summaryrefslogtreecommitdiff
path: root/tests/i915/gem_userptr_blits.c
diff options
context:
space:
mode:
authorJanusz Krzysztofik <janusz.krzysztofik@linux.intel.com>2020-02-21 12:17:01 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2020-02-24 14:14:48 +0000
commit90eaa6ad94966fe8189a9cc848f4ca01cef1164c (patch)
tree98baf1c7fb300a8f37885520ff78b8f88b33af92 /tests/i915/gem_userptr_blits.c
parent384e7ecb7464eb8ffb802909ba0cd32157c140bd (diff)
tests/gem_userptr_blits: Exercise mmap-offset mapping to userptr
Currently unavoidable lockedp loop related to userptr MMU notifier exists in the i915 driver. For that reason, attempts to set up a mmap-offset (or mmap-gtt) mapping to a userptr object may be now preventively rejected by the driver. A test should exists which checks for that. Would a mapping attempt succeed, the test should trigger the MMU notifier in a way that is proven to result in the lockdep slpat. As that exercise is strictly userptr related, it has been decided to add it as a new subtest to gem_userptr_blits. The new subtest examines userptr interaction with every supported mmap-offset type mapping on top of it. v2: Move the subtest from gem_mmap_offset to gem_userptr_blits, - use dynamic subtests (Chris), - don't FAIL but SKIP on mmap-offset attempt failure (Chris), - on success, try to anger lockdep (Chris). Suggested-by: Chris Wilson <chris@chris-wilson.co.uk Signed-off-by: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com> Cc: Matthew Auld <matthew.auld@intel.com> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'tests/i915/gem_userptr_blits.c')
-rw-r--r--tests/i915/gem_userptr_blits.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/i915/gem_userptr_blits.c b/tests/i915/gem_userptr_blits.c
index fcad374e..cd1a3af2 100644
--- a/tests/i915/gem_userptr_blits.c
+++ b/tests/i915/gem_userptr_blits.c
@@ -797,6 +797,40 @@ static int test_map_fixed_invalidate(int fd, uint32_t flags)
return 0;
}
+static void test_mmap_offset_invalidate(int fd, const struct mmap_offset *t)
+{
+ void *ptr, *map;
+ uint32_t handle;
+
+ /* check if mmap_offset type is supported by hardware, skip if not */
+ handle = gem_create(fd, PAGE_SIZE);
+ map = __gem_mmap_offset(fd, handle, 0, PAGE_SIZE,
+ PROT_READ | PROT_WRITE, t->type);
+ igt_require_f(map,
+ "HW & kernel support for mmap_offset(%s)\n", t->name);
+ munmap(map, PAGE_SIZE);
+ gem_close(fd, handle);
+
+ /* create userptr object */
+ igt_assert_eq(posix_memalign(&ptr, PAGE_SIZE, PAGE_SIZE), 0);
+ gem_userptr(fd, ptr, PAGE_SIZE, 0, userptr_flags, &handle);
+
+ /* set up mmap-offset mapping on top of the object, skip if refused */
+ map = __gem_mmap_offset(fd, handle, 0, PAGE_SIZE,
+ PROT_READ | PROT_WRITE, t->type);
+ igt_require_f(map, "mmap-offset banned, lockdep loop prevention\n");
+
+ /* set object pages in order to activate MMU notifier for it */
+ gem_set_domain(fd, handle, t->domain, t->domain);
+
+ /* trigger the notifier */
+ munmap(ptr, PAGE_SIZE);
+
+ /* cleanup */
+ munmap(map, PAGE_SIZE);
+ gem_close(fd, handle);
+}
+
static int test_forbidden_ops(int fd)
{
struct drm_i915_gem_pread gem_pread;
@@ -2170,6 +2204,12 @@ igt_main_args("c:", NULL, help_str, opt_handler, NULL)
}
}
+ igt_describe("Invalidate pages of userptr with mmap-offset on top");
+ igt_subtest_with_dynamic("mmap-offset-invalidate")
+ for_each_mmap_offset_type(fd, t)
+ igt_dynamic_f("%s", t->name)
+ test_mmap_offset_invalidate(fd, t);
+
igt_subtest("coherency-sync")
test_coherency(fd, count);