[PATCH i-g-t 1/2] lib/xe/xe_query: xe_find_engine_by_class helper
Pravalika Gurram
pravalika.gurram at intel.com
Tue Oct 15 14:18:25 UTC 2024
Added "xe_find_engine_by_class" helper function
to query with the required engine class
and get the engine info.
Cc: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
Signed-off-by: Pravalika Gurram <pravalika.gurram at intel.com>
---
lib/xe/xe_query.c | 22 ++++++++++++++++++++++
lib/xe/xe_query.h | 1 +
2 files changed, 23 insertions(+)
diff --git a/lib/xe/xe_query.c b/lib/xe/xe_query.c
index 8694fa3f9..ddb9d4065 100644
--- a/lib/xe/xe_query.c
+++ b/lib/xe/xe_query.c
@@ -731,6 +731,28 @@ bool xe_has_engine_class(int fd, uint16_t engine_class)
return false;
}
+/**
+ * xe_find_engine_by_class
+ * @fd: xe device fd
+ * @engine_class: engine class
+ *
+ * Returns engine info of xe device @fd and @engine_class otherwise NULL.
+ */
+struct drm_xe_engine *xe_find_engine_by_class(int fd, uint16_t engine_class)
+{
+ struct xe_device *xe_dev;
+
+ xe_dev = find_in_cache(fd);
+ igt_assert(xe_dev);
+
+ igt_assert(engine_class >= 0 && engine_class < xe_dev->engines->num_engines);
+ for (int i = 0; i < xe_dev->engines->num_engines; i++)
+ if (xe_dev->engines->engines[i].instance.engine_class == engine_class)
+ return &xe_dev->engines->engines[i];
+
+ return NULL;
+
+}
/**
* xe_has_media_gt:
* @fd: xe device fd
diff --git a/lib/xe/xe_query.h b/lib/xe/xe_query.h
index fd1155f7f..cabb8078c 100644
--- a/lib/xe/xe_query.h
+++ b/lib/xe/xe_query.h
@@ -108,6 +108,7 @@ uint16_t xe_dev_id(int fd);
int xe_supports_faults(int fd);
const char *xe_engine_class_string(uint32_t engine_class);
bool xe_has_engine_class(int fd, uint16_t engine_class);
+struct drm_xe_engine *xe_find_engine_by_class(int fd, uint16_t engine_class);
bool xe_has_media_gt(int fd);
bool xe_is_media_gt(int fd, int gt);
uint16_t xe_gt_get_tile_id(int fd, int gt);
--
2.34.1
More information about the igt-dev
mailing list