i965/bufmgr: Allocate BO pages outside of the kernel's locking.
authorKenneth Graunke <kenneth@whitecape.org>
Fri, 21 Jul 2017 19:29:30 +0000 (12:29 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Sun, 23 Jul 2017 02:34:42 +0000 (19:34 -0700)
Suggested by Chris Wilson.

v2: Set the write domain to 0 (suggested by Chris).

Reviewed-by: Matt Turner <mattst88@gmail.com>
src/mesa/drivers/dri/i965/brw_bufmgr.c

index 46da53d3530928a1492793b66f4721c51de5fd65..cd85874ea526fd1790870d73e4f869df3420e646 100644 (file)
@@ -382,6 +382,19 @@ retry:
 
       if (bo_set_tiling_internal(bo, tiling_mode, stride))
          goto err_free;
+
+      /* Calling set_domain() will allocate pages for the BO outside of the
+       * struct mutex lock in the kernel, which is more efficient than waiting
+       * to create them during the first execbuf that uses the BO.
+       */
+      struct drm_i915_gem_set_domain sd = {
+         .handle = bo->gem_handle,
+         .read_domains = I915_GEM_DOMAIN_CPU,
+         .write_domain = 0,
+      };
+
+      if (drmIoctl(bo->bufmgr->fd, DRM_IOCTL_I915_GEM_SET_DOMAIN, &sd) != 0)
+         goto err_free;
    }
 
    bo->name = name;