summaryrefslogtreecommitdiff
path: root/tests/i915/gem_userptr_blits.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2021-01-15 17:25:01 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2021-01-23 13:55:38 +0000
commit322827fead5a7f428e2e6b6227538b525a70cdf3 (patch)
treed6b9b782872e19b9c59df61de1bdbf8a54894461 /tests/i915/gem_userptr_blits.c
parent470671180bd36a694c1fd3660f02defd228d6bb1 (diff)
i915/gem_userptr_blits: Check set-domain on userptr for validation
We use set-domain on userptr to validate that get-user-pages is applicable to the address range in mesa & ddx. Let's perform a very basic test to exercise this combination. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Acked-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
Diffstat (limited to 'tests/i915/gem_userptr_blits.c')
-rw-r--r--tests/i915/gem_userptr_blits.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/i915/gem_userptr_blits.c b/tests/i915/gem_userptr_blits.c
index 8765123e..55936002 100644
--- a/tests/i915/gem_userptr_blits.c
+++ b/tests/i915/gem_userptr_blits.c
@@ -2185,6 +2185,40 @@ static void test_invalidate_close_race(int fd, bool overlap, int timeout)
free(t_data.ptr);
}
+static void test_sd_probe(int i915)
+{
+ const int domains[] = {
+ I915_GEM_DOMAIN_CPU,
+ I915_GEM_DOMAIN_GTT,
+ };
+
+ /*
+ * Quick and simple test to verify that GEM_SET_DOMAIN can
+ * be used to probe the existence of the userptr, as used
+ * by mesa and ddx.
+ */
+
+ for (int idx = 0; idx < ARRAY_SIZE(domains); idx++) {
+ uint32_t handle;
+ void *page;
+
+ page = mmap(NULL, 4096, PROT_READ | PROT_WRITE,
+ MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
+
+ gem_userptr(i915, page, 4096, 0, 0, &handle);
+ igt_assert_eq(__gem_set_domain(i915, handle, domains[idx], 0),
+ 0);
+ gem_close(i915, handle);
+
+ munmap(page, 4096);
+
+ gem_userptr(i915, page, 4096, 0, 0, &handle);
+ igt_assert_eq(__gem_set_domain(i915, handle, domains[idx], 0),
+ -EFAULT);
+ gem_close(i915, handle);
+ }
+}
+
struct ufd_thread {
uint32_t *page;
int i915;
@@ -2379,6 +2413,9 @@ igt_main_args("c:", NULL, help_str, opt_handler, NULL)
igt_subtest("forbidden-operations")
test_forbidden_ops(fd);
+ igt_subtest("sd-probe")
+ test_sd_probe(fd);
+
igt_subtest("userfault")
test_userfault(fd);