Reviewed-by: Jason Ekstrand <jason@xxxxxxxxxxxxxx> On Thu, Jun 3, 2021 at 4:09 PM Matthew Brost <matthew.brost@xxxxxxxxx> wrote: > > Add wrapper function around RB tree to determine if i915_sched_engine is > empty. > > Signed-off-by: Matthew Brost <matthew.brost@xxxxxxxxx> > --- > drivers/gpu/drm/i915/gt/intel_engine_cs.c | 2 +- > drivers/gpu/drm/i915/gt/intel_execlists_submission.c | 6 +++--- > drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c | 2 +- > drivers/gpu/drm/i915/i915_scheduler.h | 6 ++++++ > 4 files changed, 11 insertions(+), 5 deletions(-) > > diff --git a/drivers/gpu/drm/i915/gt/intel_engine_cs.c b/drivers/gpu/drm/i915/gt/intel_engine_cs.c > index d0f3814440f6..85f2effe9dc6 100644 > --- a/drivers/gpu/drm/i915/gt/intel_engine_cs.c > +++ b/drivers/gpu/drm/i915/gt/intel_engine_cs.c > @@ -1287,7 +1287,7 @@ bool intel_engine_is_idle(struct intel_engine_cs *engine) > intel_engine_flush_submission(engine); > > /* ELSP is empty, but there are ready requests? E.g. after reset */ > - if (!RB_EMPTY_ROOT(&engine->sched_engine->queue.rb_root)) > + if (!i915_sched_engine_is_empty(engine->sched_engine)) > return false; > > /* Ring stopped? */ > diff --git a/drivers/gpu/drm/i915/gt/intel_execlists_submission.c b/drivers/gpu/drm/i915/gt/intel_execlists_submission.c > index d1dc1db3e378..2326a73af6d3 100644 > --- a/drivers/gpu/drm/i915/gt/intel_execlists_submission.c > +++ b/drivers/gpu/drm/i915/gt/intel_execlists_submission.c > @@ -384,7 +384,7 @@ __unwind_incomplete_requests(struct intel_engine_cs *engine) > prio = rq_prio(rq); > pl = i915_sched_lookup_priolist(engine, prio); > } > - GEM_BUG_ON(RB_EMPTY_ROOT(&engine->sched_engine->queue.rb_root)); > + GEM_BUG_ON(i915_sched_engine_is_empty(engine->sched_engine)); > > list_move(&rq->sched.link, pl); > set_bit(I915_FENCE_FLAG_PQUEUE, &rq->fence.flags); > @@ -1139,7 +1139,7 @@ static bool needs_timeslice(const struct intel_engine_cs *engine, > } > > /* Otherwise, ELSP[0] is by itself, but may be waiting in the queue */ > - if (!RB_EMPTY_ROOT(&engine->sched_engine->queue.rb_root)) { > + if (!i915_sched_engine_is_empty(engine->sched_engine)) { > ENGINE_TRACE(engine, "timeslice required for queue\n"); > return true; > } > @@ -2487,7 +2487,7 @@ static void execlists_submit_request(struct i915_request *request) > } else { > queue_request(engine, request); > > - GEM_BUG_ON(RB_EMPTY_ROOT(&engine->sched_engine->queue.rb_root)); > + GEM_BUG_ON(i915_sched_engine_is_empty(engine->sched_engine)); > GEM_BUG_ON(list_empty(&request->sched.link)); > > if (submit_queue(engine, request)) > diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c > index d42dea79ee64..5d00f2e3c1de 100644 > --- a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c > +++ b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c > @@ -541,7 +541,7 @@ static void guc_submit_request(struct i915_request *rq) > > queue_request(engine, rq, rq_prio(rq)); > > - GEM_BUG_ON(RB_EMPTY_ROOT(&engine->sched_engine->queue.rb_root)); > + GEM_BUG_ON(i915_sched_engine_is_empty(engine->sched_engine)); > GEM_BUG_ON(list_empty(&rq->sched.link)); > > tasklet_hi_schedule(&engine->execlists.tasklet); > diff --git a/drivers/gpu/drm/i915/i915_scheduler.h b/drivers/gpu/drm/i915/i915_scheduler.h > index 91a04e34cac5..5bec7b3b8456 100644 > --- a/drivers/gpu/drm/i915/i915_scheduler.h > +++ b/drivers/gpu/drm/i915/i915_scheduler.h > @@ -66,6 +66,12 @@ i915_sched_engine_put(struct i915_sched_engine *sched_engine) > kref_put(&sched_engine->ref, i915_sched_engine_free); > } > > +static inline bool > +i915_sched_engine_is_empty(struct i915_sched_engine *sched_engine) > +{ > + return RB_EMPTY_ROOT(&sched_engine->queue.rb_root); > +} > + > void i915_request_show_with_schedule(struct drm_printer *m, > const struct i915_request *rq, > const char *prefix, > -- > 2.28.0 > > _______________________________________________ > Intel-gfx mailing list > Intel-gfx@xxxxxxxxxxxxxxxxxxxxx > https://lists.freedesktop.org/mailman/listinfo/intel-gfx