Commit b647c7df authored by Chris Wilson's avatar Chris Wilson
Browse files

drm/i915: Fixup preempt-to-busy vs resubmission of a virtual request

As preempt-to-busy leaves the request on the HW as the resubmission is
processed, that request may complete in the background and even cause a
second virtual request to enter queue. This second virtual request
breaks our "single request in the virtual pipeline" assumptions.
Furthermore, as the virtual request may be completed and retired, we
lose the reference the virtual engine assumes is held. Normally, just
removing the request from the scheduler queue removes it from the
engine, but the virtual engine keeps track of its singleton request via
its ve->request. This pointer needs protecting with a reference.

v2: Drop unnecessary motion of rq->engine = owner

Fixes: 22b7a426

 ("drm/i915/execlists: Preempt-to-busy")
Signed-off-by: default avatarChris Wilson <>
Cc: Mika Kuoppala <>
Cc: Tvrtko Ursulin <>
Reviewed-by: default avatarTvrtko Ursulin <>
parent 27ffe6e5
......@@ -1256,6 +1256,7 @@ static void execlists_dequeue(struct intel_engine_cs *engine)
submit = true;
last = rq;
* Hmm, we have a bunch of virtual engine requests,
......@@ -2556,6 +2557,7 @@ static void execlists_cancel_requests(struct intel_engine_cs *engine)
rq->engine = engine;
ve->base.execlists.queue_priority_hint = INT_MIN;
......@@ -3809,6 +3811,8 @@ static void virtual_submission_tasklet(unsigned long data)
static void virtual_submit_request(struct i915_request *rq)
struct virtual_engine *ve = to_virtual_engine(rq->engine);
struct i915_request *old;
unsigned long flags;
GEM_TRACE("%s: rq=%llx:%lld\n",
......@@ -3817,15 +3821,31 @@ static void virtual_submit_request(struct i915_request *rq)
GEM_BUG_ON(ve->base.submit_request != virtual_submit_request);
spin_lock_irqsave(&ve->, flags);
old = ve->request;
if (old) { /* background completion event from preempt-to-busy */
ve->base.execlists.queue_priority_hint = rq_prio(rq);
WRITE_ONCE(ve->request, rq);
if (i915_request_completed(rq)) {
list_move_tail(&rq->, virtual_queue(ve));
ve->base.execlists.queue_priority_hint = INT_MIN;
ve->request = NULL;
} else {
ve->base.execlists.queue_priority_hint = rq_prio(rq);
ve->request = i915_request_get(rq);
list_move_tail(&rq->, virtual_queue(ve));
spin_unlock_irqrestore(&ve->, flags);
static struct ve_bond *
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment