drm/i915/gt: Prevent timeslicing into unpreemptible requests
diff mbox series

Message ID 20200527130214.1239-1-chris@chris-wilson.co.uk
State New
Headers show
Series
  • drm/i915/gt: Prevent timeslicing into unpreemptible requests
Related show

Commit Message

Chris Wilson May 27, 2020, 1:02 p.m. UTC
We have a I915_REQUEST_NOPREEMPT flag that we set when we must prevent
the HW from preempting during the course of this request. We need to
honour this flag and protect the HW even if we have a heartbeat request,
or other maximum priority barrier, pending. As such, restrict the
timeslicing check to avoid preempting into the topmost priority band,
leaving the unpreemptable requests in blissful peace running
uninterrupted on the HW.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
 drivers/gpu/drm/i915/gt/intel_lrc.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

Chris Wilson May 27, 2020, 1:05 p.m. UTC | #1
Quoting Chris Wilson (2020-05-27 14:02:14)
> We have a I915_REQUEST_NOPREEMPT flag that we set when we must prevent
> the HW from preempting during the course of this request. We need to
> honour this flag and protect the HW even if we have a heartbeat request,
> or other maximum priority barrier, pending. As such, restrict the
> timeslicing check to avoid preempting into the topmost priority band,
> leaving the unpreemptable requests in blissful peace running
> uninterrupted on the HW.
> 

Fixes: 2a98f4e65bba ("drm/i915: add infrastructure to hold off preemption on a request")
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
-Chris

Patch
diff mbox series

diff --git a/drivers/gpu/drm/i915/gt/intel_lrc.c b/drivers/gpu/drm/i915/gt/intel_lrc.c
index a8fdd4f9eb5a..cf63613c2a60 100644
--- a/drivers/gpu/drm/i915/gt/intel_lrc.c
+++ b/drivers/gpu/drm/i915/gt/intel_lrc.c
@@ -1896,6 +1896,15 @@  static void defer_active(struct intel_engine_cs *engine)
 	defer_request(rq, i915_sched_lookup_priolist(engine, rq_prio(rq)));
 }
 
+static inline int never_timeslice(int prio)
+{
+	/* Don't allow timeslicing of the 'unpreemptible' requests */
+	if (prio == I915_PRIORITY_UNPREEMPTABLE)
+		prio--;
+
+	return prio;
+}
+
 static bool
 need_timeslice(const struct intel_engine_cs *engine,
 	       const struct i915_request *rq,
@@ -1927,6 +1936,7 @@  need_timeslice(const struct intel_engine_cs *engine,
 
 	if (!list_is_last(&rq->sched.link, &engine->active.requests))
 		hint = max(hint, rq_prio(list_next_entry(rq, sched.link)));
+	hint = never_timeslice(hint);
 
 	return hint >= effective_prio(rq);
 }
@@ -2007,6 +2017,7 @@  static void start_timeslice(struct intel_engine_cs *engine, int prio)
 	if (!intel_engine_has_timeslices(engine))
 		return;
 
+	prio = never_timeslice(prio);
 	WRITE_ONCE(execlists->switch_priority_hint, prio);
 	if (prio == INT_MIN)
 		return;