[Intel-gfx] [PATCH 1/6] drm/i915: Force the switch to the i915->kernel_context
Mika Kuoppala
mika.kuoppala at linux.intel.com
Thu Nov 2 15:40:50 UTC 2017
Chris Wilson <chris at chris-wilson.co.uk> writes:
> In the next few patches, we will have a hard requirement that we emit a
> context-switch to the perma-pinned i915->kernel_context (so that we can
> save the HW state using that context-switch). As the first context
> itself may be classed as a kernel context, we want to be explicit in our
> comparison. For an extra-layer of finesse, we can check the last
> unretired context on the engine; as well as the last retired context
> when idle.
>
> Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
> ---
> drivers/gpu/drm/i915/intel_engine_cs.c | 16 ++++++++++++++--
> 1 file changed, 14 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/intel_engine_cs.c b/drivers/gpu/drm/i915/intel_engine_cs.c
> index ddbe5c9bf45a..c15e288bed02 100644
> --- a/drivers/gpu/drm/i915/intel_engine_cs.c
> +++ b/drivers/gpu/drm/i915/intel_engine_cs.c
> @@ -1587,8 +1587,20 @@ bool intel_engines_are_idle(struct drm_i915_private *dev_priv)
>
> bool intel_engine_has_kernel_context(const struct intel_engine_cs *engine)
> {
> - return (!engine->last_retired_context ||
> - i915_gem_context_is_kernel(engine->last_retired_context));
> + const struct i915_gem_context *kctx = engine->i915->kernel_context;
> + struct drm_i915_gem_request *rq;
> +
> + lockdep_assert_held(&engine->i915->drm.struct_mutex);
> +
> + /* An unretired request? */
> + rq = __i915_gem_active_peek(&engine->timeline->last_request);
> + if (rq)
> + return rq->ctx == kctx;
> +
> + if (!engine->last_retired_context)
> + return true;
> +
> + return engine->last_retired_context == kctx;
Conside that we would have intel_engine_loaded_context(engine)
{
rq = __i915_gem_active_peek(&engine->timeline->last_request);
if (rq)
return rq->ctx;
if (engine->last_retired_context)
return engine->last_retired_context;
return NULL;
}
and then have simple intel_engine_has_kernel_context_loaded()
Also further on the patch series we do switch to kernel context
on init, to grab the hw state. So would it be possible to completely
get rid of notion that !engine->last_retired_context means kernel
context? I would rather assert that we have always last retired
context after init and resume.
-Mika
> }
>
> void intel_engines_reset_default_submission(struct drm_i915_private *i915)
> --
> 2.15.0
More information about the Intel-gfx
mailing list