On Thu, 2017-11-02 at 12:42 +0000, Chris Wilson wrote: > 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@xxxxxxxxxxxxxxxxxx> <SNIP> > @@ -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; *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; It might be worthy dropping a comment that a nonexistent context is considered kernel context to the *cough*nonexistent*cough* kerneldoc. Reviewed-by: Joonas Lahtinen <joonas.lahtinen@xxxxxxxxxxxxxxx> Regards, Joonas -- Joonas Lahtinen Open Source Technology Center Intel Corporation _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/intel-gfx