Mesa (17.1): anv: Set EXEC_OBJECT_ASYNC when available

Juan Antonio Suárez Romero jasuarez at kemper.freedesktop.org
Sat Jun 3 17:04:08 UTC 2017


Module: Mesa
Branch: 17.1
Commit: 0aa1e6acdefd25128e26e13b33384b862a87aee9
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=0aa1e6acdefd25128e26e13b33384b862a87aee9

Author: Jason Ekstrand <jason.ekstrand at intel.com>
Date:   Thu Apr 13 16:30:19 2017 -0700

anv: Set EXEC_OBJECT_ASYNC when available

Reviewed-by: Chad Versace <chadversary at chromium.org>
(cherry picked from commit 35e626bd0e59e7ce9fd97ccef66b2468c09206a4)
Signed-off-by: Juan A. Suarez Romero <jasuarez at igalia.com>

Squashed with:

anv/tests: Create a dummy instance as well as device

This fixes crashes caused by 35e626bd0e59e7ce9fd97ccef66b2468c09206a4
which made us start referencing the instance in the allocators.  With
this commit, the tests now happily pass again.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=100877
Tested-by: Vinson Lee <vlee at freedesktop.org>
(cherry picked from commit 6ef1bd4fa57b36efc7919773fd26c36fd43d2ea9)
Signed-off-by: Juan A. Suarez Romero <jasuarez at igalia.com>

---

 src/intel/vulkan/anv_allocator.c                   | 3 +++
 src/intel/vulkan/anv_device.c                      | 5 +++++
 src/intel/vulkan/anv_private.h                     | 1 +
 src/intel/vulkan/anv_wsi.c                         | 1 +
 src/intel/vulkan/tests/block_pool_no_free.c        | 5 ++++-
 src/intel/vulkan/tests/state_pool.c                | 5 ++++-
 src/intel/vulkan/tests/state_pool_free_list_only.c | 5 ++++-
 src/intel/vulkan/tests/state_pool_no_free.c        | 5 ++++-
 8 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/src/intel/vulkan/anv_allocator.c b/src/intel/vulkan/anv_allocator.c
index f3e83bc679..b1efd324f5 100644
--- a/src/intel/vulkan/anv_allocator.c
+++ b/src/intel/vulkan/anv_allocator.c
@@ -504,6 +504,9 @@ anv_block_pool_grow(struct anv_block_pool *pool, struct anv_block_state *state)
    anv_bo_init(&pool->bo, gem_handle, size);
    pool->bo.map = map;
 
+   if (pool->device->instance->physicalDevice.has_exec_async)
+      pool->bo.flags |= EXEC_OBJECT_ASYNC;
+
 done:
    pthread_mutex_unlock(&pool->device->mutex);
 
diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
index 7ad14b59f9..d22da8be0b 100644
--- a/src/intel/vulkan/anv_device.c
+++ b/src/intel/vulkan/anv_device.c
@@ -257,6 +257,8 @@ anv_physical_device_init(struct anv_physical_device *device,
    if (result != VK_SUCCESS)
       goto fail;
 
+   device->has_exec_async = anv_gem_get_param(fd, I915_PARAM_HAS_EXEC_ASYNC);
+
    if (!anv_device_get_cache_uuid(device->uuid, device->chipset_id)) {
       result = vk_errorf(VK_ERROR_INITIALIZATION_FAILED,
                          "cannot generate UUID");
@@ -1560,6 +1562,9 @@ anv_bo_init_new(struct anv_bo *bo, struct anv_device *device, uint64_t size)
    if (device->instance->physicalDevice.supports_48bit_addresses)
       bo->flags |= EXEC_OBJECT_SUPPORTS_48B_ADDRESS;
 
+   if (device->instance->physicalDevice.has_exec_async)
+      bo->flags |= EXEC_OBJECT_ASYNC;
+
    return VK_SUCCESS;
 }
 
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index 57b39a72af..599badedfd 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -624,6 +624,7 @@ struct anv_physical_device {
     struct brw_compiler *                       compiler;
     struct isl_device                           isl_dev;
     int                                         cmd_parser_version;
+    bool                                        has_exec_async;
 
     uint32_t                                    eu_total;
     uint32_t                                    subslice_total;
diff --git a/src/intel/vulkan/anv_wsi.c b/src/intel/vulkan/anv_wsi.c
index ba66ea6d46..a024561c94 100644
--- a/src/intel/vulkan/anv_wsi.c
+++ b/src/intel/vulkan/anv_wsi.c
@@ -208,6 +208,7 @@ x11_anv_wsi_image_create(VkDevice device_h,
     * know we're writing to them and synchronize uses on other rings (eg if
     * the display server uses the blitter ring).
     */
+   memory->bo.flags &= ~EXEC_OBJECT_ASYNC;
    memory->bo.flags |= EXEC_OBJECT_WRITE;
 
    anv_BindImageMemory(device_h, image_h, memory_h, 0);
diff --git a/src/intel/vulkan/tests/block_pool_no_free.c b/src/intel/vulkan/tests/block_pool_no_free.c
index 86d1a76151..0a61818e42 100644
--- a/src/intel/vulkan/tests/block_pool_no_free.c
+++ b/src/intel/vulkan/tests/block_pool_no_free.c
@@ -107,7 +107,10 @@ static void validate_monotonic(uint32_t **blocks)
 
 static void run_test()
 {
-   struct anv_device device;
+   struct anv_instance instance;
+   struct anv_device device = {
+      .instance = &instance,
+   };
    struct anv_block_pool pool;
 
    pthread_mutex_init(&device.mutex, NULL);
diff --git a/src/intel/vulkan/tests/state_pool.c b/src/intel/vulkan/tests/state_pool.c
index 878ec19a59..90c9bdea51 100644
--- a/src/intel/vulkan/tests/state_pool.c
+++ b/src/intel/vulkan/tests/state_pool.c
@@ -34,7 +34,10 @@
 
 int main(int argc, char **argv)
 {
-   struct anv_device device;
+   struct anv_instance instance;
+   struct anv_device device = {
+      .instance = &instance,
+   };
    struct anv_block_pool block_pool;
    struct anv_state_pool state_pool;
 
diff --git a/src/intel/vulkan/tests/state_pool_free_list_only.c b/src/intel/vulkan/tests/state_pool_free_list_only.c
index 2f4eb47fe4..868815cf93 100644
--- a/src/intel/vulkan/tests/state_pool_free_list_only.c
+++ b/src/intel/vulkan/tests/state_pool_free_list_only.c
@@ -33,7 +33,10 @@
 
 int main(int argc, char **argv)
 {
-   struct anv_device device;
+   struct anv_instance instance;
+   struct anv_device device = {
+      .instance = &instance,
+   };
    struct anv_block_pool block_pool;
    struct anv_state_pool state_pool;
 
diff --git a/src/intel/vulkan/tests/state_pool_no_free.c b/src/intel/vulkan/tests/state_pool_no_free.c
index 4b248c2ee6..6e012e4683 100644
--- a/src/intel/vulkan/tests/state_pool_no_free.c
+++ b/src/intel/vulkan/tests/state_pool_no_free.c
@@ -54,7 +54,10 @@ static void *alloc_states(void *_job)
 
 static void run_test()
 {
-   struct anv_device device;
+   struct anv_instance instance;
+   struct anv_device device = {
+      .instance = &instance,
+   };
    struct anv_block_pool block_pool;
    struct anv_state_pool state_pool;
 




More information about the mesa-commit mailing list