[PATCH 02/14] drm/i915: Stop listening to request resubmission from the signaler kthread

Chris Wilson chris at chris-wilson.co.uk
Sat Dec 9 00:37:06 UTC 2017

The intent here was that we would be listening to
i915_gem_request_unsubmit in order to cancel the signaler quickly and
release the reference on the request. Cancelling the signaler is done
directly via intel_engine_cancel_signaling (called from unsubmit), but
that does not directly wake up the signaling thread, and neither does
setting the request->global_seqno back to zero wake up listeners to the
request->execute waitqueue. So the only time that listening to the
request->execute waitqueue would wake up the signaling kthread would be
on the request resubmission, during which time we would already receive
wake ups from rejoining the global breadcrumbs wait rbtree.

Trying to wake up to release the request remains an issue. If the
signaling was cancelled and no other request required signaling, then it
is possible for us to shutdown with the reference on the request still
held. To ensure that we do not try to shutdown, leaking that request, we
kick the signaling threads whenever we disarm the breadcrumbs, i.e. on
parking the engine when idle.

Fixes: d6a2289d9d6b ("drm/i915: Remove the preempted request from the execution queue")
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin at linux.intel.com>
Cc: MichaƂ Winiarski <michal.winiarski at intel.com>
 drivers/gpu/drm/i915/intel_breadcrumbs.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_breadcrumbs.c b/drivers/gpu/drm/i915/intel_breadcrumbs.c
index 24c6fefdd0b1..29fb828770a1 100644
--- a/drivers/gpu/drm/i915/intel_breadcrumbs.c
+++ b/drivers/gpu/drm/i915/intel_breadcrumbs.c
@@ -217,7 +217,7 @@ void intel_engine_disarm_breadcrumbs(struct intel_engine_cs *engine)
 	struct intel_wait *wait, *n;
 	if (!b->irq_armed)
-		return;
+		goto wakeup_signaler;
 	 * We only disarm the irq when we are idle (all requests completed),
@@ -242,6 +242,14 @@ void intel_engine_disarm_breadcrumbs(struct intel_engine_cs *engine)
 	b->waiters = RB_ROOT;
+	/*
+	 * The signaling thread may be asleep holding a reference to a request,
+	 * that had its signaling cancelled prior to being preempted. We need
+	 * to kick the signaler, just in case, to release any such reference.
+	 */
+	wake_up_process(b->signaler);
 static bool use_fake_irq(const struct intel_breadcrumbs *b)
@@ -686,8 +694,6 @@ static int intel_breadcrumbs_signaler(void *arg)
 		if (unlikely(do_schedule)) {
-			DEFINE_WAIT(exec);
 			if (kthread_should_park())
@@ -696,13 +702,7 @@ static int intel_breadcrumbs_signaler(void *arg)
-			if (request)
-				add_wait_queue(&request->execute, &exec);
-			if (request)
-				remove_wait_queue(&request->execute, &exec);
 	} while (1);

More information about the Intel-gfx-trybot mailing list