[PATCH 12/57] drm/i915: Move context revocation to scheduler

Chris Wilson chris at chris-wilson.co.uk
Fri Feb 5 16:40:48 UTC 2021


Quoting Tvrtko Ursulin (2021-02-05 16:36:16)
> 
> On 05/02/2021 01:18, Chris Wilson wrote:
> > -static struct intel_engine_cs *active_engine(struct intel_context *ce)
> > -{
> > -     struct intel_engine_cs *engine = NULL;
> > -     struct i915_request *rq;
> > -
> > -     if (intel_context_has_inflight(ce))
> > -             return intel_context_inflight(ce);
> > -
> > -     if (!ce->timeline)
> > -             return NULL;
> > -
> > -     /*
> > -      * rq->link is only SLAB_TYPESAFE_BY_RCU, we need to hold a reference
> > -      * to the request to prevent it being transferred to a new timeline
> > -      * (and onto a new timeline->requests list).
> > -      */
> > -     rcu_read_lock();
> > -     list_for_each_entry_reverse(rq, &ce->timeline->requests, link) {
> > -             bool found;
> > -
> > -             /* timeline is already completed upto this point? */
> > -             if (!i915_request_get_rcu(rq))
> > -                     break;
> > -
> > -             /* Check with the backend if the request is inflight */
> > -             found = true;
> > -             if (likely(rcu_access_pointer(rq->timeline) == ce->timeline))
> > -                     found = __active_engine(rq, &engine);
> > -
> > -             i915_request_put(rq);
> > -             if (found)
> > -                     break;
> > -     }
> > -     rcu_read_unlock();
> 
> Moves and removes the above chunk of code. Now I assume 
> intel_context_inflight should be good enough, but obviously existing 
> code does not trust it. I can't figure it out. Do you remember why?

Because not everything was execlists, so originally we wrote it
generically. Then added the shortcuts on top, with the final edit being
that execlists sets a magic flag so it always takes:

if (intel_context_has_inflight(ce))
	return intel_context_inflight(ce);

-Chris


More information about the Intel-gfx-trybot mailing list