From: Dominik Grzegorzek <dominik.grzegorzek@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: andrzej.hajda@intel.com,
Dominik Grzegorzek <dominik.grzegorzek@intel.com>
Subject: [PATCH i-g-t 2/4] lib: Export xe_engine_class_to_str function
Date: Wed, 11 Dec 2024 12:40:42 +0100 [thread overview]
Message-ID: <20241211114044.210562-2-dominik.grzegorzek@intel.com> (raw)
In-Reply-To: <20241211114044.210562-1-dominik.grzegorzek@intel.com>
Define xe_engine_class_to_str as library function in xe_query.h and change its name to
xe_engine_class_short_string so it matches already defined xe_engine_class_string.
Replace all uses of xe_engine_class_to_str within igt_sysfs.c.
Signed-off-by: Dominik Grzegorzek <dominik.grzegorzek@intel.com>
---
lib/igt_sysfs.c | 30 ++++++++----------------------
lib/xe/xe_query.c | 25 +++++++++++++++++++++++++
lib/xe/xe_query.h | 1 +
3 files changed, 34 insertions(+), 22 deletions(-)
diff --git a/lib/igt_sysfs.c b/lib/igt_sysfs.c
index eaf8fd882..2e4c2ee63 100644
--- a/lib/igt_sysfs.c
+++ b/lib/igt_sysfs.c
@@ -48,6 +48,7 @@
#include "igt_device.h"
#include "igt_io.h"
#include "intel_chipset.h"
+#include "xe/xe_query.h"
/**
* SECTION:igt_sysfs
@@ -291,22 +292,6 @@ bool xe_sysfs_gt_has_node(int xe_device, int gt, const char *node)
return has_node;
}
-static const char *xe_engine_class_to_str(__u16 class)
-{
- static const char * const str[] = {
- [DRM_XE_ENGINE_CLASS_RENDER] = "rcs",
- [DRM_XE_ENGINE_CLASS_COPY] = "bcs",
- [DRM_XE_ENGINE_CLASS_VIDEO_DECODE] = "vcs",
- [DRM_XE_ENGINE_CLASS_VIDEO_ENHANCE] = "vecs",
- [DRM_XE_ENGINE_CLASS_COMPUTE] = "ccs",
- };
-
- if (class < ARRAY_SIZE(str))
- return str[class];
-
- return "unk";
-}
-
/**
* xe_sysfs_engine_path:
* @xe_device: fd of the device
@@ -331,7 +316,8 @@ xe_sysfs_engine_path(int xe_device, int gt, int class, char *path, int pathlen)
return NULL;
snprintf(path, pathlen, "/sys/dev/char/%d:%d/device/tile%d/gt%d/engines/%s",
- major(st.st_rdev), minor(st.st_rdev), tile, gt, xe_engine_class_to_str(class));
+ major(st.st_rdev), minor(st.st_rdev), tile, gt,
+ xe_engine_class_short_string(class));
if (!access(path, F_OK))
return path;
@@ -1567,14 +1553,14 @@ bool xe_sysfs_engine_class_get_property(int xe_device, int gt, uint16_t class, c
engines_fd = xe_sysfs_engine_open(xe_device, gt, class);
if (engines_fd == -1) {
- igt_debug("Failed to open %s on gt%d.\n", xe_engine_class_to_str(class), gt);
+ igt_debug("Failed to open %s on gt%d.\n", xe_engine_class_short_string(class), gt);
return false;
}
if (!__igt_sysfs_get_u32(engines_fd, property, value)) {
igt_debug("Failed to read %s property of %s on gt%d.\n", property,
- xe_engine_class_to_str(class), gt);
+ xe_engine_class_short_string(class), gt);
close(engines_fd);
return false;
@@ -1606,14 +1592,14 @@ bool xe_sysfs_engine_class_set_property(int xe_device, int gt, uint16_t class, c
engines_fd = xe_sysfs_engine_open(xe_device, gt, class);
if (engines_fd == -1) {
- igt_debug("Failed to open %s on gt%d.\n", xe_engine_class_to_str(class), gt);
+ igt_debug("Failed to open %s on gt%d.\n", xe_engine_class_short_string(class), gt);
return false;
}
if (old_value && !__igt_sysfs_get_u32(engines_fd, property, old_value)) {
igt_debug("Failed to read %s property of %s on gt%d.\n", property,
- xe_engine_class_to_str(class), gt);
+ xe_engine_class_short_string(class), gt);
close(engines_fd);
return false;
@@ -1621,7 +1607,7 @@ bool xe_sysfs_engine_class_set_property(int xe_device, int gt, uint16_t class, c
if (!__igt_sysfs_set_u32(engines_fd, property, new_value)) {
igt_debug("Failed to write %s property of %s on gt%d.\n", property,
- xe_engine_class_to_str(class), gt);
+ xe_engine_class_short_string(class), gt);
close(engines_fd);
return false;
diff --git a/lib/xe/xe_query.c b/lib/xe/xe_query.c
index 73d2734e2..6a7b08006 100644
--- a/lib/xe/xe_query.c
+++ b/lib/xe/xe_query.c
@@ -241,6 +241,31 @@ const char *xe_engine_class_string(uint32_t engine_class)
}
}
+/**
+ * xe_engine_class_short_string:
+ * @engine_class: engine class
+ *
+ * Returns short name for engine class or 'unknown' otherwise.
+ */
+const char *xe_engine_class_short_string(uint32_t engine_class)
+{
+ switch (engine_class) {
+ case DRM_XE_ENGINE_CLASS_RENDER:
+ return "rcs";
+ case DRM_XE_ENGINE_CLASS_COPY:
+ return "bcs";
+ case DRM_XE_ENGINE_CLASS_VIDEO_DECODE:
+ return "vcs";
+ case DRM_XE_ENGINE_CLASS_VIDEO_ENHANCE:
+ return "vecs";
+ case DRM_XE_ENGINE_CLASS_COMPUTE:
+ return "ccs";
+ default:
+ igt_warn("Engine class 0x%x unknown\n", engine_class);
+ return "unknown";
+ }
+}
+
static struct xe_device_cache {
pthread_mutex_t cache_mutex;
struct igt_map *map;
diff --git a/lib/xe/xe_query.h b/lib/xe/xe_query.h
index 30ea5ad41..a84a6bfa5 100644
--- a/lib/xe/xe_query.h
+++ b/lib/xe/xe_query.h
@@ -114,6 +114,7 @@ uint32_t xe_va_bits(int fd);
uint16_t xe_dev_id(int fd);
int xe_supports_faults(int fd);
const char *xe_engine_class_string(uint32_t engine_class);
+const char *xe_engine_class_short_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);
--
2.34.1
next prev parent reply other threads:[~2024-12-11 11:41 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-11 11:40 [PATCH i-g-t 1/4] lib/xe_eudebug: Use igt_container_of instead of (void *) casting Dominik Grzegorzek
2024-12-11 11:40 ` Dominik Grzegorzek [this message]
2024-12-12 16:36 ` [PATCH i-g-t 2/4] lib: Export xe_engine_class_to_str function Manszewski, Christoph
2024-12-11 11:40 ` [PATCH i-g-t 3/4] lib/xe_eudebug: Use xe_engine_class_short_string Dominik Grzegorzek
2024-12-12 16:38 ` Manszewski, Christoph
2024-12-11 11:40 ` [PATCH i-g-t 4/4] lib/xe_query: Fix switch indentation Dominik Grzegorzek
2024-12-12 16:40 ` Manszewski, Christoph
2024-12-11 14:16 ` ✗ i915.CI.BAT: failure for series starting with [i-g-t,1/4] lib/xe_eudebug: Use igt_container_of instead of (void *) casting Patchwork
2024-12-11 14:21 ` ✓ Xe.CI.BAT: success " Patchwork
2024-12-11 16:11 ` ✗ Xe.CI.Full: failure " Patchwork
2024-12-12 16:30 ` [PATCH i-g-t 1/4] " Manszewski, Christoph
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241211114044.210562-2-dominik.grzegorzek@intel.com \
--to=dominik.grzegorzek@intel.com \
--cc=andrzej.hajda@intel.com \
--cc=igt-dev@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox