diff mbox series

[2/2] drm/i915: Protect request peeking with RCU

Message ID 20191104090158.2959-2-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show
Series [1/2] drm/i915/gt: Drop false assertion on user_forcewake | expand

Commit Message

Chris Wilson Nov. 4, 2019, 9:01 a.m. UTC
Since the execlists_active() is no longer protected by the
engine->active.lock, we need to protect the request pointer with RCU to
prevent it being freed as we evaluate whether or not we need to preempt.

Fixes: df403069029d ("drm/i915/execlists: Lift process_csb() out of the irq-off spinlock")
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
 drivers/gpu/drm/i915/i915_scheduler.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Comments

Mika Kuoppala Nov. 4, 2019, 9:59 a.m. UTC | #1
Chris Wilson <chris@chris-wilson.co.uk> writes:

> Since the execlists_active() is no longer protected by the
> engine->active.lock, we need to protect the request pointer with RCU to
> prevent it being freed as we evaluate whether or not we need to preempt.
>
> Fixes: df403069029d ("drm/i915/execlists: Lift process_csb() out of the irq-off spinlock")
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Reviewed-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>

> ---
>  drivers/gpu/drm/i915/i915_scheduler.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_scheduler.c b/drivers/gpu/drm/i915/i915_scheduler.c
> index d2edb527dcb8..010d67f48ad9 100644
> --- a/drivers/gpu/drm/i915/i915_scheduler.c
> +++ b/drivers/gpu/drm/i915/i915_scheduler.c
> @@ -202,21 +202,26 @@ static void kick_submission(struct intel_engine_cs *engine,
>  	if (prio <= engine->execlists.queue_priority_hint)
>  		return;
>  
> +	rcu_read_lock();
> +
>  	/* Nothing currently active? We're overdue for a submission! */
>  	inflight = execlists_active(&engine->execlists);
>  	if (!inflight)
> -		return;
> +		goto unlock;
>  
>  	/*
>  	 * If we are already the currently executing context, don't
>  	 * bother evaluating if we should preempt ourselves.
>  	 */
>  	if (inflight->hw_context == rq->hw_context)
> -		return;
> +		goto unlock;
>  
>  	engine->execlists.queue_priority_hint = prio;
>  	if (need_preempt(prio, rq_prio(inflight)))
>  		tasklet_hi_schedule(&engine->execlists.tasklet);
> +
> +unlock:
> +	rcu_read_unlock();
>  }
>  
>  static void __i915_schedule(struct i915_sched_node *node,
> -- 
> 2.24.0.rc2
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/i915_scheduler.c b/drivers/gpu/drm/i915/i915_scheduler.c
index d2edb527dcb8..010d67f48ad9 100644
--- a/drivers/gpu/drm/i915/i915_scheduler.c
+++ b/drivers/gpu/drm/i915/i915_scheduler.c
@@ -202,21 +202,26 @@  static void kick_submission(struct intel_engine_cs *engine,
 	if (prio <= engine->execlists.queue_priority_hint)
 		return;
 
+	rcu_read_lock();
+
 	/* Nothing currently active? We're overdue for a submission! */
 	inflight = execlists_active(&engine->execlists);
 	if (!inflight)
-		return;
+		goto unlock;
 
 	/*
 	 * If we are already the currently executing context, don't
 	 * bother evaluating if we should preempt ourselves.
 	 */
 	if (inflight->hw_context == rq->hw_context)
-		return;
+		goto unlock;
 
 	engine->execlists.queue_priority_hint = prio;
 	if (need_preempt(prio, rq_prio(inflight)))
 		tasklet_hi_schedule(&engine->execlists.tasklet);
+
+unlock:
+	rcu_read_unlock();
 }
 
 static void __i915_schedule(struct i915_sched_node *node,