Mesa (master): iris: Adapt to variable ppGTT size

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Apr 1 17:02:33 UTC 2019


Module: Mesa
Branch: master
Commit: 80e1ca9d28a93567a7afb916f95c4c1e5f915eb7
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=80e1ca9d28a93567a7afb916f95c4c1e5f915eb7

Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Apr  1 11:39:46 2019 +0100

iris: Adapt to variable ppGTT size

Not all hardware is made equal and some does not have the full
complement of 48b of address space. Ask what the actual size of virtual
address space allocated for contexts, and bail if that is not enough to
satisfy our static partitioning needs.

Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>

---

 src/gallium/drivers/iris/iris_bufmgr.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/iris/iris_bufmgr.c b/src/gallium/drivers/iris/iris_bufmgr.c
index 56261d4a947..be136389431 100644
--- a/src/gallium/drivers/iris/iris_bufmgr.c
+++ b/src/gallium/drivers/iris/iris_bufmgr.c
@@ -1617,6 +1617,21 @@ iris_reg_read(struct iris_bufmgr *bufmgr, uint32_t offset, uint64_t *result)
    return ret;
 }
 
+static uint64_t
+iris_gtt_size(int fd)
+{
+   /* We use the default (already allocated) context to determine
+    * the default configuration of the virtual address space.
+    */
+   struct drm_i915_gem_context_param p = {
+      .param = I915_CONTEXT_PARAM_GTT_SIZE,
+   };
+   if (!drm_ioctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_GETPARAM, &p))
+      return p.value;
+
+   return 0;
+}
+
 /**
  * Initializes the GEM buffer manager, which uses the kernel to allocate, map,
  * and manage map buffer objections.
@@ -1626,6 +1641,10 @@ iris_reg_read(struct iris_bufmgr *bufmgr, uint32_t offset, uint64_t *result)
 struct iris_bufmgr *
 iris_bufmgr_init(struct gen_device_info *devinfo, int fd)
 {
+   uint64_t gtt_size = iris_gtt_size(fd);
+   if (gtt_size <= IRIS_MEMZONE_OTHER_START)
+      return NULL;
+
    struct iris_bufmgr *bufmgr = calloc(1, sizeof(*bufmgr));
    if (bufmgr == NULL)
       return NULL;
@@ -1661,7 +1680,7 @@ iris_bufmgr_init(struct gen_device_info *devinfo, int fd)
                       _4GB - IRIS_BORDER_COLOR_POOL_SIZE);
    util_vma_heap_init(&bufmgr->vma_allocator[IRIS_MEMZONE_OTHER],
                       IRIS_MEMZONE_OTHER_START,
-                      (1ull << 48) - IRIS_MEMZONE_OTHER_START);
+                      gtt_size - IRIS_MEMZONE_OTHER_START);
 
    // XXX: driconf
    bufmgr->bo_reuse = env_var_as_boolean("bo_reuse", true);




More information about the mesa-commit mailing list