From 5d84c764fde8c10207ee26a343e724d03e9551a7 Mon Sep 17 00:00:00 2001 From: Jordan Justen Date: Sat, 23 Mar 2019 00:28:24 -0700 Subject: [PATCH] anv: Gather engine info from i915 if available v2 (Jason Ekstrand): - Don't take an anv_physical_device in anv_gem_get_engine_info() - Return the engine info from anv_gem_get_engine_info() - Free the engine info in anv_physical_device_destroy() Signed-off-by: Jordan Justen Reviewed-by: Jason Ekstrand Reviewed-by: Lionel Landwerlin Part-of: --- src/intel/vulkan/anv_device.c | 7 +++++-- src/intel/vulkan/anv_gem.c | 22 ++++++++++++++++++++++ src/intel/vulkan/anv_gem_stubs.c | 6 ++++++ src/intel/vulkan/anv_private.h | 2 ++ 4 files changed, 35 insertions(+), 2 deletions(-) diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index 43e81ec..566a249 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -563,11 +563,12 @@ anv_physical_device_try_create(struct anv_instance *instance, } device->master_fd = master_fd; + device->engine_info = anv_gem_get_engine_info(fd); anv_physical_device_init_queue_families(device); result = anv_init_wsi(device); if (result != VK_SUCCESS) - goto fail_disk_cache; + goto fail_engine_info; device->perf = anv_get_perf(&device->info, fd); @@ -581,7 +582,8 @@ anv_physical_device_try_create(struct anv_instance *instance, return VK_SUCCESS; -fail_disk_cache: +fail_engine_info: + free(device->engine_info); anv_physical_device_free_disk_cache(device); fail_compiler: ralloc_free(device->compiler); @@ -598,6 +600,7 @@ static void anv_physical_device_destroy(struct anv_physical_device *device) { anv_finish_wsi(device); + free(device->engine_info); anv_physical_device_free_disk_cache(device); ralloc_free(device->compiler); ralloc_free(device->perf); diff --git a/src/intel/vulkan/anv_gem.c b/src/intel/vulkan/anv_gem.c index 587cf4b..3d71946 100644 --- a/src/intel/vulkan/anv_gem.c +++ b/src/intel/vulkan/anv_gem.c @@ -681,3 +681,25 @@ anv_i915_query(int fd, uint64_t query_id, void *buffer, *buffer_len = item.length; return ret; } + +struct drm_i915_query_engine_info * +anv_gem_get_engine_info(int fd) +{ + int32_t length = 0; + int ret = anv_i915_query(fd, DRM_I915_QUERY_ENGINE_INFO, NULL, &length); + assert(ret == 0); + + if (ret == -1 && errno == EINVAL) + return NULL; + + struct drm_i915_query_engine_info *info = calloc(1, length); + ret = anv_i915_query(fd, DRM_I915_QUERY_ENGINE_INFO, info, &length); + assert(ret == 0); + + if (ret != 0) { + free(info); + return NULL; + } + + return info; +} diff --git a/src/intel/vulkan/anv_gem_stubs.c b/src/intel/vulkan/anv_gem_stubs.c index c34f994..ed576a7 100644 --- a/src/intel/vulkan/anv_gem_stubs.c +++ b/src/intel/vulkan/anv_gem_stubs.c @@ -252,6 +252,12 @@ anv_i915_query(int fd, uint64_t query_id, void *buffer, unreachable("Unused"); } +struct drm_i915_query_engine_info * +anv_gem_get_engine_info(int fd) +{ + unreachable("Unused"); +} + int anv_gem_syncobj_wait(struct anv_device *device, const uint32_t *handles, uint32_t num_handles, diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index b478dde..91de322 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -1162,6 +1162,7 @@ struct anv_physical_device { struct wsi_device wsi_device; int local_fd; int master_fd; + struct drm_i915_query_engine_info * engine_info; }; struct anv_app_info { @@ -1662,6 +1663,7 @@ int anv_gem_syncobj_timeline_query(struct anv_device *device, uint32_t num_items); int anv_i915_query(int fd, uint64_t query_id, void *buffer, int32_t *buffer_len); +struct drm_i915_query_engine_info *anv_gem_get_engine_info(int fd); uint64_t anv_vma_alloc(struct anv_device *device, uint64_t size, uint64_t align, -- 2.7.4