@@ -945,10 +945,19 @@ bool intel_engine_is_idle(struct intel_engine_cs *engine)
return true;
/* Waiting to drain ELSP? */
- if (READ_ONCE(engine->execlists.active))
- return false;
+ if (READ_ONCE(engine->execlists.active)) {
+ /*
+ * 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.
+ */
+ execlists_tasklet(&engine->execlists);
+ 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;