Commit 737f5989 authored by Chris Wilson's avatar Chris Wilson

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's avatarAntonio Argenziano <antonio.argenziano@intel.com>
Signed-off-by: Chris Wilson's avatarChris Wilson <chris@chris-wilson.co.uk>
Cc: Antonio Argenziano <antonio.argenziano@intel.com>
Reviewed-by: Antonio Argenziano's avatarAntonio Argenziano <antonio.argenziano@intel.com>
parent 103af728
...@@ -21,14 +21,18 @@ ...@@ -21,14 +21,18 @@
* IN THE SOFTWARE. * IN THE SOFTWARE.
*/ */
#include <errno.h>
#include <stdbool.h> #include <stdbool.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <i915_drm.h> #include <i915_drm.h>
#include "igt_core.h" #include "igt_core.h"
#include "igt_gt.h"
#include "igt_sysfs.h" #include "igt_sysfs.h"
#include "intel_chipset.h" #include "intel_chipset.h"
#include "intel_reg.h"
#include "ioctl_wrappers.h"
#include "i915/gem_submission.h" #include "i915/gem_submission.h"
...@@ -159,3 +163,48 @@ bool gem_has_guc_submission(int fd) ...@@ -159,3 +163,48 @@ bool gem_has_guc_submission(int fd)
{ {
return gem_submission_method(fd) & GEM_SUBMISSION_GUC; 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));
}
...@@ -33,4 +33,6 @@ bool gem_has_semaphores(int fd); ...@@ -33,4 +33,6 @@ bool gem_has_semaphores(int fd);
bool gem_has_execlists(int fd); bool gem_has_execlists(int fd);
bool gem_has_guc_submission(int fd); bool gem_has_guc_submission(int fd);
void gem_test_engine(int fd, unsigned int engine);
#endif /* GEM_SUBMISSION_H */ #endif /* GEM_SUBMISSION_H */
...@@ -66,7 +66,7 @@ static void trigger_reset(int fd) ...@@ -66,7 +66,7 @@ static void trigger_reset(int fd)
/* And just check the gpu is indeed running again */ /* And just check the gpu is indeed running again */
igt_debug("Checking that the GPU recovered\n"); igt_debug("Checking that the GPU recovered\n");
gem_quiescent_gpu(fd); gem_test_engine(fd, -1);
} }
static void wedge_gpu(int fd) static void wedge_gpu(int fd)
......
...@@ -1277,7 +1277,7 @@ static void gem_idle_subtest(void) ...@@ -1277,7 +1277,7 @@ static void gem_idle_subtest(void)
sleep(5); sleep(5);
gem_quiescent_gpu(drm_fd); gem_test_engine(drm_fd, -1);
} }
static void gem_evict_pwrite_subtest(void) static void gem_evict_pwrite_subtest(void)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment