[Intel-gfx] [PATCH 04/10] drm/i915/guc: Add a second client, to be used for preemption

Michal Wajdeczko michal.wajdeczko at intel.com
Thu Oct 5 13:59:37 UTC 2017


On Thu, 05 Oct 2017 11:13:43 +0200, Michał Winiarski  
<michal.winiarski at intel.com> wrote:

> From: Dave Gordon <david.s.gordon at intel.com>
>
> This second client is created with priority KMD_HIGH, and marked
> as preemptive. This will allow us to request preemption using GuC  
> actions.
>
> Cc: Chris Wilson <chris at chris-wilson.co.uk>
> Cc: Jeff Mcgee <jeff.mcgee at intel.com>
> Cc: Michal Wajdeczko <michal.wajdeczko at intel.com>
> Cc: Oscar Mateo <oscar.mateo at intel.com>
> Signed-off-by: Dave Gordon <david.s.gordon at intel.com>
> Signed-off-by: Michał Winiarski <michal.winiarski at intel.com>
> ---
>  drivers/gpu/drm/i915/i915_debugfs.c        |  4 ++++
>  drivers/gpu/drm/i915/i915_guc_submission.c | 32  
> ++++++++++++++++++++++++++----
>  drivers/gpu/drm/i915/intel_uc.h            |  1 +
>  3 files changed, 33 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_debugfs.c  
> b/drivers/gpu/drm/i915/i915_debugfs.c
> index b4a6ac60e7c6..1a963c13cab8 100644
> --- a/drivers/gpu/drm/i915/i915_debugfs.c
> +++ b/drivers/gpu/drm/i915/i915_debugfs.c
> @@ -2488,6 +2488,10 @@ static int i915_guc_info(struct seq_file *m, void  
> *data)
> 	seq_printf(m, "\nGuC execbuf client @ %p:\n", guc->execbuf_client);
>  	i915_guc_client_info(m, dev_priv, guc->execbuf_client);
> +	if (guc->preempt_client) {
> +		seq_printf(m, "\nGuC preempt client\n");

Maybe to match output from 'execbuf' there should be "@ %p:"

> +		i915_guc_client_info(m, dev_priv, guc->preempt_client);
> +	}
> 	i915_guc_log_info(m, dev_priv);
> diff --git a/drivers/gpu/drm/i915/i915_guc_submission.c  
> b/drivers/gpu/drm/i915/i915_guc_submission.c
> index 374501a67274..e8052e86426d 100644
> --- a/drivers/gpu/drm/i915/i915_guc_submission.c
> +++ b/drivers/gpu/drm/i915/i915_guc_submission.c
> @@ -331,6 +331,8 @@ static void guc_stage_desc_init(struct intel_guc  
> *guc,
>  	memset(desc, 0, sizeof(*desc));
> 	desc->attribute = GUC_STAGE_DESC_ATTR_ACTIVE |  
> GUC_STAGE_DESC_ATTR_KERNEL;
> +	if (client->priority <= GUC_CLIENT_PRIORITY_HIGH)
> +		desc->attribute |= GUC_STAGE_DESC_ATTR_PREEMPT;
>  	desc->stage_id = client->stage_id;
>  	desc->priority = client->priority;
>  	desc->db_id = client->doorbell_id;
> @@ -1154,7 +1156,7 @@ int i915_guc_submission_enable(struct  
> drm_i915_private *dev_priv)
>  		     sizeof(struct guc_wq_item) *
>  		     I915_NUM_ENGINES > GUC_WQ_SIZE);
> -	if (!client) {

Make sure to remove unnecessary earlier assignment:
	client = guc->execbuf_client;

> +	if (!guc->execbuf_client) {
>  		client = guc_client_alloc(dev_priv,
>  					  INTEL_INFO(dev_priv)->ring_mask,
>  					  GUC_CLIENT_PRIORITY_KMD_NORMAL,
> @@ -1167,15 +1169,29 @@ int i915_guc_submission_enable(struct  
> drm_i915_private *dev_priv)
>  		guc->execbuf_client = client;
>  	}
> +	if (!guc->preempt_client) {
> +		client = guc_client_alloc(dev_priv,
> +					  INTEL_INFO(dev_priv)->ring_mask,
> +					  GUC_CLIENT_PRIORITY_KMD_HIGH,
> +					  dev_priv->preempt_context);
> +		if (IS_ERR(client)) {
> +			DRM_ERROR("Failed to create GuC client for preemption!\n");
> +			err = PTR_ERR(client);
> +			goto err_free_clients;
> +		}
> +
> +		guc->preempt_client = client;
> +	}
> +

If we allow clients to be already created here, then maybe we should
move their creation into separate helper inline to clearly mark that.
Then we will have simpler error handling sequence ;)

>  	err = intel_guc_sample_forcewake(guc);
>  	if (err)
> -		goto err_execbuf_client;
> +		goto err_free_clients;
> 	guc_reset_wq(client);
> 	err = guc_init_doorbell_hw(guc);
>  	if (err)
> -		goto err_execbuf_client;
> +		goto err_free_clients;
> 	/* Take over from manual control of ELSP (execlists) */
>  	guc_interrupts_capture(dev_priv);
> @@ -1187,7 +1203,11 @@ int i915_guc_submission_enable(struct  
> drm_i915_private *dev_priv)
> 	return 0;
> -err_execbuf_client:
> +err_free_clients:
> +	if (guc->preempt_client) {
> +		guc_client_free(guc->preempt_client);
> +		guc->preempt_client = NULL;
> +	}
>  	guc_client_free(guc->execbuf_client);
>  	guc->execbuf_client = NULL;
>  	return err;
> @@ -1202,6 +1222,10 @@ void i915_guc_submission_disable(struct  
> drm_i915_private *dev_priv)
>  	/* Revert back to manual ELSP submission */
>  	intel_engines_reset_default_submission(dev_priv);
> +	if (guc->preempt_client) {
> +		guc_client_free(guc->preempt_client);
> +		guc->preempt_client = NULL;
> +	}
>  	guc_client_free(guc->execbuf_client);
>  	guc->execbuf_client = NULL;
>  }
> diff --git a/drivers/gpu/drm/i915/intel_uc.h  
> b/drivers/gpu/drm/i915/intel_uc.h
> index 10e8f0ed02e4..c6c6f8513bbf 100644
> --- a/drivers/gpu/drm/i915/intel_uc.h
> +++ b/drivers/gpu/drm/i915/intel_uc.h
> @@ -107,6 +107,7 @@ struct intel_guc {
>  	struct ida stage_ids;
> 	struct i915_guc_client *execbuf_client;
> +	struct i915_guc_client *preempt_client;
> 	DECLARE_BITMAP(doorbell_bitmap, GUC_NUM_DOORBELLS);
>  	uint32_t db_cacheline;		/* Cyclic counter mod pagesize	*/


More information about the Intel-gfx mailing list