summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/i915/selftests/mock_engine.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2019-03-08 16:25:18 +0300
committerChris Wilson <chris@chris-wilson.co.uk>2019-03-08 16:59:50 +0300
commit4dc84b77b07731b7f5de2ce14b5f0526a86f013d (patch)
treedab57196ae00549822468476afab8c77cc68e252 /drivers/gpu/drm/i915/selftests/mock_engine.c
parent39e2f501c1b431bd9291308e1ef02b9a02fffbee (diff)
downloadlinux-4dc84b77b07731b7f5de2ce14b5f0526a86f013d.tar.xz
drm/i915: Store the intel_context_ops in the intel_engine_cs
If we place a pointer to the engine specific intel_context_ops in the engine itself, we can assign the ops pointer on initialising the context, and then rely on it being set. This simplifies the code in later patches. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20190308132522.21573-3-chris@chris-wilson.co.uk
Diffstat (limited to 'drivers/gpu/drm/i915/selftests/mock_engine.c')
-rw-r--r--drivers/gpu/drm/i915/selftests/mock_engine.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/drivers/gpu/drm/i915/selftests/mock_engine.c b/drivers/gpu/drm/i915/selftests/mock_engine.c
index 8032a8a9542f..856ec2706f3e 100644
--- a/drivers/gpu/drm/i915/selftests/mock_engine.c
+++ b/drivers/gpu/drm/i915/selftests/mock_engine.c
@@ -137,11 +137,6 @@ static void mock_context_destroy(struct intel_context *ce)
mock_ring_free(ce->ring);
}
-static const struct intel_context_ops mock_context_ops = {
- .unpin = mock_context_unpin,
- .destroy = mock_context_destroy,
-};
-
static struct intel_context *
mock_context_pin(struct intel_engine_cs *engine,
struct i915_gem_context *ctx)
@@ -160,8 +155,6 @@ mock_context_pin(struct intel_engine_cs *engine,
mock_timeline_pin(ce->ring->timeline);
- ce->ops = &mock_context_ops;
-
mutex_lock(&ctx->mutex);
list_add(&ce->active_link, &ctx->active_engines);
mutex_unlock(&ctx->mutex);
@@ -174,6 +167,11 @@ err:
return ERR_PTR(err);
}
+static const struct intel_context_ops mock_context_ops = {
+ .unpin = mock_context_unpin,
+ .destroy = mock_context_destroy,
+};
+
static int mock_request_alloc(struct i915_request *request)
{
INIT_LIST_HEAD(&request->mock.link);
@@ -232,6 +230,7 @@ struct intel_engine_cs *mock_engine(struct drm_i915_private *i915,
engine->base.mask = BIT(id);
engine->base.status_page.addr = (void *)(engine + 1);
+ engine->base.cops = &mock_context_ops;
engine->base.context_pin = mock_context_pin;
engine->base.request_alloc = mock_request_alloc;
engine->base.emit_flush = mock_emit_flush;