[Intel-gfx] [PATCH i-g-t 3/4] igt/gem_blits: Check for blitter support before use

Chris Wilson chris at chris-wilson.co.uk
Thu Aug 29 13:05:24 UTC 2019


Not all HW supports XY blitter commands, so check before use.

Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
 lib/i915/gem_submission.c          | 28 ++++++++++++++++++++++++++++
 lib/i915/gem_submission.h          |  9 +++++++++
 tests/i915/gem_linear_blits.c      |  1 +
 tests/i915/gem_tiled_blits.c       |  1 +
 tests/i915/gem_tiled_fence_blits.c |  1 +
 5 files changed, 40 insertions(+)

diff --git a/lib/i915/gem_submission.c b/lib/i915/gem_submission.c
index 7602d7f68..4f9464931 100644
--- a/lib/i915/gem_submission.c
+++ b/lib/i915/gem_submission.c
@@ -225,3 +225,31 @@ void gem_test_engine(int i915, unsigned int engine)
 	igt_assert(!is_wedged(i915));
 	close(i915);
 }
+
+int gem_cmdparser_version(int i915, uint32_t engine)
+{
+	int version = 0;
+	drm_i915_getparam_t gp = {
+		.param = I915_PARAM_CMD_PARSER_VERSION,
+		.value = &version,
+	};
+
+	ioctl(i915, DRM_IOCTL_I915_GETPARAM, &gp);
+	return version;
+}
+
+bool gem_has_blitter(int i915)
+{
+	unsigned int blt;
+
+	blt = 0;
+	if (intel_gen(intel_get_drm_devid(i915)) >= 6)
+		blt = I915_EXEC_BLT;
+
+	return gem_has_ring(i915, blt);
+}
+
+void gem_require_blitter(int i915)
+{
+	igt_require(gem_has_blitter(i915));
+}
diff --git a/lib/i915/gem_submission.h b/lib/i915/gem_submission.h
index f94eabb20..ca32b68a3 100644
--- a/lib/i915/gem_submission.h
+++ b/lib/i915/gem_submission.h
@@ -33,6 +33,15 @@ bool gem_has_semaphores(int fd);
 bool gem_has_execlists(int fd);
 bool gem_has_guc_submission(int fd);
 
+int gem_cmdparser_version(int i915, uint32_t engine);
+static inline bool gem_has_cmdparser(int i915, uint32_t engine)
+{
+	return gem_cmdparser_version(i915, engine) > 0;
+}
+
+bool gem_has_blitter(int i915);
+void gem_require_blitter(int i915);
+
 void gem_test_engine(int fd, unsigned int engine);
 
 int gem_reopen_driver(int fd);
diff --git a/tests/i915/gem_linear_blits.c b/tests/i915/gem_linear_blits.c
index a5359288e..07ca2f29e 100644
--- a/tests/i915/gem_linear_blits.c
+++ b/tests/i915/gem_linear_blits.c
@@ -227,6 +227,7 @@ igt_main
 	igt_fixture {
 		fd = drm_open_driver(DRIVER_INTEL);
 		igt_require_gem(fd);
+		gem_require_blitter(fd);
 	}
 
 	igt_subtest("basic")
diff --git a/tests/i915/gem_tiled_blits.c b/tests/i915/gem_tiled_blits.c
index 28861d0b4..df0699f36 100644
--- a/tests/i915/gem_tiled_blits.c
+++ b/tests/i915/gem_tiled_blits.c
@@ -203,6 +203,7 @@ igt_main
 	igt_fixture {
 		fd = drm_open_driver(DRIVER_INTEL);
 		igt_require_gem(fd);
+		gem_require_blitter(fd);
 
 		bufmgr = drm_intel_bufmgr_gem_init(fd, 4096);
 		drm_intel_bufmgr_gem_enable_reuse(bufmgr);
diff --git a/tests/i915/gem_tiled_fence_blits.c b/tests/i915/gem_tiled_fence_blits.c
index aacd42b73..ef03c73b5 100644
--- a/tests/i915/gem_tiled_fence_blits.c
+++ b/tests/i915/gem_tiled_fence_blits.c
@@ -213,6 +213,7 @@ igt_main
 	igt_fixture {
 		fd = drm_open_driver(DRIVER_INTEL);
 		igt_require_gem(fd);
+		gem_require_blitter(fd);
 	}
 
 	igt_subtest("basic")
-- 
2.23.0



More information about the Intel-gfx mailing list