summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLucas De Marchi <lucas.demarchi@intel.com>2024-05-03 23:46:37 -0700
committerLucas De Marchi <lucas.demarchi@intel.com>2024-05-08 09:07:40 -0700
commit0df7b9b97f9da0e364f5ee30fe331004b8c86b56 (patch)
tree1ceeea552aecf55df4bb098ce1d10b7e74fbb01f
parent55281583000fae8d359ee985b168e59f614651f5 (diff)
lib/igt_drm_fdinfo: Start tracking available engine keys
Start tracking what are the available keys related to engine utilization that were parsed from fdinfo. This can be later used by application to make decisions on which of them to use. Acked-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com> Reviewed-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com> Link: https://lore.kernel.org/r/20240504064643.25863-8-lucas.demarchi@intel.com Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
-rw-r--r--lib/igt_drm_fdinfo.c7
-rw-r--r--lib/igt_drm_fdinfo.h8
2 files changed, 12 insertions, 3 deletions
diff --git a/lib/igt_drm_fdinfo.c b/lib/igt_drm_fdinfo.c
index a780038c0..0a4b5f234 100644
--- a/lib/igt_drm_fdinfo.c
+++ b/lib/igt_drm_fdinfo.c
@@ -190,10 +190,11 @@ out:
} \
} while (0)
-#define UPDATE_ENGINE(idx, engine, val) \
+#define UPDATE_ENGINE(idx, engine, val, utilization_key) \
do { \
if (idx >= 0) { \
info->engine[idx] = val; \
+ info->utilization_mask |= utilization_key; \
if (!info->capacity[idx]) \
info->capacity[idx] = 1; \
if (!engines_found[idx]) { \
@@ -259,11 +260,11 @@ __igt_parse_drm_fdinfo(int dir, const char *fd, struct drm_client_fdinfo *info,
} else if (strstartswith(l, "drm-engine-", &keylen)) {
idx = parse_engine(l + keylen, info,
name_map, map_entries, &val);
- UPDATE_ENGINE(idx, busy, val);
+ UPDATE_ENGINE(idx, busy, val, DRM_FDINFO_UTILIZATION_ENGINE_TIME);
} else if (strstartswith(l, "drm-cycles-", &keylen)) {
idx = parse_engine(l + keylen, info,
name_map, map_entries, &val);
- UPDATE_ENGINE(idx, cycles, val);
+ UPDATE_ENGINE(idx, cycles, val, DRM_FDINFO_UTILIZATION_CYCLES);
} else if (strstartswith(l, "drm-total-", &keylen)) {
idx = parse_region(l + keylen, info,
region_map, region_entries, &val);
diff --git a/lib/igt_drm_fdinfo.h b/lib/igt_drm_fdinfo.h
index 17a47f94a..3f641d79d 100644
--- a/lib/igt_drm_fdinfo.h
+++ b/lib/igt_drm_fdinfo.h
@@ -41,6 +41,11 @@ struct drm_client_meminfo {
uint64_t active;
};
+enum drm_fdinfo_utilization {
+ DRM_FDINFO_UTILIZATION_ENGINE_TIME = 1U << 0,
+ DRM_FDINFO_UTILIZATION_CYCLES = 1U << 1,
+};
+
struct drm_client_fdinfo {
char driver[128];
char pdev[128];
@@ -51,6 +56,9 @@ struct drm_client_fdinfo {
unsigned int capacity[DRM_CLIENT_FDINFO_MAX_ENGINES];
char names[DRM_CLIENT_FDINFO_MAX_ENGINES][256];
+ /* mask of enum drm_fdinfo_utilization parsed from fdinfo */
+ unsigned int utilization_mask;
+
/* drm-engine-<engine> values */
uint64_t busy[DRM_CLIENT_FDINFO_MAX_ENGINES];
/* drm-cycles-<engine> values */