@@ -933,11 +933,20 @@ bool intel_engine_is_idle(struct intel_engine_cs *engine)
if (I915_SELFTEST_ONLY(engine->breadcrumbs.mock))
return true;
+ /*
+ * ksoftirqd has notorious latency that may cause us to
+ * timeout while waiting for the engine to idle as we wait for
+ * ksoftirqd to run the execlists tasklet to drain the ELSP.
+ * If we are expecting a context switch from the GPU, check now.
+ */
+ if (test_bit(ENGINE_IRQ_EXECLIST, &engine->irq_posted))
+ i915_tasklet_try(&engine->execlists.tasklet);
+
/* Waiting to drain ELSP? */
if (READ_ONCE(engine->execlists.active))
return false;
- /* ELSP is empty, but there are ready requests? */
+ /* ELSP is empty, but there are ready requests? E.g. after reset */
if (READ_ONCE(engine->execlists.first))
return false;