Mesa (master): anv: Gather engine info from i915 if available
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Jan 28 18:34:22 UTC 2021
Module: Mesa
Branch: master
Commit: 5d84c764fde8c10207ee26a343e724d03e9551a7
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=5d84c764fde8c10207ee26a343e724d03e9551a7
Author: Jordan Justen <jordan.l.justen at intel.com>
Date: Sat Mar 23 00:28:24 2019 -0700
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 <jordan.l.justen at intel.com>
Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8667>
---
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 43e81ece144..566a24994fe 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 587cf4b2ef4..3d7194657df 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 c34f9945e9c..ed576a7fd19 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 b478ddedaf4..91de3223730 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,
More information about the mesa-commit
mailing list