* [PATCH 1/4] drm/i915: export error state to string conversion
@ 2013-06-06 12:18 Mika Kuoppala
2013-06-06 12:18 ` [PATCH 2/4] drm/i915: export error state ref handling Mika Kuoppala
` (2 more replies)
0 siblings, 3 replies; 11+ messages in thread
From: Mika Kuoppala @ 2013-06-06 12:18 UTC (permalink / raw)
To: intel-gfx
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
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 2/4] drm/i915: export error state ref handling
2013-06-06 12:18 [PATCH 1/4] drm/i915: export error state to string conversion Mika Kuoppala
@ 2013-06-06 12:18 ` 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
2 siblings, 0 replies; 11+ messages in thread
From: Mika Kuoppala @ 2013-06-06 12:18 UTC (permalink / raw)
To: intel-gfx
In preparation for sysfs error state access,
export ref error state ref counting interface.
Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com>
---
drivers/gpu/drm/i915/i915_debugfs.c | 31 ++++++++++++++++++++++---------
drivers/gpu/drm/i915/i915_drv.h | 3 +++
2 files changed, 25 insertions(+), 9 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
index 77bfd51..1e22820 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -889,12 +889,30 @@ i915_error_state_write(struct file *filp,
return cnt;
}
+void i915_error_state_get(struct drm_device *dev,
+ struct i915_error_state_file_priv *error_priv)
+{
+ struct drm_i915_private *dev_priv = dev->dev_private;
+ unsigned long flags;
+
+ spin_lock_irqsave(&dev_priv->gpu_error.lock, flags);
+ error_priv->error = dev_priv->gpu_error.first_error;
+ if (error_priv->error)
+ kref_get(&error_priv->error->ref);
+ spin_unlock_irqrestore(&dev_priv->gpu_error.lock, flags);
+
+}
+
+void i915_error_state_put(struct i915_error_state_file_priv *error_priv)
+{
+ if (error_priv->error)
+ kref_put(&error_priv->error->ref, i915_error_state_free);
+}
+
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)
@@ -902,11 +920,7 @@ static int i915_error_state_open(struct inode *inode, struct file *file)
error_priv->dev = dev;
- spin_lock_irqsave(&dev_priv->gpu_error.lock, flags);
- error_priv->error = dev_priv->gpu_error.first_error;
- if (error_priv->error)
- kref_get(&error_priv->error->ref);
- spin_unlock_irqrestore(&dev_priv->gpu_error.lock, flags);
+ i915_error_state_get(dev, error_priv);
file->private_data = error_priv;
@@ -917,8 +931,7 @@ static int i915_error_state_release(struct inode *inode, struct file *file)
{
struct i915_error_state_file_priv *error_priv = file->private_data;
- if (error_priv->error)
- kref_put(&error_priv->error->ref, i915_error_state_free);
+ i915_error_state_put(error_priv);
kfree(error_priv);
return 0;
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 538b36b..adc2841 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -1857,6 +1857,9 @@ __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);
+void i915_error_state_get(struct drm_device *dev,
+ struct i915_error_state_file_priv *error_priv);
+void i915_error_state_put(struct i915_error_state_file_priv *error_priv);
/* i915_suspend.c */
extern int i915_save_state(struct drm_device *dev);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 3/4] drm/i915: introduce i915_error_state_buf_init
2013-06-06 12:18 [PATCH 1/4] drm/i915: export error state to string conversion Mika Kuoppala
2013-06-06 12:18 ` [PATCH 2/4] drm/i915: export error state ref handling Mika Kuoppala
@ 2013-06-06 12:18 ` Mika Kuoppala
2013-06-06 12:18 ` [PATCH 4/4] drm/i915: add i915_error_state sysfs entry Mika Kuoppala
2 siblings, 0 replies; 11+ messages in thread
From: Mika Kuoppala @ 2013-06-06 12:18 UTC (permalink / raw)
To: intel-gfx
Make function for struct i915_error_state_buf initialization
and export it, for sysfs and debugfs.
Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com>
---
drivers/gpu/drm/i915/i915_debugfs.c | 50 +++++++++++++++++++++--------------
drivers/gpu/drm/i915/i915_drv.h | 7 +++++
2 files changed, 37 insertions(+), 20 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
index 1e22820..6ea6747 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -937,38 +937,48 @@ static int i915_error_state_release(struct inode *inode, struct file *file)
return 0;
}
-static ssize_t i915_error_state_read(struct file *file, char __user *userbuf,
- size_t count, loff_t *pos)
+int i915_error_state_buf_init(struct drm_i915_error_state_buf *ebuf,
+ size_t count, loff_t pos)
{
- struct i915_error_state_file_priv *error_priv = file->private_data;
- struct drm_i915_error_state_buf error_str;
- loff_t tmp_pos = 0;
- ssize_t ret_count = 0;
- int ret = 0;
-
- memset(&error_str, 0, sizeof(error_str));
+ memset(ebuf, 0, sizeof(*ebuf));
/* We need to have enough room to store any i915_error_state printf
* so that we can move it to start position.
*/
- error_str.size = count + 1 > PAGE_SIZE ? count + 1 : PAGE_SIZE;
- error_str.buf = kmalloc(error_str.size,
+ ebuf->size = count + 1 > PAGE_SIZE ? count + 1 : PAGE_SIZE;
+ ebuf->buf = kmalloc(ebuf->size,
GFP_TEMPORARY | __GFP_NORETRY | __GFP_NOWARN);
- if (error_str.buf == NULL) {
- error_str.size = PAGE_SIZE;
- error_str.buf = kmalloc(error_str.size, GFP_TEMPORARY);
+ if (ebuf->buf == NULL) {
+ ebuf->size = PAGE_SIZE;
+ ebuf->buf = kmalloc(ebuf->size, GFP_TEMPORARY);
}
- if (error_str.buf == NULL) {
- error_str.size = 128;
- error_str.buf = kmalloc(error_str.size, GFP_TEMPORARY);
+ if (ebuf->buf == NULL) {
+ ebuf->size = 128;
+ ebuf->buf = kmalloc(ebuf->size, GFP_TEMPORARY);
}
- if (error_str.buf == NULL)
+ if (ebuf->buf == NULL)
return -ENOMEM;
- error_str.start = *pos;
+ ebuf->start = pos;
+
+ return 0;
+}
+
+static ssize_t i915_error_state_read(struct file *file, char __user *userbuf,
+ size_t count, loff_t *pos)
+{
+ struct i915_error_state_file_priv *error_priv = file->private_data;
+ struct drm_i915_error_state_buf error_str;
+ loff_t tmp_pos = 0;
+ ssize_t ret_count = 0;
+ int ret;
+
+ ret = i915_error_state_buf_init(&error_str, count, *pos);
+ if (ret)
+ return ret;
ret = i915_error_state_to_str(&error_str, error_priv);
if (ret)
@@ -983,7 +993,7 @@ static ssize_t i915_error_state_read(struct file *file, char __user *userbuf,
else
*pos = error_str.start + ret_count;
out:
- kfree(error_str.buf);
+ i915_error_state_buf_release(&error_str);
return ret ?: ret_count;
}
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index adc2841..b8e16d1 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -1860,6 +1860,13 @@ int i915_error_state_to_str(struct drm_i915_error_state_buf *estr,
void i915_error_state_get(struct drm_device *dev,
struct i915_error_state_file_priv *error_priv);
void i915_error_state_put(struct i915_error_state_file_priv *error_priv);
+int i915_error_state_buf_init(struct drm_i915_error_state_buf *eb,
+ size_t count, loff_t pos);
+static inline void i915_error_state_buf_release(
+ struct drm_i915_error_state_buf *eb)
+{
+ kfree(eb->buf);
+}
/* i915_suspend.c */
extern int i915_save_state(struct drm_device *dev);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 4/4] drm/i915: add i915_error_state sysfs entry
2013-06-06 12:18 [PATCH 1/4] drm/i915: export error state to string conversion Mika Kuoppala
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 ` Mika Kuoppala
2013-06-06 12:22 ` Chris Wilson
` (2 more replies)
2 siblings, 3 replies; 11+ messages in thread
From: Mika Kuoppala @ 2013-06-06 12:18 UTC (permalink / raw)
To: intel-gfx
As getting error state doesn't anymore require big kmallocs,
make error state accessible also from sysfs.
Suggested-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com>
---
drivers/gpu/drm/i915/i915_sysfs.c | 49 +++++++++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+)
diff --git a/drivers/gpu/drm/i915/i915_sysfs.c b/drivers/gpu/drm/i915/i915_sysfs.c
index 6875b56..d4c754b 100644
--- a/drivers/gpu/drm/i915/i915_sysfs.c
+++ b/drivers/gpu/drm/i915/i915_sysfs.c
@@ -409,6 +409,49 @@ static const struct attribute *gen6_attrs[] = {
NULL,
};
+static ssize_t error_state_read(struct file *filp, struct kobject *kobj,
+ struct bin_attribute *attr, char *buf,
+ loff_t off, size_t count)
+{
+
+ struct device *kdev = container_of(kobj, struct device, kobj);
+ struct drm_minor *minor = container_of(kdev, struct drm_minor, kdev);
+ struct drm_device *dev = minor->dev;
+ struct i915_error_state_file_priv error_priv;
+ struct drm_i915_error_state_buf error_str;
+ ssize_t ret_count = 0;
+ int ret;
+
+ memset(&error_priv, 0, sizeof(error_priv));
+
+ ret = i915_error_state_buf_init(&error_str, count, off);
+ if (ret)
+ return ret;
+
+ error_priv.dev = dev;
+ i915_error_state_get(dev, &error_priv);
+
+ ret = i915_error_state_to_str(&error_str, &error_priv);
+ if (ret)
+ goto out;
+
+ ret_count = count < error_str.bytes ? count : error_str.bytes;
+
+ memcpy(buf, error_str.buf, ret_count);
+out:
+ i915_error_state_buf_release(&error_str);
+ i915_error_state_put(&error_priv);
+
+ return ret ?: ret_count;
+}
+
+static struct bin_attribute error_state_attr = {
+ .attr.name = "i915_error_state",
+ .attr.mode = 0444,
+ .size = 0,
+ .read = error_state_read,
+};
+
void i915_setup_sysfs(struct drm_device *dev)
{
int ret;
@@ -432,10 +475,16 @@ void i915_setup_sysfs(struct drm_device *dev)
if (ret)
DRM_ERROR("gen6 sysfs setup failed\n");
}
+
+ ret = sysfs_create_bin_file(&dev->primary->kdev.kobj,
+ &error_state_attr);
+ if (ret)
+ DRM_ERROR("error_state sysfs setup failed\n");
}
void i915_teardown_sysfs(struct drm_device *dev)
{
+ sysfs_remove_bin_file(&dev->primary->kdev.kobj, &error_state_attr);
sysfs_remove_files(&dev->primary->kdev.kobj, gen6_attrs);
device_remove_bin_file(&dev->primary->kdev, &dpf_attrs);
#ifdef CONFIG_PM
--
1.7.9.5
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 4/4] drm/i915: add i915_error_state sysfs entry
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
2 siblings, 0 replies; 11+ messages in thread
From: Chris Wilson @ 2013-06-06 12:22 UTC (permalink / raw)
To: Mika Kuoppala; +Cc: intel-gfx
On Thu, Jun 06, 2013 at 03:18:42PM +0300, Mika Kuoppala wrote:
> As getting error state doesn't anymore require big kmallocs,
> make error state accessible also from sysfs.
>
> Suggested-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com>
Don't forget the ability to clear an error-state in order to capture a
fresh one.
-Chris
--
Chris Wilson, Intel Open Source Technology Centre
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 4/4] drm/i915: add i915_error_state sysfs entry
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
2 siblings, 0 replies; 11+ messages in thread
From: Daniel Vetter @ 2013-06-06 12:24 UTC (permalink / raw)
To: Mika Kuoppala; +Cc: intel-gfx
On Thu, Jun 06, 2013 at 03:18:42PM +0300, Mika Kuoppala wrote:
> As getting error state doesn't anymore require big kmallocs,
> make error state accessible also from sysfs.
>
> Suggested-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com>
> ---
> drivers/gpu/drm/i915/i915_sysfs.c | 49 +++++++++++++++++++++++++++++++++++++
> 1 file changed, 49 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/i915_sysfs.c b/drivers/gpu/drm/i915/i915_sysfs.c
> index 6875b56..d4c754b 100644
> --- a/drivers/gpu/drm/i915/i915_sysfs.c
> +++ b/drivers/gpu/drm/i915/i915_sysfs.c
> @@ -409,6 +409,49 @@ static const struct attribute *gen6_attrs[] = {
> NULL,
> };
>
> +static ssize_t error_state_read(struct file *filp, struct kobject *kobj,
> + struct bin_attribute *attr, char *buf,
> + loff_t off, size_t count)
> +{
> +
> + struct device *kdev = container_of(kobj, struct device, kobj);
> + struct drm_minor *minor = container_of(kdev, struct drm_minor, kdev);
> + struct drm_device *dev = minor->dev;
> + struct i915_error_state_file_priv error_priv;
> + struct drm_i915_error_state_buf error_str;
> + ssize_t ret_count = 0;
> + int ret;
> +
> + memset(&error_priv, 0, sizeof(error_priv));
> +
> + ret = i915_error_state_buf_init(&error_str, count, off);
> + if (ret)
> + return ret;
> +
> + error_priv.dev = dev;
> + i915_error_state_get(dev, &error_priv);
> +
> + ret = i915_error_state_to_str(&error_str, &error_priv);
> + if (ret)
> + goto out;
> +
> + ret_count = count < error_str.bytes ? count : error_str.bytes;
> +
> + memcpy(buf, error_str.buf, ret_count);
> +out:
> + i915_error_state_buf_release(&error_str);
> + i915_error_state_put(&error_priv);
> +
> + return ret ?: ret_count;
> +}
> +
> +static struct bin_attribute error_state_attr = {
> + .attr.name = "i915_error_state",
> + .attr.mode = 0444,
Error state could easily leak sensitive information, so I think we should
only allow root to read it. Also maybe a new name for it, i915_ is kinda
meh ... I vote for gpu_error_state.
-Daniel
> + .size = 0,
> + .read = error_state_read,
> +};
> +
> void i915_setup_sysfs(struct drm_device *dev)
> {
> int ret;
> @@ -432,10 +475,16 @@ void i915_setup_sysfs(struct drm_device *dev)
> if (ret)
> DRM_ERROR("gen6 sysfs setup failed\n");
> }
> +
> + ret = sysfs_create_bin_file(&dev->primary->kdev.kobj,
> + &error_state_attr);
> + if (ret)
> + DRM_ERROR("error_state sysfs setup failed\n");
> }
>
> void i915_teardown_sysfs(struct drm_device *dev)
> {
> + sysfs_remove_bin_file(&dev->primary->kdev.kobj, &error_state_attr);
> sysfs_remove_files(&dev->primary->kdev.kobj, gen6_attrs);
> device_remove_bin_file(&dev->primary->kdev, &dpf_attrs);
> #ifdef CONFIG_PM
> --
> 1.7.9.5
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 4/4] drm/i915: add error_state sysfs entry
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 ` Mika Kuoppala
2013-06-06 13:48 ` Chris Wilson
2 siblings, 1 reply; 11+ messages in thread
From: Mika Kuoppala @ 2013-06-06 13:33 UTC (permalink / raw)
To: intel-gfx
As getting error state doesn't anymore require big kmallocs,
make error state accessible also from sysfs.
v2: - error state clearing (Chris Wilson)
- user hint, proper access mode bits and name (Daniel Vetter)
Suggested-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com>
---
drivers/gpu/drm/i915/i915_irq.c | 3 +-
drivers/gpu/drm/i915/i915_sysfs.c | 71 +++++++++++++++++++++++++++++++++++++
2 files changed, 72 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index 63996aa..22ed519 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -1881,8 +1881,7 @@ static void i915_capture_error_state(struct drm_device *dev)
}
DRM_INFO("capturing error event; look for more information in "
- "/sys/kernel/debug/dri/%d/i915_error_state\n",
- dev->primary->index);
+ "/sys/class/drm/card%d/error_state\n", dev->primary->index);
kref_init(&error->ref);
error->eir = I915_READ(EIR);
diff --git a/drivers/gpu/drm/i915/i915_sysfs.c b/drivers/gpu/drm/i915/i915_sysfs.c
index 6875b56..50416d1 100644
--- a/drivers/gpu/drm/i915/i915_sysfs.c
+++ b/drivers/gpu/drm/i915/i915_sysfs.c
@@ -409,6 +409,71 @@ static const struct attribute *gen6_attrs[] = {
NULL,
};
+static ssize_t error_state_read(struct file *filp, struct kobject *kobj,
+ struct bin_attribute *attr, char *buf,
+ loff_t off, size_t count)
+{
+
+ struct device *kdev = container_of(kobj, struct device, kobj);
+ struct drm_minor *minor = container_of(kdev, struct drm_minor, kdev);
+ struct drm_device *dev = minor->dev;
+ struct i915_error_state_file_priv error_priv;
+ struct drm_i915_error_state_buf error_str;
+ ssize_t ret_count = 0;
+ int ret;
+
+ memset(&error_priv, 0, sizeof(error_priv));
+
+ ret = i915_error_state_buf_init(&error_str, count, off);
+ if (ret)
+ return ret;
+
+ error_priv.dev = dev;
+ i915_error_state_get(dev, &error_priv);
+
+ ret = i915_error_state_to_str(&error_str, &error_priv);
+ if (ret)
+ goto out;
+
+ ret_count = count < error_str.bytes ? count : error_str.bytes;
+
+ memcpy(buf, error_str.buf, ret_count);
+out:
+ i915_error_state_buf_release(&error_str);
+ i915_error_state_put(&error_priv);
+
+ return ret ?: ret_count;
+}
+
+static ssize_t error_state_write(struct file *file, struct kobject *kobj,
+ struct bin_attribute *attr, char *buf,
+ loff_t off, size_t count)
+{
+ struct device *kdev = container_of(kobj, struct device, kobj);
+ struct drm_minor *minor = container_of(kdev, struct drm_minor, kdev);
+ struct drm_device *dev = minor->dev;
+ int ret;
+
+ DRM_DEBUG_DRIVER("Resetting error state\n");
+
+ ret = mutex_lock_interruptible(&dev->struct_mutex);
+ if (ret)
+ return ret;
+
+ i915_destroy_error_state(dev);
+ mutex_unlock(&dev->struct_mutex);
+
+ return count;
+}
+
+static struct bin_attribute error_state_attr = {
+ .attr.name = "error_state",
+ .attr.mode = S_IRUSR | S_IWUSR,
+ .size = 0,
+ .read = error_state_read,
+ .write = error_state_write,
+};
+
void i915_setup_sysfs(struct drm_device *dev)
{
int ret;
@@ -432,10 +497,16 @@ void i915_setup_sysfs(struct drm_device *dev)
if (ret)
DRM_ERROR("gen6 sysfs setup failed\n");
}
+
+ ret = sysfs_create_bin_file(&dev->primary->kdev.kobj,
+ &error_state_attr);
+ if (ret)
+ DRM_ERROR("error_state sysfs setup failed\n");
}
void i915_teardown_sysfs(struct drm_device *dev)
{
+ sysfs_remove_bin_file(&dev->primary->kdev.kobj, &error_state_attr);
sysfs_remove_files(&dev->primary->kdev.kobj, gen6_attrs);
device_remove_bin_file(&dev->primary->kdev, &dpf_attrs);
#ifdef CONFIG_PM
--
1.7.9.5
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 4/4] drm/i915: add error_state sysfs entry
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
0 siblings, 1 reply; 11+ messages in thread
From: Chris Wilson @ 2013-06-06 13:48 UTC (permalink / raw)
To: Mika Kuoppala; +Cc: intel-gfx
On Thu, Jun 06, 2013 at 04:33:06PM +0300, Mika Kuoppala wrote:
> As getting error state doesn't anymore require big kmallocs,
> make error state accessible also from sysfs.
>
> v2: - error state clearing (Chris Wilson)
> - user hint, proper access mode bits and name (Daniel Vetter)
>
> Suggested-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com>
> ---
> +static ssize_t error_state_read(struct file *filp, struct kobject *kobj,
> + struct bin_attribute *attr, char *buf,
> + loff_t off, size_t count)
> +{
> +
> + struct device *kdev = container_of(kobj, struct device, kobj);
> + struct drm_minor *minor = container_of(kdev, struct drm_minor, kdev);
> + struct drm_device *dev = minor->dev;
> + struct i915_error_state_file_priv error_priv;
> + struct drm_i915_error_state_buf error_str;
> + ssize_t ret_count = 0;
> + int ret;
> +
> + memset(&error_priv, 0, sizeof(error_priv));
> +
> + ret = i915_error_state_buf_init(&error_str, count, off);
> + if (ret)
> + return ret;
> +
> + error_priv.dev = dev;
> + i915_error_state_get(dev, &error_priv);
> +
> + ret = i915_error_state_to_str(&error_str, &error_priv);
> + if (ret)
> + goto out;
> +
> + ret_count = count < error_str.bytes ? count : error_str.bytes;
> +
> + memcpy(buf, error_str.buf, ret_count);
> +out:
> + i915_error_state_buf_release(&error_str);
> + i915_error_state_put(&error_priv);
Not quite oniony enough.
-Chris
--
Chris Wilson, Intel Open Source Technology Centre
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 4/4] drm/i915: add error_state sysfs entry
2013-06-06 13:48 ` Chris Wilson
@ 2013-06-06 14:38 ` Mika Kuoppala
2013-07-01 16:19 ` Chris Wilson
0 siblings, 1 reply; 11+ messages in thread
From: Mika Kuoppala @ 2013-06-06 14:38 UTC (permalink / raw)
To: intel-gfx
As getting error state doesn't anymore require big kmallocs,
make error state accessible also from sysfs.
v2: - error state clearing (Chris Wilson)
- user hint, proper access mode bits and name (Daniel Vetter)
v3: release resources in proper order (Chris Wilson)
Suggested-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com>
---
drivers/gpu/drm/i915/i915_irq.c | 3 +-
drivers/gpu/drm/i915/i915_sysfs.c | 71 +++++++++++++++++++++++++++++++++++++
2 files changed, 72 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index 63996aa..22ed519 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -1881,8 +1881,7 @@ static void i915_capture_error_state(struct drm_device *dev)
}
DRM_INFO("capturing error event; look for more information in "
- "/sys/kernel/debug/dri/%d/i915_error_state\n",
- dev->primary->index);
+ "/sys/class/drm/card%d/error_state\n", dev->primary->index);
kref_init(&error->ref);
error->eir = I915_READ(EIR);
diff --git a/drivers/gpu/drm/i915/i915_sysfs.c b/drivers/gpu/drm/i915/i915_sysfs.c
index 6875b56..ffaf5da 100644
--- a/drivers/gpu/drm/i915/i915_sysfs.c
+++ b/drivers/gpu/drm/i915/i915_sysfs.c
@@ -409,6 +409,71 @@ static const struct attribute *gen6_attrs[] = {
NULL,
};
+static ssize_t error_state_read(struct file *filp, struct kobject *kobj,
+ struct bin_attribute *attr, char *buf,
+ loff_t off, size_t count)
+{
+
+ struct device *kdev = container_of(kobj, struct device, kobj);
+ struct drm_minor *minor = container_of(kdev, struct drm_minor, kdev);
+ struct drm_device *dev = minor->dev;
+ struct i915_error_state_file_priv error_priv;
+ struct drm_i915_error_state_buf error_str;
+ ssize_t ret_count = 0;
+ int ret;
+
+ memset(&error_priv, 0, sizeof(error_priv));
+
+ ret = i915_error_state_buf_init(&error_str, count, off);
+ if (ret)
+ return ret;
+
+ error_priv.dev = dev;
+ i915_error_state_get(dev, &error_priv);
+
+ ret = i915_error_state_to_str(&error_str, &error_priv);
+ if (ret)
+ goto out;
+
+ ret_count = count < error_str.bytes ? count : error_str.bytes;
+
+ memcpy(buf, error_str.buf, ret_count);
+out:
+ i915_error_state_put(&error_priv);
+ i915_error_state_buf_release(&error_str);
+
+ return ret ?: ret_count;
+}
+
+static ssize_t error_state_write(struct file *file, struct kobject *kobj,
+ struct bin_attribute *attr, char *buf,
+ loff_t off, size_t count)
+{
+ struct device *kdev = container_of(kobj, struct device, kobj);
+ struct drm_minor *minor = container_of(kdev, struct drm_minor, kdev);
+ struct drm_device *dev = minor->dev;
+ int ret;
+
+ DRM_DEBUG_DRIVER("Resetting error state\n");
+
+ ret = mutex_lock_interruptible(&dev->struct_mutex);
+ if (ret)
+ return ret;
+
+ i915_destroy_error_state(dev);
+ mutex_unlock(&dev->struct_mutex);
+
+ return count;
+}
+
+static struct bin_attribute error_state_attr = {
+ .attr.name = "error_state",
+ .attr.mode = S_IRUSR | S_IWUSR,
+ .size = 0,
+ .read = error_state_read,
+ .write = error_state_write,
+};
+
void i915_setup_sysfs(struct drm_device *dev)
{
int ret;
@@ -432,10 +497,16 @@ void i915_setup_sysfs(struct drm_device *dev)
if (ret)
DRM_ERROR("gen6 sysfs setup failed\n");
}
+
+ ret = sysfs_create_bin_file(&dev->primary->kdev.kobj,
+ &error_state_attr);
+ if (ret)
+ DRM_ERROR("error_state sysfs setup failed\n");
}
void i915_teardown_sysfs(struct drm_device *dev)
{
+ sysfs_remove_bin_file(&dev->primary->kdev.kobj, &error_state_attr);
sysfs_remove_files(&dev->primary->kdev.kobj, gen6_attrs);
device_remove_bin_file(&dev->primary->kdev, &dpf_attrs);
#ifdef CONFIG_PM
--
1.7.9.5
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 4/4] drm/i915: add error_state sysfs entry
2013-06-06 14:38 ` Mika Kuoppala
@ 2013-07-01 16:19 ` Chris Wilson
2013-07-01 16:56 ` Daniel Vetter
0 siblings, 1 reply; 11+ messages in thread
From: Chris Wilson @ 2013-07-01 16:19 UTC (permalink / raw)
To: Mika Kuoppala; +Cc: intel-gfx
On Thu, Jun 06, 2013 at 05:38:54PM +0300, Mika Kuoppala wrote:
> As getting error state doesn't anymore require big kmallocs,
> make error state accessible also from sysfs.
>
> v2: - error state clearing (Chris Wilson)
> - user hint, proper access mode bits and name (Daniel Vetter)
>
> v3: release resources in proper order (Chris Wilson)
>
> Suggested-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com>
I am happy overall here. We could take the plunge and use this as an
excuse to move all the error-state string handling into a new file,
which would be useful for when we pull the hangcheck mechanism out of
i915_irq.c.
Perhaps the more pressing bikeshed is that after years of
i915_error_state, I'm tired of the name and think that the 'state' was
just redundant, so perhaps '/sys/class/drm/card0/error' is a nice
minimalist and modern looking name.
-Chris
--
Chris Wilson, Intel Open Source Technology Centre
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 4/4] drm/i915: add error_state sysfs entry
2013-07-01 16:19 ` Chris Wilson
@ 2013-07-01 16:56 ` Daniel Vetter
0 siblings, 0 replies; 11+ messages in thread
From: Daniel Vetter @ 2013-07-01 16:56 UTC (permalink / raw)
To: Chris Wilson, Mika Kuoppala, intel-gfx
On Mon, Jul 01, 2013 at 05:19:59PM +0100, Chris Wilson wrote:
> On Thu, Jun 06, 2013 at 05:38:54PM +0300, Mika Kuoppala wrote:
> > As getting error state doesn't anymore require big kmallocs,
> > make error state accessible also from sysfs.
> >
> > v2: - error state clearing (Chris Wilson)
> > - user hint, proper access mode bits and name (Daniel Vetter)
> >
> > v3: release resources in proper order (Chris Wilson)
> >
> > Suggested-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> > Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com>
>
> I am happy overall here. We could take the plunge and use this as an
> excuse to move all the error-state string handling into a new file,
> which would be useful for when we pull the hangcheck mechanism out of
> i915_irq.c.
>
> Perhaps the more pressing bikeshed is that after years of
> i915_error_state, I'm tired of the name and think that the 'state' was
> just redundant, so perhaps '/sys/class/drm/card0/error' is a nice
> minimalist and modern looking name.
Series merged with this bikeshed applied and your r-b from irc added.
Thanks, Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2013-07-01 16:56 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-06 12:18 [PATCH 1/4] drm/i915: export error state to string conversion Mika Kuoppala
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
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.