xf86-video-intel: src/sna/kgem.c
Chris Wilson
ickle at kemper.freedesktop.org
Tue Apr 14 15:45:23 PDT 2015
src/sna/kgem.c | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
New commits:
commit 37ce4dd0a02dd5b33017904580219a6541da9428
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Tue Apr 14 23:43:19 2015 +0100
sna: Leak the mmu_notifier for sync userptr
Since creating/destroying the mmu_notifier for sync userptr is fairly
expensive, leak the test userptr object to keep it around for the
lifetime of our process.
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
diff --git a/src/sna/kgem.c b/src/sna/kgem.c
index 59ebe83..952f249 100644
--- a/src/sna/kgem.c
+++ b/src/sna/kgem.c
@@ -1192,7 +1192,7 @@ static bool test_has_caching(struct kgem *kgem)
static bool test_has_userptr(struct kgem *kgem)
{
- uint32_t handle;
+ struct local_i915_gem_userptr arg;
void *ptr;
if (DBG_NO_USERPTR)
@@ -1205,11 +1205,23 @@ static bool test_has_userptr(struct kgem *kgem)
if (posix_memalign(&ptr, PAGE_SIZE, PAGE_SIZE))
return false;
- handle = gem_userptr(kgem->fd, ptr, PAGE_SIZE, false);
- gem_close(kgem->fd, handle);
- free(ptr);
+ VG_CLEAR(arg);
+ arg.user_ptr = (uintptr_t)ptr;
+ arg.user_size = PAGE_SIZE;
+ arg.flags = I915_USERPTR_UNSYNCHRONIZED;
+
+ if (DBG_NO_UNSYNCHRONIZED_USERPTR ||
+ do_ioctl(kgem->fd, LOCAL_IOCTL_I915_GEM_USERPTR, &arg)) {
+ arg.flags &= ~I915_USERPTR_UNSYNCHRONIZED;
+ if (do_ioctl(kgem->fd, LOCAL_IOCTL_I915_GEM_USERPTR, &arg))
+ arg.handle = 0;
+ /* Leak the userptr bo to keep the mmu_notifier alive */
+ } else {
+ gem_close(kgem->fd, arg.handle);
+ free(ptr);
+ }
- return handle != 0;
+ return arg.handle != 0;
}
static bool test_has_create2(struct kgem *kgem)
More information about the xorg-commit
mailing list