[PATCH 106/119] drm/i915/userptr: Probe existence of backing struct pages upon creation
Chris Wilson
chris at chris-wilson.co.uk
Tue Sep 11 11:55:40 UTC 2018
Jason Ekstrand requested a more efficient method than userptr+set-domain
to determine if the userptr object was backed by a complete set of pages
upon creation. To be more efficient than simply populating the userptr
using get_user_pages() (as done by the call to set-domain or execbuf),
we can walk the tree of vm_area_struct and check for gaps or vma not
backed by struct page (VM_PFNMAP). The question is how to handle
VM_MIXEDMAP which may be either struct page or pfn backed...
Testcase: igt/gem_userptr_blits/probe
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
Cc: MichaĆ Winiarski <michal.winiarski at intel.com>
Cc: Jason Ekstrand <jason at jlekstrand.net>
---
drivers/gpu/drm/i915/i915_gem_userptr.c | 13 +++++++++++++
include/uapi/drm/i915_drm.h | 5 +++--
2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_gem_userptr.c b/drivers/gpu/drm/i915/i915_gem_userptr.c
index cd3238318d49..aaa081092930 100644
--- a/drivers/gpu/drm/i915/i915_gem_userptr.c
+++ b/drivers/gpu/drm/i915/i915_gem_userptr.c
@@ -840,6 +840,7 @@ i915_gem_userptr_ioctl(struct drm_device *dev,
}
if (args->flags & ~(I915_USERPTR_READ_ONLY |
+ I915_USERPTR_PROBE |
I915_USERPTR_UNSYNCHRONIZED))
return -EINVAL;
@@ -865,6 +866,18 @@ i915_gem_userptr_ioctl(struct drm_device *dev,
return -ENODEV;
}
+ if (args->flags & I915_USERPTR_PROBE) {
+ /*
+ * Check that the range pointed to represents real struct
+ * pages and not iomappings (at *this* moment in time!)
+ */
+ down_read(¤t->mm->mmap_sem);
+ ret = probe_range(current->mm, args->user_ptr, args->user_size);
+ up_read(¤t->mm->mmap_sem);
+ if (ret)
+ return ret;
+ }
+
obj = i915_gem_object_alloc(dev_priv);
if (obj == NULL)
return -ENOMEM;
diff --git a/include/uapi/drm/i915_drm.h b/include/uapi/drm/i915_drm.h
index f8cfe21d73ac..6378d89ba587 100644
--- a/include/uapi/drm/i915_drm.h
+++ b/include/uapi/drm/i915_drm.h
@@ -1502,8 +1502,9 @@ struct drm_i915_gem_userptr {
__u64 user_ptr;
__u64 user_size;
__u32 flags;
-#define I915_USERPTR_READ_ONLY 0x1
-#define I915_USERPTR_UNSYNCHRONIZED 0x80000000
+#define I915_USERPTR_READ_ONLY 0x1
+#define I915_USERPTR_PROBE 0x2
+#define I915_USERPTR_UNSYNCHRONIZED 0x80000000
/**
* Returned handle for the object.
*
--
2.19.0.rc2
More information about the Intel-gfx-trybot
mailing list