From: Mika Kuoppala <mika.kuoppala@linux.intel.com>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH 1/6] drm/i915: Add debugfs entry to read/write next_seqno
Date: Tue, 4 Dec 2012 15:12:00 +0200 [thread overview]
Message-ID: <1354626725-8521-2-git-send-email-mika.kuoppala@intel.com> (raw)
In-Reply-To: <1354626725-8521-1-git-send-email-mika.kuoppala@intel.com>
This is needed for testing seqno wrapping. Be careful to not bump next_seqno
more than 0x7FFFFFFF at a time (between some handled requests) as
i915_seqno_passed() can't handle bigger difference in between.
v2: Address review comments from Chris Wilson.
Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com>
---
drivers/gpu/drm/i915/i915_debugfs.c | 86 +++++++++++++++++++++++++++++++++++
1 file changed, 86 insertions(+)
diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
index ce60506..18de201 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -843,6 +843,86 @@ static const struct file_operations i915_error_state_fops = {
.release = i915_error_state_release,
};
+static ssize_t
+i915_next_seqno_read(struct file *filp,
+ char __user *ubuf,
+ size_t max,
+ loff_t *ppos)
+{
+ struct drm_device *dev = filp->private_data;
+ drm_i915_private_t *dev_priv = dev->dev_private;
+ char buf[80];
+ int len;
+ int ret;
+
+ ret = mutex_lock_interruptible(&dev->struct_mutex);
+ if (ret)
+ return ret;
+
+ len = snprintf(buf, sizeof(buf),
+ "next_seqno : 0x%x\n",
+ dev_priv->next_seqno);
+
+ mutex_unlock(&dev->struct_mutex);
+
+ if (len > sizeof(buf))
+ len = sizeof(buf);
+
+ return simple_read_from_buffer(ubuf, max, ppos, buf, len);
+}
+
+static ssize_t
+i915_next_seqno_write(struct file *filp,
+ const char __user *ubuf,
+ size_t cnt,
+ loff_t *ppos)
+{
+ struct drm_device *dev = filp->private_data;
+ drm_i915_private_t *dev_priv = dev->dev_private;
+ char buf[20];
+ u32 val = 1;
+ int ret;
+
+ if (cnt > 0) {
+ if (cnt > sizeof(buf) - 1)
+ return -EINVAL;
+
+ if (copy_from_user(buf, ubuf, cnt))
+ return -EFAULT;
+ buf[cnt] = 0;
+
+ ret = kstrtouint(buf, 0, &val);
+ if (ret < 0)
+ return ret;
+ }
+
+ if (val == 0)
+ return -EINVAL;
+
+ ret = mutex_lock_interruptible(&dev->struct_mutex);
+ if (ret)
+ return ret;
+
+ if (i915_seqno_passed(val, dev_priv->next_seqno)) {
+ dev_priv->next_seqno = val;
+ DRM_DEBUG_DRIVER("Advancing seqno to %u\n", val);
+ } else {
+ ret = -EINVAL;
+ }
+
+ mutex_unlock(&dev->struct_mutex);
+
+ return ret ?: cnt;
+}
+
+static const struct file_operations i915_next_seqno_fops = {
+ .owner = THIS_MODULE,
+ .open = simple_open,
+ .read = i915_next_seqno_read,
+ .write = i915_next_seqno_write,
+ .llseek = default_llseek,
+};
+
static int i915_rstdby_delays(struct seq_file *m, void *unused)
{
struct drm_info_node *node = (struct drm_info_node *) m->private;
@@ -2107,6 +2187,12 @@ int i915_debugfs_init(struct drm_minor *minor)
if (ret)
return ret;
+ ret = i915_debugfs_create(minor->debugfs_root, minor,
+ "i915_next_seqno",
+ &i915_next_seqno_fops);
+ if (ret)
+ return ret;
+
return drm_debugfs_create_files(i915_debugfs_list,
I915_DEBUGFS_ENTRIES,
minor->debugfs_root, minor);
--
1.7.9.5
next prev parent reply other threads:[~2012-12-04 13:12 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-04 13:11 [PATCH 0/6] ring seqno wrap handling Mika Kuoppala
2012-12-04 13:12 ` Mika Kuoppala [this message]
2012-12-04 13:12 ` [PATCH 2/6] drm/i915: Fix debugfs seqno info print to use uint Mika Kuoppala
2012-12-04 13:12 ` [PATCH 3/6] drm/i915: Don't emit semaphore wait if wrap happened Mika Kuoppala
2012-12-05 20:44 ` Paulo Zanoni
2012-12-06 8:51 ` Daniel Vetter
2012-12-06 11:41 ` Paulo Zanoni
2012-12-06 12:14 ` Daniel Vetter
2012-12-06 12:24 ` Chris Wilson
2012-12-06 14:12 ` [PATCH] Detect wraparound using next-seqno rather than waiter->olr Chris Wilson
2012-12-04 13:12 ` [PATCH 4/6] drm/i915: Split intel_ring_begin Mika Kuoppala
2012-12-04 13:12 ` [PATCH 5/6] drm/i915: Add intel_ring_handle_seqno wrap Mika Kuoppala
2012-12-04 13:12 ` [PATCH 6/6] drm/i915: Set initial seqno value close to wrap boundary Mika Kuoppala
2012-12-04 14:05 ` [PATCH 0/6] ring seqno wrap handling Chris Wilson
2012-12-04 22:03 ` 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=1354626725-8521-2-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