[Intel-gfx] [PATCH 14/16] drm/i915: Add a simple request selftest for waiting
Chris Wilson
chris at chris-wilson.co.uk
Wed Dec 7 13:58:31 UTC 2016
A trivial kselftest to submit a request and wait upon it.
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
drivers/gpu/drm/i915/i915_gem_request.c | 48 +++++++++++++++++++++++++++++++++
1 file changed, 48 insertions(+)
diff --git a/drivers/gpu/drm/i915/i915_gem_request.c b/drivers/gpu/drm/i915/i915_gem_request.c
index 6553457adc77..9ba17d3e35cb 100644
--- a/drivers/gpu/drm/i915/i915_gem_request.c
+++ b/drivers/gpu/drm/i915/i915_gem_request.c
@@ -1601,10 +1601,58 @@ static int igt_add_request(void *ignore)
return err;
}
+static int igt_wait_request(void *ignore)
+{
+ struct drm_i915_private *i915;
+ struct drm_i915_gem_request *request;
+ int err = -ENOMEM;
+
+ i915 = mock_device();
+ if (!i915)
+ goto out;
+
+ mutex_lock(&i915->drm.struct_mutex);
+ request = mock_request(i915->engine[RCS],
+ i915->kernel_context,
+ HZ / 2);
+ if (!request)
+ goto out_unlock;
+
+ i915_add_request(request);
+
+ if (i915_gem_request_completed(request)) {
+ pr_err("request completed immediately!\n");
+ goto out_unlock;
+ }
+
+ if (i915_wait_request(request, I915_WAIT_LOCKED, HZ / 4) != -ETIME) {
+ pr_err("request wait succeeded (expected tiemout!)\n");
+ goto out_unlock;
+ }
+
+ if (i915_wait_request(request, I915_WAIT_LOCKED, HZ / 2) == -ETIME) {
+ pr_err("request wait timed out!\n");
+ goto out_unlock;
+ }
+
+ if (!i915_gem_request_completed(request)) {
+ pr_err("request not complete after waiting!\n");
+ goto out_unlock;
+ }
+
+ err = 0;
+out_unlock:
+ mutex_unlock(&i915->drm.struct_mutex);
+ mock_device_free(i915);
+out:
+ return err;
+}
+
int i915_gem_request_selftest(void)
{
static const struct i915_subtest tests[] = {
SUBTEST(igt_add_request),
+ SUBTEST(igt_wait_request),
};
return i915_subtests(tests, NULL);
--
2.11.0
More information about the Intel-gfx
mailing list