<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">I commented on this in the office, but I think this whole thing would be cleaner if we just clearly documented address ranges in anv_private.h with a good comment.  Something like<br><br></div><div class="gmail_quote">#define LOW_HEAP_BASE_ADDRESS 4096<br></div><div class="gmail_quote">#define LOW_HEAP_SIZE ((3ull << 30) - 4096)<br></div><div class="gmail_quote">#define DYNAMIC_STATE_POOL_ADDRESS (3ull << 30)<br></div><div class="gmail_quote">#define BINDING_TABLE_POOL_ADDRESS (4ull << 30)<br></div><div class="gmail_quote">#define SURFACE_STATE_POOL_ADDRESS (5ull << 30)<br><br></div><div class="gmail_quote">Maybe we want it in hex?  I'm not sure.  In any case, I think having the layout explicit is better.<br></div><div class="gmail_quote"><br>On Wed, May 2, 2018 at 9:01 AM, Scott D Phillips <span dir="ltr"><<a href="mailto:scott.d.phillips@intel.com" target="_blank">scott.d.phillips@intel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The state_pools reserve virtual address space of the full<br>
BLOCK_POOL_MEMFD_SIZE, but maintain the current behavior of<br>
growing from the middle.<br>
---<br>
 src/intel/vulkan/anv_allocato<wbr>r.c | 25 +++++++++++++++++++++++++<br>
 src/intel/vulkan/anv_device.c<wbr>    | 13 +++++++++----<br>
 src/intel/vulkan/anv_private.<wbr>h   |  2 ++<br>
 3 files changed, 36 insertions(+), 4 deletions(-)<br>
<br>
diff --git a/src/intel/vulkan/anv_allocat<wbr>or.c b/src/intel/vulkan/anv_allocat<wbr>or.c<br>
index 642e1618c10..fa4e7d74ac7 100644<br>
--- a/src/intel/vulkan/anv_allocat<wbr>or.c<br>
+++ b/src/intel/vulkan/anv_allocat<wbr>or.c<br>
@@ -250,6 +250,27 @@ anv_block_pool_init(struct anv_block_pool *pool,<br>
<br>
    pool->device = device;<br>
    pool->bo_flags = bo_flags;<br>
+<br>
+   if (bo_flags & EXEC_OBJECT_PINNED) {<br>
+      pool->offset = 0;<br>
+<br>
+      pthread_mutex_lock(&device->vm<wbr>a_mutex);<br>
+<br>
+      if (bo_flags & EXEC_OBJECT_SUPPORTS_48B_ADDRE<wbr>SS)<br>
+         pool->offset = util_vma_heap_alloc(&device->v<wbr>ma_hi,<br>
+                                            BLOCK_POOL_MEMFD_SIZE, 4096);<br>
+<br>
+      if (!pool->offset)<br>
+         pool->offset = util_vma_heap_alloc(&device->v<wbr>ma_lo,<br>
+                                            BLOCK_POOL_MEMFD_SIZE, 4096);<br>
+<br>
+      pthread_mutex_unlock(&device-><wbr>vma_mutex);<br>
+<br>
+      if (!pool->offset)<br>
+         return vk_error(VK_ERROR_OUT_OF_DEVIC<wbr>E_MEMORY);<br>
+<br>
+      pool->offset = canonical_address(pool->offset<wbr>);<br>
+   }<br>
    anv_bo_init(&pool->bo, 0, 0);<br>
<br>
    pool->fd = memfd_create("block pool", MFD_CLOEXEC);<br>
@@ -402,6 +423,10 @@ anv_block_pool_expand_range(st<wbr>ruct anv_block_pool *pool,<br>
     * hard work for us.<br>
     */<br>
    anv_bo_init(&pool->bo, gem_handle, size);<br>
+   if (pool->bo_flags & EXEC_OBJECT_PINNED) {<br>
+      pool->bo.offset = pool->offset + BLOCK_POOL_MEMFD_CENTER -<br>
+         center_bo_offset;<br>
+   }<br>
    pool->bo.flags = pool->bo_flags;<br>
    pool->bo.map = map;<br>
<br>
diff --git a/src/intel/vulkan/anv_device.<wbr>c b/src/intel/vulkan/anv_device.<wbr>c<br>
index d3d9c779d62..2837d2f83ca 100644<br>
--- a/src/intel/vulkan/anv_device.<wbr>c<br>
+++ b/src/intel/vulkan/anv_device.<wbr>c<br>
@@ -1613,12 +1613,17 @@ VkResult anv_CreateDevice(<br>
    if (result != VK_SUCCESS)<br>
       goto fail_batch_bo_pool;<br>
<br>
-   /* For the state pools we explicitly disable 48bit. */<br>
-   bo_flags = (physical_device->has_exec_asy<wbr>nc ? EXEC_OBJECT_ASYNC : 0) |<br>
-              (physical_device->has_exec_cap<wbr>ture ? EXEC_OBJECT_CAPTURE : 0);<br>
+   if (physical_device->has_exec_sof<wbr>tpin)<br>
+      bo_flags |= EXEC_OBJECT_PINNED;<br>
+   else<br>
+      bo_flags &= ~EXEC_OBJECT_SUPPORTS_48B_ADDR<wbr>ESS;<br>
<br>
+   /* dynamic_state_pool needs to stay in the same 4GiB as index and<br>
+    * vertex buffers. For rationale, see the comment in<br>
+    * anv_physical_device_init_heaps<wbr>.<br>
+    */<br>
    result = anv_state_pool_init(&device->d<wbr>ynamic_state_pool, device, 16384,<br>
-                                bo_flags);<br>
+                                bo_flags & ~EXEC_OBJECT_SUPPORTS_48B_ADDR<wbr>ESS);<br>
    if (result != VK_SUCCESS)<br>
       goto fail_bo_cache;<br>
<br>
diff --git a/src/intel/vulkan/anv_private<wbr>.h b/src/intel/vulkan/anv_private<wbr>.h<br>
index 708c3a540d3..23527eebaab 100644<br>
--- a/src/intel/vulkan/anv_private<wbr>.h<br>
+++ b/src/intel/vulkan/anv_private<wbr>.h<br>
@@ -582,6 +582,8 @@ struct anv_block_pool {<br>
<br>
    struct anv_bo bo;<br>
<br>
+   uint64_t offset;<br></blockquote><div><br></div><div>This might be better named "start_address".  Also, we should have a comment saying what it means. :-)<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
    /* The offset from the start of the bo to the "center" of the block<br>
     * pool.  Pointers to allocated blocks are given by<br>
     * bo.map + center_bo_offset + offsets.<br>
<span class="m_-5099171929792544623m_4387367380000536717HOEnZb"><font color="#888888">-- <br>
2.14.3<br>
<br>
</font></span></blockquote></div><br></div></div>