Commit ca883c30 authored by Chris Wilson's avatar Chris Wilson

drm/i915/selftests: Pass intel_context to mock_request

Modernise the mock_request factory to take intel_context not a (GEM
context, intel_engine_cs) tuple.
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: default avatarMatthew Auld <matthew.auld@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190808115640.20552-1-chris@chris-wilson.co.uk
parent 32d38e6c
...@@ -46,9 +46,7 @@ static int igt_add_request(void *arg) ...@@ -46,9 +46,7 @@ static int igt_add_request(void *arg)
/* Basic preliminary test to create a request and let it loose! */ /* Basic preliminary test to create a request and let it loose! */
mutex_lock(&i915->drm.struct_mutex); mutex_lock(&i915->drm.struct_mutex);
request = mock_request(i915->engine[RCS0], request = mock_request(i915->engine[RCS0]->kernel_context, HZ / 10);
i915->kernel_context,
HZ / 10);
if (!request) if (!request)
goto out_unlock; goto out_unlock;
...@@ -70,7 +68,7 @@ static int igt_wait_request(void *arg) ...@@ -70,7 +68,7 @@ static int igt_wait_request(void *arg)
/* Submit a request, then wait upon it */ /* Submit a request, then wait upon it */
mutex_lock(&i915->drm.struct_mutex); mutex_lock(&i915->drm.struct_mutex);
request = mock_request(i915->engine[RCS0], i915->kernel_context, T); request = mock_request(i915->engine[RCS0]->kernel_context, T);
if (!request) { if (!request) {
err = -ENOMEM; err = -ENOMEM;
goto out_unlock; goto out_unlock;
...@@ -143,7 +141,7 @@ static int igt_fence_wait(void *arg) ...@@ -143,7 +141,7 @@ static int igt_fence_wait(void *arg)
/* Submit a request, treat it as a fence and wait upon it */ /* Submit a request, treat it as a fence and wait upon it */
mutex_lock(&i915->drm.struct_mutex); mutex_lock(&i915->drm.struct_mutex);
request = mock_request(i915->engine[RCS0], i915->kernel_context, T); request = mock_request(i915->engine[RCS0]->kernel_context, T);
if (!request) { if (!request) {
err = -ENOMEM; err = -ENOMEM;
goto out_locked; goto out_locked;
...@@ -196,11 +194,15 @@ static int igt_request_rewind(void *arg) ...@@ -196,11 +194,15 @@ static int igt_request_rewind(void *arg)
struct drm_i915_private *i915 = arg; struct drm_i915_private *i915 = arg;
struct i915_request *request, *vip; struct i915_request *request, *vip;
struct i915_gem_context *ctx[2]; struct i915_gem_context *ctx[2];
struct intel_context *ce;
int err = -EINVAL; int err = -EINVAL;
mutex_lock(&i915->drm.struct_mutex); mutex_lock(&i915->drm.struct_mutex);
ctx[0] = mock_context(i915, "A"); ctx[0] = mock_context(i915, "A");
request = mock_request(i915->engine[RCS0], ctx[0], 2 * HZ); ce = i915_gem_context_get_engine(ctx[0], RCS0);
GEM_BUG_ON(IS_ERR(ce));
request = mock_request(ce, 2 * HZ);
intel_context_put(ce);
if (!request) { if (!request) {
err = -ENOMEM; err = -ENOMEM;
goto err_context_0; goto err_context_0;
...@@ -210,7 +212,10 @@ static int igt_request_rewind(void *arg) ...@@ -210,7 +212,10 @@ static int igt_request_rewind(void *arg)
i915_request_add(request); i915_request_add(request);
ctx[1] = mock_context(i915, "B"); ctx[1] = mock_context(i915, "B");
vip = mock_request(i915->engine[RCS0], ctx[1], 0); ce = i915_gem_context_get_engine(ctx[1], RCS0);
GEM_BUG_ON(IS_ERR(ce));
vip = mock_request(ce, 0);
intel_context_put(ce);
if (!vip) { if (!vip) {
err = -ENOMEM; err = -ENOMEM;
goto err_context_1; goto err_context_1;
...@@ -259,22 +264,19 @@ struct smoketest { ...@@ -259,22 +264,19 @@ struct smoketest {
struct i915_gem_context **contexts; struct i915_gem_context **contexts;
atomic_long_t num_waits, num_fences; atomic_long_t num_waits, num_fences;
int ncontexts, max_batch; int ncontexts, max_batch;
struct i915_request *(*request_alloc)(struct i915_gem_context *, struct i915_request *(*request_alloc)(struct intel_context *ce);
struct intel_engine_cs *);
}; };
static struct i915_request * static struct i915_request *
__mock_request_alloc(struct i915_gem_context *ctx, __mock_request_alloc(struct intel_context *ce)
struct intel_engine_cs *engine)
{ {
return mock_request(engine, ctx, 0); return mock_request(ce, 0);
} }
static struct i915_request * static struct i915_request *
__live_request_alloc(struct i915_gem_context *ctx, __live_request_alloc(struct intel_context *ce)
struct intel_engine_cs *engine)
{ {
return igt_request_alloc(ctx, engine); return intel_context_create_request(ce);
} }
static int __igt_breadcrumbs_smoketest(void *arg) static int __igt_breadcrumbs_smoketest(void *arg)
...@@ -333,10 +335,14 @@ static int __igt_breadcrumbs_smoketest(void *arg) ...@@ -333,10 +335,14 @@ static int __igt_breadcrumbs_smoketest(void *arg)
struct i915_gem_context *ctx = struct i915_gem_context *ctx =
t->contexts[order[n] % t->ncontexts]; t->contexts[order[n] % t->ncontexts];
struct i915_request *rq; struct i915_request *rq;
struct intel_context *ce;
mutex_lock(BKL); mutex_lock(BKL);
rq = t->request_alloc(ctx, t->engine); ce = i915_gem_context_get_engine(ctx, t->engine->id);
GEM_BUG_ON(IS_ERR(ce));
rq = t->request_alloc(ce);
intel_context_put(ce);
if (IS_ERR(rq)) { if (IS_ERR(rq)) {
mutex_unlock(BKL); mutex_unlock(BKL);
err = PTR_ERR(rq); err = PTR_ERR(rq);
......
...@@ -28,14 +28,12 @@ ...@@ -28,14 +28,12 @@
#include "mock_request.h" #include "mock_request.h"
struct i915_request * struct i915_request *
mock_request(struct intel_engine_cs *engine, mock_request(struct intel_context *ce, unsigned long delay)
struct i915_gem_context *context,
unsigned long delay)
{ {
struct i915_request *request; struct i915_request *request;
/* NB the i915->requests slab cache is enlarged to fit mock_request */ /* NB the i915->requests slab cache is enlarged to fit mock_request */
request = igt_request_alloc(context, engine); request = intel_context_create_request(ce);
if (IS_ERR(request)) if (IS_ERR(request))
return NULL; return NULL;
......
...@@ -30,9 +30,7 @@ ...@@ -30,9 +30,7 @@
#include "../i915_request.h" #include "../i915_request.h"
struct i915_request * struct i915_request *
mock_request(struct intel_engine_cs *engine, mock_request(struct intel_context *ce, unsigned long delay);
struct i915_gem_context *context,
unsigned long delay);
bool mock_cancel_request(struct i915_request *request); bool mock_cancel_request(struct i915_request *request);
......
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