[Mesa-dev] [PATCH 3/7] i965/bufmgr: Allocate BO pages outside of the kernel's locking.

Kenneth Graunke kenneth at whitecape.org
Fri Jul 21 23:17:43 UTC 2017


Suggested by Chris Wilson.
---
 src/mesa/drivers/dri/i965/brw_bufmgr.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/brw_bufmgr.c b/src/mesa/drivers/dri/i965/brw_bufmgr.c
index 1669d26e990..78a4626d430 100644
--- a/src/mesa/drivers/dri/i965/brw_bufmgr.c
+++ b/src/mesa/drivers/dri/i965/brw_bufmgr.c
@@ -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 = I915_GEM_DOMAIN_CPU,
+      };
+
+      if (drmIoctl(bo->bufmgr->fd, DRM_IOCTL_I915_GEM_SET_DOMAIN, &sd) != 0)
+         goto err_free;
    }
 
    bo->name = name;
-- 
2.13.3



More information about the mesa-dev mailing list