[igt-dev] [PATCH i-g-t v6 31/36] lib/i915/perf: add helper function to get report reason

Umesh Nerlige Ramappa umesh.nerlige.ramappa at intel.com
Mon Oct 10 23:02:53 UTC 2022


On Mon, Oct 10, 2022 at 09:42:10PM +0000, Umesh Nerlige Ramappa wrote:
>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 b5c69d95..cac129ea 100644
>--- a/lib/i915/perf.c
>+++ b/lib/i915/perf.c
>@@ -831,3 +831,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 bd6b96f5..b73a8d91 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 b319a3c8..b029f09e 100644
>--- a/lib/meson.build
>+++ b/lib/meson.build
>@@ -329,7 +329,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