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
This commit is contained in:
@@ -1349,7 +1349,7 @@ intel_ring_free(struct intel_ring *ring)
|
||||
kfree(ring);
|
||||
}
|
||||
|
||||
static void intel_ring_context_destroy(struct intel_context *ce)
|
||||
static void ring_context_destroy(struct intel_context *ce)
|
||||
{
|
||||
GEM_BUG_ON(ce->pin_count);
|
||||
|
||||
@@ -1426,7 +1426,7 @@ static void __context_unpin(struct intel_context *ce)
|
||||
i915_vma_unpin(vma);
|
||||
}
|
||||
|
||||
static void intel_ring_context_unpin(struct intel_context *ce)
|
||||
static void ring_context_unpin(struct intel_context *ce)
|
||||
{
|
||||
__context_unpin_ppgtt(ce->gem_context);
|
||||
__context_unpin(ce);
|
||||
@@ -1549,14 +1549,8 @@ err:
|
||||
return ERR_PTR(err);
|
||||
}
|
||||
|
||||
static const struct intel_context_ops ring_context_ops = {
|
||||
.unpin = intel_ring_context_unpin,
|
||||
.destroy = intel_ring_context_destroy,
|
||||
};
|
||||
|
||||
static struct intel_context *
|
||||
intel_ring_context_pin(struct intel_engine_cs *engine,
|
||||
struct i915_gem_context *ctx)
|
||||
ring_context_pin(struct intel_engine_cs *engine, struct i915_gem_context *ctx)
|
||||
{
|
||||
struct intel_context *ce = to_intel_context(ctx, engine);
|
||||
|
||||
@@ -1566,11 +1560,14 @@ intel_ring_context_pin(struct intel_engine_cs *engine,
|
||||
return ce;
|
||||
GEM_BUG_ON(!ce->pin_count); /* no overflow please! */
|
||||
|
||||
ce->ops = &ring_context_ops;
|
||||
|
||||
return __ring_context_pin(engine, ctx, ce);
|
||||
}
|
||||
|
||||
static const struct intel_context_ops ring_context_ops = {
|
||||
.unpin = ring_context_unpin,
|
||||
.destroy = ring_context_destroy,
|
||||
};
|
||||
|
||||
static int intel_init_ring_buffer(struct intel_engine_cs *engine)
|
||||
{
|
||||
struct i915_timeline *timeline;
|
||||
@@ -2276,7 +2273,8 @@ static void intel_ring_default_vfuncs(struct drm_i915_private *dev_priv,
|
||||
engine->reset.reset = reset_ring;
|
||||
engine->reset.finish = reset_finish;
|
||||
|
||||
engine->context_pin = intel_ring_context_pin;
|
||||
engine->cops = &ring_context_ops;
|
||||
engine->context_pin = ring_context_pin;
|
||||
engine->request_alloc = ring_request_alloc;
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user