[igt-dev] [PATCH i-g-t v2 25/28] lib/i915/perf: add helper function to get report reason

Umesh Nerlige Ramappa umesh.nerlige.ramappa at intel.com
Thu Oct 27 20:55:32 UTC 2022


From: Lionel Landwerlin <lionel.g.landwerlin at intel.com>

Useful to inspect reports.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Reviewed-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa at intel.com>
---
 lib/i915/perf.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++
 lib/i915/perf.h |  3 +++
 lib/meson.build |  2 +-
 3 files changed, 58 insertions(+), 1 deletion(-)

diff --git a/lib/i915/perf.c b/lib/i915/perf.c
index 2d309e57..fa291998 100644
--- a/lib/i915/perf.c
+++ b/lib/i915/perf.c
@@ -902,3 +902,57 @@ uint64_t intel_perf_read_record_timestamp_raw(const struct intel_perf *perf,
 
        return ts;
 }
+
+const char *intel_perf_read_report_reason(const struct intel_perf *perf,
+					  const struct drm_i915_perf_record_header *record)
+{
+	const uint32_t *report = (const uint32_t *) (record + 1);
+
+	/* Not really documented on Gfx7/7.5*/
+	if (perf->devinfo.graphics_ver < 8)
+		return "timer";
+
+	/* Gfx8-11 */
+	if (perf->devinfo.graphics_ver < 12) {
+		uint32_t reason = report[0] >> 19;
+		if (reason & (1u << 0))
+			return "timer";
+		if (reason & (1u << 1))
+			return "trigger1";
+		if (reason & (1u << 2))
+			return "trigger2";
+		if (reason & (1u << 3))
+			return "context-switch";
+		if (reason & (1u << 4))
+			return "go-transition";
+
+		if (perf->devinfo.graphics_ver >= 9 &&
+		    reason & (1u << 5))
+			return "clock-ratio-change";
+
+		return "unknown";
+	}
+
+	/* Gfx12 */
+	if (perf->devinfo.graphics_ver <= 12) {
+		uint32_t reason = report[0] >> 19;
+		if (reason & (1u << 0))
+			return "timer";
+		if (reason & (1u << 1))
+			return "trigger1";
+		if (reason & (1u << 2))
+			return "trigger2";
+		if (reason & (1u << 3))
+			return "context-switch";
+		if (reason & (1u << 4))
+			return "go-transition";
+		if (reason & (1u << 5))
+			return "clock-ratio-change";
+		if (reason & (1u << 6))
+			return "mmio-trigger";
+
+		return "unknown";
+	}
+
+	return "unknown";
+}
diff --git a/lib/i915/perf.h b/lib/i915/perf.h
index 8a2ef9e7..e6e60dc9 100644
--- a/lib/i915/perf.h
+++ b/lib/i915/perf.h
@@ -348,6 +348,9 @@ uint64_t intel_perf_read_record_timestamp_raw(const struct intel_perf *perf,
 					      const struct intel_perf_metric_set *metric_set,
 					      const struct drm_i915_perf_record_header *record);
 
+const char *intel_perf_read_report_reason(const struct intel_perf *perf,
+					  const struct drm_i915_perf_record_header *record);
+
 #ifdef __cplusplus
 };
 #endif
diff --git a/lib/meson.build b/lib/meson.build
index 6b5b9e04..4b6d2267 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -342,7 +342,7 @@ pkgconf.set('prefix', get_option('prefix'))
 pkgconf.set('exec_prefix', '${prefix}')
 pkgconf.set('libdir', '${prefix}/@0@'.format(get_option('libdir')))
 pkgconf.set('includedir', '${prefix}/@0@'.format(get_option('includedir')))
-pkgconf.set('i915_perf_version', '1.5.0')
+pkgconf.set('i915_perf_version', '1.5.1')
 
 configure_file(
   input : 'i915-perf.pc.in',
-- 
2.25.1



More information about the igt-dev mailing list