diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2017-12-14 22:17:26 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2017-12-15 09:36:26 +0000 |
commit | 737f59897d0ec2b8b47a77ba4100ec3790f3704e (patch) | |
tree | 5f45d5bdff064c28a4a70cb4c452e05aad989d24 /lib/i915 | |
parent | 103af7286e2d1014e3d7126691fe046ab2c9f73e (diff) |
lib: Provide a library function to test nop execution
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@intel.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Antonio Argenziano <antonio.argenziano@intel.com>
Reviewed-by: Antonio Argenziano <antonio.argenziano@intel.com>
Diffstat (limited to 'lib/i915')
-rw-r--r-- | lib/i915/gem_submission.c | 49 | ||||
-rw-r--r-- | lib/i915/gem_submission.h | 2 |
2 files changed, 51 insertions, 0 deletions
diff --git a/lib/i915/gem_submission.c b/lib/i915/gem_submission.c index 1414c713..e27ea9ec 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 4f588aec..6b39a053 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 */ |