diff mbox

[09/31] drm/i915: Wait for engines to idle before retiring

Message ID 20180625094842.8499-9-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show

Commit Message

Chris Wilson June 25, 2018, 9:48 a.m. UTC
In the next patch, we will start to defer retiring the request from the
engine list if it is still active on the submission backend. To preserve
the semantics that after wait-for-idle completes the system is idle and
fully retired, we need to therefore wait for the backends to idle before
calling i915_retire_requests().

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/i915_gem.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

Comments

Tvrtko Ursulin June 27, 2018, 11:32 a.m. UTC | #1
On 25/06/2018 10:48, Chris Wilson wrote:
> In the next patch, we will start to defer retiring the request from the
> engine list if it is still active on the submission backend. To preserve
> the semantics that after wait-for-idle completes the system is idle and
> fully retired, we need to therefore wait for the backends to idle before
> calling i915_retire_requests().
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> ---
>   drivers/gpu/drm/i915/i915_gem.c | 11 +++++++----
>   1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> index 858d188dd33b..5a9cae604e2b 100644
> --- a/drivers/gpu/drm/i915/i915_gem.c
> +++ b/drivers/gpu/drm/i915/i915_gem.c
> @@ -3810,10 +3810,13 @@ int i915_gem_wait_for_idle(struct drm_i915_private *i915, unsigned int flags)
>   			if (err)
>   				return err;
>   		}
> +
> +		err = wait_for_engines(i915);
> +		if (err)
> +			return err;
> +
>   		i915_retire_requests(i915);
>   		GEM_BUG_ON(i915->gt.active_requests);
> -
> -		return wait_for_engines(i915);
>   	} else {
>   		struct intel_engine_cs *engine;
>   		enum intel_engine_id id;
> @@ -3824,9 +3827,9 @@ int i915_gem_wait_for_idle(struct drm_i915_private *i915, unsigned int flags)
>   			if (err)
>   				return err;
>   		}
> -
> -		return 0;
>   	}
> +
> +	return 0;
>   }
>   
>   static void __i915_gem_object_flush_for_display(struct drm_i915_gem_object *obj)
> 

To me this order makes more sense in general.

Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Regards,

Tvrtko
Chris Wilson June 27, 2018, 11:41 a.m. UTC | #2
Quoting Tvrtko Ursulin (2018-06-27 12:32:35)
> 
> To me this order makes more sense in general.

Apart from the cries of struct_mutex, no! I feel a chill go up my spline
for every i915_retire_requests(). (How on earth are we going to dig
ourselves out of this one? One hopes the globals can be constrained...)
-Chris
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 858d188dd33b..5a9cae604e2b 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -3810,10 +3810,13 @@  int i915_gem_wait_for_idle(struct drm_i915_private *i915, unsigned int flags)
 			if (err)
 				return err;
 		}
+
+		err = wait_for_engines(i915);
+		if (err)
+			return err;
+
 		i915_retire_requests(i915);
 		GEM_BUG_ON(i915->gt.active_requests);
-
-		return wait_for_engines(i915);
 	} else {
 		struct intel_engine_cs *engine;
 		enum intel_engine_id id;
@@ -3824,9 +3827,9 @@  int i915_gem_wait_for_idle(struct drm_i915_private *i915, unsigned int flags)
 			if (err)
 				return err;
 		}
-
-		return 0;
 	}
+
+	return 0;
 }
 
 static void __i915_gem_object_flush_for_display(struct drm_i915_gem_object *obj)