On Thu, Oct 05, 2017 at 11:13:43AM +0200, Michał Winiarski wrote: > From: Dave Gordon <david.s.gordon@xxxxxxxxx> > > 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@xxxxxxxxxxxxxxxxxx> > Cc: Jeff Mcgee <jeff.mcgee@xxxxxxxxx> > Cc: Michal Wajdeczko <michal.wajdeczko@xxxxxxxxx> > Cc: Oscar Mateo <oscar.mateo@xxxxxxxxx> > Signed-off-by: Dave Gordon <david.s.gordon@xxxxxxxxx> > Signed-off-by: Michał Winiarski <michal.winiarski@xxxxxxxxx> > --- > 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"); > + 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); > I think that client is still being initialized above to guc->execbuf_client. If so, can it be removed? > - if (!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; > + } > + > 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) { Do we need this check? It seems that execbuf_client and preempt_client are both required for GuC submission to be enabled. > + 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 */ > -- > 2.13.5 > _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/intel-gfx