diff mbox

[2/5] drm/i915/execlists: Refactor out complete_preempt_context()

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

Commit Message

Chris Wilson March 20, 2018, 12:18 a.m. UTC
As a complement to inject_preempt_context(), follow up with the function
to handle its completion. This will be useful should we wish to extend
the duties of the preempt-context for execlists.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Jeff McGee <jeff.mcgee@intel.com>
Cc: Michał Winiarski <michal.winiarski@intel.com>
---
 drivers/gpu/drm/i915/intel_lrc.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

Comments

jeff.mcgee@intel.com March 22, 2018, 3:26 p.m. UTC | #1
On Tue, Mar 20, 2018 at 12:18:45AM +0000, Chris Wilson wrote:
> As a complement to inject_preempt_context(), follow up with the function
> to handle its completion. This will be useful should we wish to extend
> the duties of the preempt-context for execlists.
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Jeff McGee <jeff.mcgee@intel.com>
> Cc: Michał Winiarski <michal.winiarski@intel.com>
> ---
>  drivers/gpu/drm/i915/intel_lrc.c | 22 ++++++++++++----------
>  1 file changed, 12 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
> index 53f1c009ed7b..0bfaeb56b8c7 100644
> --- a/drivers/gpu/drm/i915/intel_lrc.c
> +++ b/drivers/gpu/drm/i915/intel_lrc.c
> @@ -531,8 +531,17 @@ static void inject_preempt_context(struct intel_engine_cs *engine)
>  	if (execlists->ctrl_reg)
>  		writel(EL_CTRL_LOAD, execlists->ctrl_reg);
>  
> -	execlists_clear_active(&engine->execlists, EXECLISTS_ACTIVE_HWACK);
> -	execlists_set_active(&engine->execlists, EXECLISTS_ACTIVE_PREEMPT);
> +	execlists_clear_active(execlists, EXECLISTS_ACTIVE_HWACK);
> +	execlists_set_active(execlists, EXECLISTS_ACTIVE_PREEMPT);
> +}
> +
> +static void complete_preempt_context(struct intel_engine_execlists *execlists)
> +{
> +	execlists_cancel_port_requests(execlists);
> +	execlists_unwind_incomplete_requests(execlists);
> +
> +	GEM_BUG_ON(!execlists_is_active(execlists, EXECLISTS_ACTIVE_PREEMPT));
> +	execlists_clear_active(execlists, EXECLISTS_ACTIVE_PREEMPT);
>  }
>  
>  static void execlists_dequeue(struct intel_engine_cs *engine)
> @@ -939,14 +948,7 @@ static void execlists_submission_tasklet(unsigned long data)
>  			if (status & GEN8_CTX_STATUS_COMPLETE &&
>  			    buf[2*head + 1] == execlists->preempt_complete_status) {
>  				GEM_TRACE("%s preempt-idle\n", engine->name);
> -
> -				execlists_cancel_port_requests(execlists);
> -				execlists_unwind_incomplete_requests(execlists);
> -
> -				GEM_BUG_ON(!execlists_is_active(execlists,
> -								EXECLISTS_ACTIVE_PREEMPT));
> -				execlists_clear_active(execlists,
> -						       EXECLISTS_ACTIVE_PREEMPT);
> +				complete_preempt_context(execlists);
>  				continue;
>  			}
>  
> -- 
> 2.16.2
> 

Reviewed-by: Jeff McGee <jeff.mcgee@intel.com>
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
index 53f1c009ed7b..0bfaeb56b8c7 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -531,8 +531,17 @@  static void inject_preempt_context(struct intel_engine_cs *engine)
 	if (execlists->ctrl_reg)
 		writel(EL_CTRL_LOAD, execlists->ctrl_reg);
 
-	execlists_clear_active(&engine->execlists, EXECLISTS_ACTIVE_HWACK);
-	execlists_set_active(&engine->execlists, EXECLISTS_ACTIVE_PREEMPT);
+	execlists_clear_active(execlists, EXECLISTS_ACTIVE_HWACK);
+	execlists_set_active(execlists, EXECLISTS_ACTIVE_PREEMPT);
+}
+
+static void complete_preempt_context(struct intel_engine_execlists *execlists)
+{
+	execlists_cancel_port_requests(execlists);
+	execlists_unwind_incomplete_requests(execlists);
+
+	GEM_BUG_ON(!execlists_is_active(execlists, EXECLISTS_ACTIVE_PREEMPT));
+	execlists_clear_active(execlists, EXECLISTS_ACTIVE_PREEMPT);
 }
 
 static void execlists_dequeue(struct intel_engine_cs *engine)
@@ -939,14 +948,7 @@  static void execlists_submission_tasklet(unsigned long data)
 			if (status & GEN8_CTX_STATUS_COMPLETE &&
 			    buf[2*head + 1] == execlists->preempt_complete_status) {
 				GEM_TRACE("%s preempt-idle\n", engine->name);
-
-				execlists_cancel_port_requests(execlists);
-				execlists_unwind_incomplete_requests(execlists);
-
-				GEM_BUG_ON(!execlists_is_active(execlists,
-								EXECLISTS_ACTIVE_PREEMPT));
-				execlists_clear_active(execlists,
-						       EXECLISTS_ACTIVE_PREEMPT);
+				complete_preempt_context(execlists);
 				continue;
 			}