[Intel-gfx] [PATCH v2 2/6] drm/i915: Trim i915_guc_info() stack usage
Tvrtko Ursulin
tvrtko.ursulin at linux.intel.com
Tue Nov 29 12:17:58 UTC 2016
On 29/11/2016 12:10, Chris Wilson wrote:
> i915_guc_info() (part of debugfs output) tries to avoid holding
> struct_mutex for a long period by copying onto the stack. This causes a
> warning that the stack frame is massive, so stop doing that. We can even
> forgo holding the struct_mutex here as that doesn't serialise the values
> being read (and the lists used exist for the device lifetime).
>
> v2: Skip printing anything if guc->execbuf_client is disabled (avoids
> potential NULL dereference).
>
> Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
> ---
> drivers/gpu/drm/i915/i915_debugfs.c | 46 ++++++++++++++++---------------------
> 1 file changed, 20 insertions(+), 26 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
> index 8eb8c29b7492..a3eaf88f4a42 100644
> --- a/drivers/gpu/drm/i915/i915_debugfs.c
> +++ b/drivers/gpu/drm/i915/i915_debugfs.c
> @@ -2434,47 +2434,41 @@ static void i915_guc_client_info(struct seq_file *m,
> static int i915_guc_info(struct seq_file *m, void *data)
> {
> struct drm_i915_private *dev_priv = node_to_i915(m->private);
> - struct drm_device *dev = &dev_priv->drm;
> - struct intel_guc guc;
> - struct i915_guc_client client = {};
> + const struct intel_guc *guc = &dev_priv->guc;
> struct intel_engine_cs *engine;
> enum intel_engine_id id;
> - u64 total = 0;
> -
> - if (!HAS_GUC_SCHED(dev_priv))
> - return 0;
> + u64 total;
>
> - if (mutex_lock_interruptible(&dev->struct_mutex))
> + if (!guc->execbuf_client) {
> + seq_printf(m, "GuC submission %s\n",
> + HAS_GUC_SCHED(dev_priv) ?
> + "disabled" :
> + "not supported");
> return 0;
> -
> - /* Take a local copy of the GuC data, so we can dump it at leisure */
> - guc = dev_priv->guc;
> - if (guc.execbuf_client)
> - client = *guc.execbuf_client;
> -
> - mutex_unlock(&dev->struct_mutex);
> + }
>
> seq_printf(m, "Doorbell map:\n");
> - seq_printf(m, "\t%*pb\n", GUC_MAX_DOORBELLS, guc.doorbell_bitmap);
> - seq_printf(m, "Doorbell next cacheline: 0x%x\n\n", guc.db_cacheline);
> + seq_printf(m, "\t%*pb\n", GUC_MAX_DOORBELLS, guc->doorbell_bitmap);
> + seq_printf(m, "Doorbell next cacheline: 0x%x\n\n", guc->db_cacheline);
>
> - seq_printf(m, "GuC total action count: %llu\n", guc.action_count);
> - seq_printf(m, "GuC action failure count: %u\n", guc.action_fail);
> - seq_printf(m, "GuC last action command: 0x%x\n", guc.action_cmd);
> - seq_printf(m, "GuC last action status: 0x%x\n", guc.action_status);
> - seq_printf(m, "GuC last action error code: %d\n", guc.action_err);
> + seq_printf(m, "GuC total action count: %llu\n", guc->action_count);
> + seq_printf(m, "GuC action failure count: %u\n", guc->action_fail);
> + seq_printf(m, "GuC last action command: 0x%x\n", guc->action_cmd);
> + seq_printf(m, "GuC last action status: 0x%x\n", guc->action_status);
> + seq_printf(m, "GuC last action error code: %d\n", guc->action_err);
>
> + total = 0;
> seq_printf(m, "\nGuC submissions:\n");
> for_each_engine(engine, dev_priv, id) {
> - u64 submissions = guc.submissions[id];
> + u64 submissions = guc->submissions[id];
> total += submissions;
> seq_printf(m, "\t%-24s: %10llu, last seqno 0x%08x\n",
> - engine->name, submissions, guc.last_seqno[id]);
> + engine->name, submissions, guc->last_seqno[id]);
> }
> seq_printf(m, "\t%s: %llu\n", "Total", total);
>
> - seq_printf(m, "\nGuC execbuf client @ %p:\n", guc.execbuf_client);
> - i915_guc_client_info(m, dev_priv, &client);
> + seq_printf(m, "\nGuC execbuf client @ %p:\n", guc->execbuf_client);
> + i915_guc_client_info(m, dev_priv, guc->execbuf_client);
>
> i915_guc_log_info(m, dev_priv);
>
>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
Regards,
Tvrtko
More information about the Intel-gfx
mailing list