[Intel-gfx] [PATCH igt] lib: Provide a library function to test nop execution
Chris Wilson
chris at chris-wilson.co.uk
Thu Dec 14 22:24:56 UTC 2017
Sometimes a test wants to verify that an engine, or all of them, are
functional by executing a nop batch. Provide a common routine to submit
an empty batch then test whether the driver is wedged.
Reported-by: Antonio Argenziano <antonio.argenziano at intel.com>
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
Cc: Antonio Argenziano <antonio.argenziano at intel.com>
---
lib/i915/gem_submission.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++
lib/i915/gem_submission.h | 2 ++
tests/gem_eio.c | 2 +-
tests/pm_rpm.c | 2 +-
4 files changed, 53 insertions(+), 2 deletions(-)
diff --git a/lib/i915/gem_submission.c b/lib/i915/gem_submission.c
index 1414c7138..e27ea9ec3 100644
--- a/lib/i915/gem_submission.c
+++ b/lib/i915/gem_submission.c
@@ -21,14 +21,18 @@
* IN THE SOFTWARE.
*/
+#include <errno.h>
#include <stdbool.h>
#include <sys/ioctl.h>
#include <i915_drm.h>
#include "igt_core.h"
+#include "igt_gt.h"
#include "igt_sysfs.h"
#include "intel_chipset.h"
+#include "intel_reg.h"
+#include "ioctl_wrappers.h"
#include "i915/gem_submission.h"
@@ -159,3 +163,48 @@ bool gem_has_guc_submission(int fd)
{
return gem_submission_method(fd) & GEM_SUBMISSION_GUC;
}
+
+static bool is_wedged(int i915)
+{
+ int err = 0;
+ if (ioctl(i915, DRM_IOCTL_I915_GEM_THROTTLE))
+ err = -errno;
+ return err == -EIO;
+}
+
+/**
+ * gem_test_engine:
+ * @i915: open i915 drm file descriptor
+ * @engine: the engine (I915_EXEC_RING id) to exercise
+ *
+ * Execute a nop batch on the specified, or -1 for all, and check it
+ * executes.
+ */
+void gem_test_engine(int i915, unsigned int engine)
+{
+ const uint32_t bbe = MI_BATCH_BUFFER_END;
+ struct drm_i915_gem_exec_object2 obj = {
+ .handle = gem_create(i915, 4096)
+ };
+ struct drm_i915_gem_execbuffer2 execbuf = {
+ .buffers_ptr = to_user_pointer(&obj),
+ .buffer_count = 1,
+ };
+
+ igt_assert(!is_wedged(i915));
+ gem_write(i915, obj.handle, 0, &bbe, sizeof(bbe));
+
+ if (engine == -1u) {
+ for_each_engine(i915, engine) {
+ execbuf.flags = engine;
+ gem_execbuf(i915, &execbuf);
+ }
+ } else {
+ execbuf.flags = engine;
+ gem_execbuf(i915, &execbuf);
+ }
+ gem_sync(i915, obj.handle);
+ gem_close(i915, obj.handle);
+
+ igt_assert(!is_wedged(i915));
+}
diff --git a/lib/i915/gem_submission.h b/lib/i915/gem_submission.h
index 4f588aec7..6b39a0532 100644
--- a/lib/i915/gem_submission.h
+++ b/lib/i915/gem_submission.h
@@ -33,4 +33,6 @@ bool gem_has_semaphores(int fd);
bool gem_has_execlists(int fd);
bool gem_has_guc_submission(int fd);
+void gem_test_engine(int fd, unsigned int engine);
+
#endif /* GEM_SUBMISSION_H */
diff --git a/tests/gem_eio.c b/tests/gem_eio.c
index 2ac9f0a96..6d5a10f26 100644
--- a/tests/gem_eio.c
+++ b/tests/gem_eio.c
@@ -66,7 +66,7 @@ static void trigger_reset(int fd)
/* And just check the gpu is indeed running again */
igt_debug("Checking that the GPU recovered\n");
- gem_quiescent_gpu(fd);
+ gem_test_engine(fd, -1);
}
static void wedge_gpu(int fd)
diff --git a/tests/pm_rpm.c b/tests/pm_rpm.c
index fb26e384e..d2a6705e1 100644
--- a/tests/pm_rpm.c
+++ b/tests/pm_rpm.c
@@ -1277,7 +1277,7 @@ static void gem_idle_subtest(void)
sleep(5);
- gem_quiescent_gpu(drm_fd);
+ gem_test_engine(drm_fd, -1);
}
static void gem_evict_pwrite_subtest(void)
--
2.15.1
More information about the Intel-gfx
mailing list