[Intel-gfx] [PATCH i-g-t] prime_vgem: Check that we wrap the vgem mmap with userptr
Chris Wilson
chris at chris-wilson.co.uk
Thu Oct 8 22:13:34 UTC 2020
This came up in a discussion about importing virtio dma-buf, which are
themselves plain shmemfs objects and so not only backed by struct pages,
but wrappable by userptr. vgem share the same properties and so should
serve as a useful proxy for testing.
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
Cc: "Graunke, Kenneth W" <kenneth.w.graunke at intel.com>,
Cc: "Lahtinen, Joonas" <joonas.lahtinen at intel.com>
Cc: "Kondapally, Kalyan" <kalyan.kondapally at intel.com>
---
tests/intel-ci/fast-feedback.testlist | 1 +
tests/prime_vgem.c | 42 +++++++++++++++++++++++++++
2 files changed, 43 insertions(+)
diff --git a/tests/intel-ci/fast-feedback.testlist b/tests/intel-ci/fast-feedback.testlist
index aa2eb3295..982d25834 100644
--- a/tests/intel-ci/fast-feedback.testlist
+++ b/tests/intel-ci/fast-feedback.testlist
@@ -143,6 +143,7 @@ igt at prime_vgem@basic-fence-read
igt at prime_vgem@basic-gtt
igt at prime_vgem@basic-read
igt at prime_vgem@basic-write
+igt at prime_vgem@basic-userptr
igt at vgem_basic@setversion
igt at vgem_basic@create
igt at vgem_basic@debugfs
diff --git a/tests/prime_vgem.c b/tests/prime_vgem.c
index 38e2026aa..425bba8fb 100644
--- a/tests/prime_vgem.c
+++ b/tests/prime_vgem.c
@@ -287,6 +287,45 @@ static void test_write(int vgem, int i915)
munmap(ptr, scratch.size);
}
+static uint32_t batch_create(int i915)
+{
+ const uint32_t bbe = MI_BATCH_BUFFER_END;
+ uint32_t handle;
+
+ handle = gem_create(i915, 4096);
+ gem_write(i915, handle, 0, &bbe, sizeof(bbe));
+
+ return handle;
+}
+
+static void test_userptr(int vgem, int i915)
+{
+ struct vgem_bo scratch;
+ struct drm_i915_gem_exec_object2 obj[2] = {};
+ struct drm_i915_gem_execbuffer2 execbuf = {
+ .buffers_ptr = to_user_pointer(obj),
+ .buffer_count = ARRAY_SIZE(obj),
+ };
+ uint32_t *ptr;
+
+ scratch.width = 1024;
+ scratch.height = 1024;
+ scratch.bpp = 32;
+ vgem_create(vgem, &scratch);
+
+ ptr = vgem_mmap(vgem, &scratch, PROT_WRITE);
+ gem_close(vgem, scratch.handle);
+
+ gem_userptr(i915, (uint32_t *)ptr, scratch.size, 0, 0, &obj[0].handle);
+ obj[1].handle = batch_create(i915);
+
+ gem_execbuf(i915, &execbuf);
+ gem_close(i915, obj[1].handle);
+ gem_close(i915, obj[0].handle);
+
+ munmap(ptr, scratch.size);
+}
+
static void test_gtt(int vgem, int i915)
{
struct vgem_bo scratch;
@@ -1038,6 +1077,9 @@ igt_main
igt_subtest("basic-write")
test_write(vgem, i915);
+ igt_subtest("basic-userptr")
+ test_userptr(vgem, i915);
+
igt_subtest("basic-gtt") {
gem_require_mappable_ggtt(i915);
test_gtt(vgem, i915);
--
2.28.0
More information about the Intel-gfx
mailing list