diff mbox series

drm/i915: Keep engine alive as we retire the context

Message ID 20190617084044.1894-1-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show
Series drm/i915: Keep engine alive as we retire the context | expand

Commit Message

Chris Wilson June 17, 2019, 8:40 a.m. UTC
Though we pin the context first before taking the pm wakeref, during
retire we need to unpin before dropping the pm wakeref (breaking the
"natural" onion). During the unpin, we may need to attach a cleanup
operation on to the engine wakeref, ergo we want to keep the engine
awake until after the unpin.

Fixes: ce476c80b8bf ("drm/i915: Keep contexts pinned until after the next kernel context switch")
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
---
 drivers/gpu/drm/i915/i915_request.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Chris Wilson June 17, 2019, 9:08 a.m. UTC | #1
Quoting Chris Wilson (2019-06-17 09:40:44)
> Though we pin the context first before taking the pm wakeref, during
> retire we need to unpin before dropping the pm wakeref (breaking the
> "natural" onion). During the unpin, we may need to attach a cleanup
> operation on to the engine wakeref, ergo we want to keep the engine
> awake until after the unpin.
> 
> Fixes: ce476c80b8bf ("drm/i915: Keep contexts pinned until after the next kernel context switch")
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
> ---
>  drivers/gpu/drm/i915/i915_request.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_request.c b/drivers/gpu/drm/i915/i915_request.c
> index 9819483d1b5d..8d952bc03d5c 100644
> --- a/drivers/gpu/drm/i915/i915_request.c
> +++ b/drivers/gpu/drm/i915/i915_request.c
> @@ -250,8 +250,9 @@ static bool i915_request_retire(struct i915_request *rq)
>  
>         local_irq_enable();
>  
> -       intel_context_exit(rq->hw_context);
> +       /* Onion reversed to keep engine alive until after unpinning */
>         intel_context_unpin(rq->hw_context);
> +       intel_context_exit(rq->hw_context);

The alternative is to keep the onion unwind here and to add the engine
wakerefs into the barriers. Hmm.

That seems like it should be more foolproof, perhaps?
-Chris
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/i915_request.c b/drivers/gpu/drm/i915/i915_request.c
index 9819483d1b5d..8d952bc03d5c 100644
--- a/drivers/gpu/drm/i915/i915_request.c
+++ b/drivers/gpu/drm/i915/i915_request.c
@@ -250,8 +250,9 @@  static bool i915_request_retire(struct i915_request *rq)
 
 	local_irq_enable();
 
-	intel_context_exit(rq->hw_context);
+	/* Onion reversed to keep engine alive until after unpinning */
 	intel_context_unpin(rq->hw_context);
+	intel_context_exit(rq->hw_context);
 
 	i915_request_remove_from_client(rq);
 	list_del(&rq->link);