[igt-dev] [PATCH i-g-t v5 06/30] i915/perf: Add class:instance support to OA tests

Umesh Nerlige Ramappa umesh.nerlige.ramappa at intel.com
Thu Mar 23 22:55:10 UTC 2023


Add test to verify class:instance interface to perf OA.

v2: Temporarily move uapi to lib/i915/i915_drm_local.h

Signed-off-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa at intel.com>
Reviewed-by: Ashutosh Dixit <ashutosh.dixit at intel.com>
---
 lib/i915/i915_drm_local.h |  3 +++
 tests/i915/perf.c         | 49 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 52 insertions(+)

diff --git a/lib/i915/i915_drm_local.h b/lib/i915/i915_drm_local.h
index 9a2273c4..af017650 100644
--- a/lib/i915/i915_drm_local.h
+++ b/lib/i915/i915_drm_local.h
@@ -23,6 +23,9 @@ extern "C" {
 
 #define DRM_I915_QUERY_GEOMETRY_SUBSLICES      6
 
+#define DRM_I915_PERF_PROP_OA_ENGINE_CLASS	9
+#define DRM_I915_PERF_PROP_OA_ENGINE_INSTANCE	10
+
 #if defined(__cplusplus)
 }
 #endif
diff --git a/tests/i915/perf.c b/tests/i915/perf.c
index 865858fe..a480f8ca 100644
--- a/tests/i915/perf.c
+++ b/tests/i915/perf.c
@@ -1175,6 +1175,47 @@ test_invalid_open_flags(void)
 	do_ioctl_err(drm_fd, DRM_IOCTL_I915_PERF_OPEN, &param, EINVAL);
 }
 
+static void
+test_invalid_class_instance(void)
+{
+	uint64_t properties[] = {
+		DRM_I915_PERF_PROP_SAMPLE_OA, true,
+		DRM_I915_PERF_PROP_OA_METRICS_SET, test_set->perf_oa_metrics_set,
+		DRM_I915_PERF_PROP_OA_FORMAT, test_set->perf_oa_format,
+		DRM_I915_PERF_PROP_OA_EXPONENT, oa_exp_1_millisec,
+		DRM_I915_PERF_PROP_OA_ENGINE_CLASS, 0,
+		DRM_I915_PERF_PROP_OA_ENGINE_INSTANCE, 0,
+	};
+	struct drm_i915_perf_open_param param = {
+		.flags = I915_PERF_FLAG_FD_CLOEXEC,
+		.num_properties = ARRAY_SIZE(properties) / 2,
+		.properties_ptr = to_user_pointer(properties),
+	};
+
+#define OA_E_CLASS 9
+#define OA_E_INSTANCE 11
+
+	properties[OA_E_CLASS] = I915_ENGINE_CLASS_COPY;
+	do_ioctl_err(drm_fd, DRM_IOCTL_I915_PERF_OPEN, &param, EINVAL);
+
+	properties[OA_E_CLASS] = 10;
+	do_ioctl_err(drm_fd, DRM_IOCTL_I915_PERF_OPEN, &param, EINVAL);
+
+	properties[OA_E_CLASS] = I915_ENGINE_CLASS_RENDER;
+
+	properties[OA_E_INSTANCE] = 100;
+	do_ioctl_err(drm_fd, DRM_IOCTL_I915_PERF_OPEN, &param, EINVAL);
+
+	properties[OA_E_INSTANCE] = 248;
+	do_ioctl_err(drm_fd, DRM_IOCTL_I915_PERF_OPEN, &param, EINVAL);
+
+	properties[OA_E_CLASS] = default_e2.class;
+	properties[OA_E_INSTANCE] = default_e2.instance;
+
+	stream_fd = __perf_open(drm_fd, &param, false);
+	__perf_close(stream_fd);
+}
+
 static void
 test_invalid_oa_metric_set_id(void)
 {
@@ -5294,6 +5335,14 @@ igt_main
 		}
 	}
 
+	igt_subtest_group {
+		igt_fixture igt_require(i915_perf_revision(drm_fd) >= 6);
+
+		igt_describe("Verify invalid class instance");
+		igt_subtest("gen12-invalid-class-instance")
+			test_invalid_class_instance();
+	}
+
 	igt_subtest("rc6-disable")
 		test_rc6_disable();
 
-- 
2.36.1



More information about the igt-dev mailing list