Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Mika Kuoppala <mika.kuoppala@linux.intel.com>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH 1/4] drm/i915: export error state to string conversion
Date: Thu,  6 Jun 2013 15:18:39 +0300	[thread overview]
Message-ID: <1370521122-20268-1-git-send-email-mika.kuoppala@intel.com> (raw)

In preparation for accessing error state from sysfs, export
error state to string conversion function. Also tuck buffer
error handling inside the function.

Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com>
---
 drivers/gpu/drm/i915/i915_debugfs.c |   24 ++++++++----------------
 drivers/gpu/drm/i915/i915_drv.h     |    7 +++++++
 2 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
index 0e7e3c0..77bfd51 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -739,15 +739,8 @@ static void i915_ring_error_state(struct drm_i915_error_state_buf *m,
 	err_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 i915_error_state_file_priv *error_priv,
-			    struct drm_i915_error_state_buf *m)
-
+int i915_error_state_to_str(struct drm_i915_error_state_buf *m,
+			    const struct i915_error_state_file_priv *error_priv)
 {
 	struct drm_device *dev = error_priv->dev;
 	drm_i915_private_t *dev_priv = dev->dev_private;
@@ -757,7 +750,7 @@ static int i915_error_state(struct i915_error_state_file_priv *error_priv,
 
 	if (!error) {
 		err_printf(m, "no error state collected\n");
-		return 0;
+		goto out;
 	}
 
 	err_printf(m, "Time: %ld s %ld us\n", error->time.tv_sec,
@@ -867,6 +860,10 @@ static int i915_error_state(struct i915_error_state_file_priv *error_priv,
 	if (error->display)
 		intel_display_print_error_state(m, dev, error->display);
 
+out:
+	if (m->bytes == 0 && m->err)
+		return m->err;
+
 	return 0;
 }
 
@@ -960,15 +957,10 @@ static ssize_t i915_error_state_read(struct file *file, char __user *userbuf,
 
 	error_str.start = *pos;
 
-	ret = i915_error_state(error_priv, &error_str);
+	ret = i915_error_state_to_str(&error_str, error_priv);
 	if (ret)
 		goto out;
 
-	if (error_str.bytes == 0 && error_str.err) {
-		ret = error_str.err;
-		goto out;
-	}
-
 	ret_count = simple_read_from_buffer(userbuf, count, &tmp_pos,
 					    error_str.buf,
 					    error_str.bytes);
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 215aa63..538b36b 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -857,6 +857,11 @@ struct drm_i915_error_state_buf {
 	loff_t pos;
 };
 
+struct i915_error_state_file_priv {
+	struct drm_device *dev;
+	struct drm_i915_error_state *error;
+};
+
 struct i915_gpu_error {
 	/* For hangcheck timer */
 #define DRM_I915_HANGCHECK_PERIOD 1500 /* in ms */
@@ -1850,6 +1855,8 @@ int i915_debugfs_init(struct drm_minor *minor);
 void i915_debugfs_cleanup(struct drm_minor *minor);
 __printf(2, 3)
 void i915_error_printf(struct drm_i915_error_state_buf *e, const char *f, ...);
+int i915_error_state_to_str(struct drm_i915_error_state_buf *estr,
+			    const struct i915_error_state_file_priv *error);
 
 /* i915_suspend.c */
 extern int i915_save_state(struct drm_device *dev);
-- 
1.7.9.5

             reply	other threads:[~2013-06-06 12:18 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-06 12:18 Mika Kuoppala [this message]
2013-06-06 12:18 ` [PATCH 2/4] drm/i915: export error state ref handling Mika Kuoppala
2013-06-06 12:18 ` [PATCH 3/4] drm/i915: introduce i915_error_state_buf_init Mika Kuoppala
2013-06-06 12:18 ` [PATCH 4/4] drm/i915: add i915_error_state sysfs entry Mika Kuoppala
2013-06-06 12:22   ` Chris Wilson
2013-06-06 12:24   ` Daniel Vetter
2013-06-06 13:33   ` [PATCH 4/4] drm/i915: add error_state " Mika Kuoppala
2013-06-06 13:48     ` Chris Wilson
2013-06-06 14:38       ` Mika Kuoppala
2013-07-01 16:19         ` Chris Wilson
2013-07-01 16:56           ` 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=1370521122-20268-1-git-send-email-mika.kuoppala@intel.com \
    --to=mika.kuoppala@linux.intel.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox