All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Intel Graphics Development <intel-gfx@lists.freedesktop.org>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Subject: Re: [PATCH 03/10] drm/i915: allow the existing error_state to be destroyed
Date: Fri, 4 May 2012 13:56:32 +0200	[thread overview]
Message-ID: <20120504115632.GE5443@phenom.ffwll.local> (raw)
In-Reply-To: <1335532667-10597-3-git-send-email-daniel.vetter@ffwll.ch>

On Fri, Apr 27, 2012 at 03:17:40PM +0200, Daniel Vetter wrote:
> ... by writing (anything) to i915_error_state.
> 
> This way we can simulate a bunch of gpu hangs and run the error_state
> capture code every time (without the need to reload the module).
> 
> To make that happen we need to abandon the simple seq_file wrappers
> provided by the drm core. While at it, but the new error_state
> refcounting to some good use and associated. This should help greatly
> when we finally get around to split up the giant single seq_file block
> that the error_state file currently is into smaller parts.

Meh, commit msg fail, that phrase should read "While at it put the new
error_state refcounting to some good use and associated the error_state to
the debugfs when opening the file. Otherwise the error_state could change
while someone is reading it. This should help greatly ..."

-Daniel
> 
> v2: Actually squash all the fixes into the patch ...
> 
> Signed-Off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> ---
>  drivers/gpu/drm/i915/i915_debugfs.c |   90 ++++++++++++++++++++++++++++++-----
>  1 files changed, 77 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
> index b46c198..4805df0 100644
> --- a/drivers/gpu/drm/i915/i915_debugfs.c
> +++ b/drivers/gpu/drm/i915/i915_debugfs.c
> @@ -691,21 +691,19 @@ static void i915_ring_error_state(struct seq_file *m,
>  	seq_printf(m, "  ring->tail: 0x%08x\n", error->cpu_ring_tail[ring]);
>  }
>  
> +struct i915_error_state_file_priv {
> +	struct drm_device *dev;
> +	struct drm_i915_error_state *error;
> +};
> +
>  static int i915_error_state(struct seq_file *m, void *unused)
>  {
> -	struct drm_info_node *node = (struct drm_info_node *) m->private;
> -	struct drm_device *dev = node->minor->dev;
> +	struct i915_error_state_file_priv *error_priv = m->private;
> +	struct drm_device *dev = error_priv->dev;
>  	drm_i915_private_t *dev_priv = dev->dev_private;
> -	struct drm_i915_error_state *error;
> -	unsigned long flags;
> +	struct drm_i915_error_state *error = error_priv->error;
>  	int i, j, page, offset, elt;
>  
> -	spin_lock_irqsave(&dev_priv->error_lock, flags);
> -	error = dev_priv->first_error;
> -	if (error)
> -		kref_get(&error->ref);
> -	spin_unlock_irqrestore(&dev_priv->error_lock, flags);
> -
>  	if (!error) {
>  		seq_printf(m, "no error state collected\n");
>  		return 0;
> @@ -792,11 +790,71 @@ static int i915_error_state(struct seq_file *m, void *unused)
>  	if (error->display)
>  		intel_display_print_error_state(m, dev, error->display);
>  
> -	kref_put(&error->ref, i915_error_state_free);
> -
>  	return 0;
>  }
>  
> +static ssize_t
> +i915_error_state_write(struct file *filp,
> +		       const char __user *ubuf,
> +		       size_t cnt,
> +		       loff_t *ppos)
> +{
> +	struct seq_file *m = filp->private_data;
> +	struct i915_error_state_file_priv *error_priv = m->private;
> +	struct drm_device *dev = error_priv->dev;
> +
> +	DRM_DEBUG_DRIVER("Resetting error state\n");
> +
> +	mutex_lock(&dev->struct_mutex);
> +	i915_destroy_error_state(dev);
> +	mutex_unlock(&dev->struct_mutex);
> +
> +	return cnt;
> +}
> +
> +static int i915_error_state_open(struct inode *inode, struct file *file)
> +{
> +	struct drm_device *dev = inode->i_private;
> +	drm_i915_private_t *dev_priv = dev->dev_private;
> +	struct i915_error_state_file_priv *error_priv;
> +	unsigned long flags;
> +
> +	error_priv = kzalloc(sizeof(*error_priv), GFP_KERNEL);
> +	if (!error_priv)
> +		return -ENOMEM;
> +
> +	error_priv->dev = dev;
> +
> +	spin_lock_irqsave(&dev_priv->error_lock, flags);
> +	error_priv->error = dev_priv->first_error;
> +	if (error_priv->error)
> +		kref_get(&error_priv->error->ref);
> +	spin_unlock_irqrestore(&dev_priv->error_lock, flags);
> +
> +	return single_open(file, i915_error_state, error_priv);
> +}
> +
> +static int i915_error_state_release(struct inode *inode, struct file *file)
> +{
> +	struct seq_file *m = file->private_data;
> +	struct i915_error_state_file_priv *error_priv = m->private;
> +
> +	if (error_priv->error)
> +		kref_put(&error_priv->error->ref, i915_error_state_free);
> +	kfree(error_priv);
> +
> +	return single_release(inode, file);
> +}
> +
> +static const struct file_operations i915_error_state_fops = {
> +	.owner = THIS_MODULE,
> +	.open = i915_error_state_open,
> +	.read = seq_read,
> +	.write = i915_error_state_write,
> +	.llseek = default_llseek,
> +	.release = i915_error_state_release,
> +};
> +
>  static int i915_rstdby_delays(struct seq_file *m, void *unused)
>  {
>  	struct drm_info_node *node = (struct drm_info_node *) m->private;
> @@ -1645,6 +1703,7 @@ static const struct file_operations i915_ring_stop_fops = {
>  	.write = i915_ring_stop_write,
>  	.llseek = default_llseek,
>  };
> +
>  static ssize_t
>  i915_max_freq_read(struct file *filp,
>  		   char __user *ubuf,
> @@ -1899,7 +1958,6 @@ static struct drm_info_list i915_debugfs_list[] = {
>  	{"i915_gem_hws", i915_hws_info, 0, (void *)RCS},
>  	{"i915_gem_hws_blt", i915_hws_info, 0, (void *)BCS},
>  	{"i915_gem_hws_bsd", i915_hws_info, 0, (void *)VCS},
> -	{"i915_error_state", i915_error_state, 0},
>  	{"i915_rstdby_delays", i915_rstdby_delays, 0},
>  	{"i915_cur_delayinfo", i915_cur_delayinfo, 0},
>  	{"i915_delayfreq_table", i915_delayfreq_table, 0},
> @@ -1951,6 +2009,12 @@ int i915_debugfs_init(struct drm_minor *minor)
>  	if (ret)
>  		return ret;
>  
> +	ret = i915_debugfs_create(minor->debugfs_root, minor,
> +				  "i915_error_state",
> +				  &i915_error_state_fops);
> +	if (ret)
> +		return ret;
> +
>  	return drm_debugfs_create_files(i915_debugfs_list,
>  					I915_DEBUGFS_ENTRIES,
>  					minor->debugfs_root, minor);
> -- 
> 1.7.9
> 

-- 
Daniel Vetter
Mail: daniel@ffwll.ch
Mobile: +41 (0)79 365 57 48

  reply	other threads:[~2012-05-04 11:55 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-27 13:17 [PATCH 01/10] drm/i915: add interface to simulate gpu hangs Daniel Vetter
2012-04-27 13:17 ` [PATCH 02/10] drm/i915: rework dev->first_error locking Daniel Vetter
2012-05-04 17:04   ` Eugeni Dodonov
2012-04-27 13:17 ` [PATCH 03/10] drm/i915: allow the existing error_state to be destroyed Daniel Vetter
2012-05-04 11:56   ` Daniel Vetter [this message]
2012-05-04 17:15     ` Eugeni Dodonov
2012-05-04 19:58       ` Daniel Vetter
2012-04-27 13:17 ` [PATCH 04/10] drm/i915: simplify i915_reset a bit Daniel Vetter
2012-05-04 16:47   ` Eugeni Dodonov
2012-04-27 13:17 ` [PATCH 05/10] drm/i915: extract intel_gpu_reset Daniel Vetter
2012-04-30  1:03   ` Ben Widawsky
2012-05-04 16:51   ` Eugeni Dodonov
2012-04-27 13:17 ` [PATCH 06/10] drm/i915: make gpu hangman more resilient Daniel Vetter
2012-05-04 16:47   ` Eugeni Dodonov
2012-04-27 13:17 ` [PATCH 07/10] drm/i915: kill flags parameter for reset functions Daniel Vetter
2012-05-04 16:47   ` Eugeni Dodonov
2012-04-27 13:17 ` [PATCH 08/10] drm/i915: also reset the media engine on gen4/5 Daniel Vetter
2012-04-27 13:17 ` [PATCH 09/10] drm/i915: remove modeset reset from i915_reset Daniel Vetter
2012-04-27 13:17 ` [PATCH 10/10] drm/i915: kill gen4 gpu reset code Daniel Vetter
2012-04-27 18:49   ` Eric Anholt
2012-04-27 19:17     ` Daniel Vetter
2012-04-27 23:26       ` Eric Anholt
2012-05-02 19:33         ` [PATCH] drm/i915: fix gen4 gpu reset Daniel Vetter
2012-05-02 19:54           ` Kenneth Graunke
2012-05-04 12:07             ` Daniel Vetter
2012-05-04 17:06           ` Eugeni Dodonov
2012-04-28  4:56 ` [PATCH 01/10] drm/i915: add interface to simulate gpu hangs Ben Widawsky
2012-05-02 15:23   ` Daniel Vetter
2012-05-03 12:48 ` [PATCH] " Daniel Vetter
2012-05-03 19:00   ` Eugeni Dodonov
2012-05-05 19:13     ` Daniel Vetter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120504115632.GE5443@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=daniel.vetter@ffwll.ch \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.