Skip to contentSkip to conversation

drm/i915: Add error_recovery option to i915_handle_error

PATCH In review Mika Kuoppala 3 participants 7 messages Oct 23, 2014 – Oct 30, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/3 drm/i915: Add error_recovery option to i915_handle_error

So that we gain more fine grained control how we want to do the recovery. The aim is to grab the gpu state and skip everything related to recovery.

---
 drivers/gpu/drm/i915/i915_drv.h |  9 ++++++++-
 drivers/gpu/drm/i915/i915_irq.c | 28 +++++++++++++++-------------
 2 files changed, 23 insertions(+), 14 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +8 -1
index 3212d62..23e7f20 100644
@@ -2288,8 +2288,15 @@ void intel_hpd_cancel_work(struct drm_i915_private *dev_priv);
 
 /* i915_irq.c */
 void i915_queue_hangcheck(struct drm_device *dev);
+
+enum recovery_type {
+	NO_RESET,
+	RESET,
+	DEBUGFS,
+};
+
 __printf(3, 4)
-void i915_handle_error(struct drm_device *dev, bool wedged,
+void i915_handle_error(struct drm_device *dev, enum recovery_type recovery,
 		       const char *fmt, ...);
 
 void gen6_set_pm_mask(struct drm_i915_private *dev_priv, u32 pm_iir,
drivers/gpu/drm/i915/i915_irq.c +15 -13
index a2b013d..21008a2 100644
@@ -1320,7 +1320,7 @@ static void snb_gt_irq_handler(struct drm_device *dev,
 	if (gt_iir & (GT_BLT_CS_ERROR_INTERRUPT |
 		      GT_BSD_CS_ERROR_INTERRUPT |
 		      GT_RENDER_CS_MASTER_ERROR_INTERRUPT)) {
-		i915_handle_error(dev, false, "GT error interrupt 0x%08x",
+		i915_handle_error(dev, NO_RESET, "GT error interrupt 0x%08x",
 				  gt_iir);
 	}
 
@@ -1716,7 +1716,7 @@ static void gen6_rps_irq_handler(struct drm_i915_private *dev_priv, u32 pm_iir)
 			notify_ring(dev_priv->dev, &dev_priv->ring[VECS]);
 
 		if (pm_iir & PM_VEBOX_CS_ERROR_INTERRUPT) {
-			i915_handle_error(dev_priv->dev, false,
+			i915_handle_error(dev_priv->dev, NO_RESET,
 					  "VEBOX CS error interrupt 0x%08x",
 					  pm_iir);
 		}
@@ -2548,7 +2548,7 @@ static void i915_report_and_clear_eir(struct drm_device *dev)
  * so userspace knows something bad happened (should trigger collection
  * of a ring dump etc.).
  */
-void i915_handle_error(struct drm_device *dev, bool wedged,
+void i915_handle_error(struct drm_device *dev, enum recovery_type recovery,
 		       const char *fmt, ...)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
@@ -2559,10 +2559,11 @@ void i915_handle_error(struct drm_device *dev, bool wedged,
 	vscnprintf(error_msg, sizeof(error_msg), fmt, args);
 	va_end(args);
 
-	i915_capture_error_state(dev, wedged, error_msg);
-	i915_report_and_clear_eir(dev);
+	i915_capture_error_state(dev, recovery == RESET, error_msg);
+	if (recovery != DEBUGFS)
+		i915_report_and_clear_eir(dev);
 
-	if (wedged) {
+	if (recovery == RESET) {
 		atomic_set_mask(I915_RESET_IN_PROGRESS_FLAG,
 				&dev_priv->gpu_error.reset_counter);
 
@@ -2588,7 +2589,8 @@ void i915_handle_error(struct drm_device *dev, bool wedged,
 	 * dev-priv->wq work queue for otherwise the flush_work in the pageflip
 	 * code will deadlock.
 	 */
-	schedule_work(&dev_priv->gpu_error.work);
+	if (recovery != DEBUGFS)
+		schedule_work(&dev_priv->gpu_error.work);
 }
 
 /* Called from drm generic code, passed 'crtc' which
@@ -2888,7 +2890,7 @@ ring_stuck(struct intel_engine_cs *ring, u64 acthd)
 	 */
 	tmp = I915_READ_CTL(ring);
 	if (tmp & RING_WAIT) {
-		i915_handle_error(dev, false,
+		i915_handle_error(dev, NO_RESET,
 				  "Kicking stuck wait on %s",
 				  ring->name);
 		I915_WRITE_CTL(ring, tmp);
@@ -2900,7 +2902,7 @@ ring_stuck(struct intel_engine_cs *ring, u64 acthd)
 		default:
 			return HANGCHECK_HUNG;
 		case 1:
-			i915_handle_error(dev, false,
+			i915_handle_error(dev, NO_RESET,
 					  "Kicking stuck semaphore on %s",
 					  ring->name);
 			I915_WRITE_CTL(ring, tmp);
@@ -3028,7 +3030,7 @@ static void i915_hangcheck_elapsed(unsigned long data)
 	}
 
 	if (rings_hung)
-		return i915_handle_error(dev, true, "Ring hung");
+		return i915_handle_error(dev, RESET, "Ring hung");
 
 	if (busy_count)
 		/* Reset timer case chip hangs without another request
@@ -3777,7 +3779,7 @@ static irqreturn_t i8xx_irq_handler(int irq, void *arg)
 		 */
 		spin_lock(&dev_priv->irq_lock);
 		if (iir & I915_RENDER_COMMAND_PARSER_ERROR_INTERRUPT)
-			i915_handle_error(dev, false,
+			i915_handle_error(dev, NO_RESET,
 					  "Command parser error, iir 0x%08x",
 					  iir);
 
@@ -3962,7 +3964,7 @@ static irqreturn_t i915_irq_handler(int irq, void *arg)
 		 */
 		spin_lock(&dev_priv->irq_lock);
 		if (iir & I915_RENDER_COMMAND_PARSER_ERROR_INTERRUPT)
-			i915_handle_error(dev, false,
+			i915_handle_error(dev, NO_RESET,
 					  "Command parser error, iir 0x%08x",
 					  iir);
 
@@ -4189,7 +4191,7 @@ static irqreturn_t i965_irq_handler(int irq, void *arg)
 		 */
 		spin_lock(&dev_priv->irq_lock);
 		if (iir & I915_RENDER_COMMAND_PARSER_ERROR_INTERRUPT)
-			i915_handle_error(dev, false,
+			i915_handle_error(dev, NO_RESET,
 					  "Command parser error, iir 0x%08x",
 					  iir);
 
Signature · 1 line
1.9.1
#1 lore raw

PATCH 2/3 drm/i915: Split the gpu (error) state generation

out from i915_capture_error_state so that it can be reused when we want to grab only the gpu state without any errors.

---
 drivers/gpu/drm/i915/i915_gpu_error.c | 41 +++++++++++++++++++++++------------
 1 file changed, 27 insertions(+), 14 deletions(-)
drivers/gpu/drm/i915/i915_gpu_error.c +27 -14
index e664599..c11882a 100644
@@ -1262,28 +1262,17 @@ static void i915_capture_gen_state(struct drm_i915_private *dev_priv,
 	error->suspend_count = dev_priv->suspend_count;
 }
 
-/**
- * i915_capture_error_state - capture an error record for later analysis
- * @dev: drm device
- *
- * Should be called when an error is detected (either a hang or an error
- * interrupt) to capture error state from the time of the error.  Fills
- * out a structure which becomes available in debugfs for user level tools
- * to pick up.
- */
-void i915_capture_error_state(struct drm_device *dev, bool wedged,
-			      const char *error_msg)
+static struct drm_i915_error_state *
+__i915_capture_gpu_state(struct drm_device *dev)
 {
-	static bool warned;
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct drm_i915_error_state *error;
-	unsigned long flags;
 
 	/* Account for pipe specific data like PIPE*STAT */
 	error = kzalloc(sizeof(*error), GFP_ATOMIC);
 	if (!error) {
 		DRM_DEBUG_DRIVER("out of memory, not capturing error state\n");
-		return;
+		return NULL;
 	}
 
 	kref_init(&error->ref);
@@ -1299,6 +1288,30 @@ void i915_capture_error_state(struct drm_device *dev, bool wedged,
 	error->overlay = intel_overlay_capture_error_state(dev);
 	error->display = intel_display_capture_error_state(dev);
 
+	return error;
+}
+
+/**
+ * i915_capture_error_state - capture an error record for later analysis
+ * @dev: drm device
+ *
+ * Should be called when an error is detected (either a hang or an error
+ * interrupt) to capture error state from the time of the error.  Fills
+ * out a structure which becomes available in debugfs for user level tools
+ * to pick up.
+ */
+void i915_capture_error_state(struct drm_device *dev, bool wedged,
+			      const char *error_msg)
+{
+	static bool warned;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	struct drm_i915_error_state *error;
+	unsigned long flags;
+
+	error = __i915_capture_gpu_state(dev);
+	if (error == NULL)
+		return;
+
 	i915_error_capture_msg(dev, error, wedged, error_msg);
 	DRM_INFO("%s\n", error->error_msg);
 
Signature · 1 line
1.9.1
#2 lore raw

PATCH 3/3 drm/i915: Grab gpu state through debugfs

In reply to Mika Kuoppala

because it is handy to direct bug reporters to do things like:
'grep -i suspend /sys/kernel/debug/dri/0/i915_gpu_state'

---
 drivers/gpu/drm/i915/i915_debugfs.c   | 42 +++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/i915_drv.h       |  4 ++++
 drivers/gpu/drm/i915/i915_gpu_error.c | 22 ++++++++++++++----
 3 files changed, 64 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +42 -0
index e60d5c2..8d3266d 100644
@@ -976,6 +976,47 @@ static const struct file_operations i915_error_state_fops = {
 	.release = i915_error_state_release,
 };
 
+static int i915_gpu_state_open(struct inode *inode, struct file *file)
+{
+	struct drm_device *dev = inode->i_private;
+	struct i915_error_state_file_priv *gpu_priv;
+
+	gpu_priv = kzalloc(sizeof(*gpu_priv), GFP_KERNEL);
+	if (!gpu_priv)
+		return -ENOMEM;
+
+	gpu_priv->dev = dev;
+
+	gpu_priv->error = i915_capture_gpu_state(dev);
+	if (gpu_priv->error == NULL) {
+		kfree(gpu_priv);
+		return -ENOMEM;
+	}
+
+	file->private_data = gpu_priv;
+
+	return 0;
+}
+
+static int i915_gpu_state_release(struct inode *inode, struct file *file)
+{
+	struct i915_error_state_file_priv *gpu_priv = file->private_data;
+
+	kref_put(&gpu_priv->error->ref, i915_gpu_state_free);
+	kfree(gpu_priv);
+
+	return 0;
+}
+
+static const struct file_operations i915_gpu_state_fops = {
+	.owner = THIS_MODULE,
+	.open = i915_gpu_state_open,
+	.read = i915_error_state_read,
+	.write = NULL,
+	.llseek = default_llseek,
+	.release = i915_gpu_state_release,
+};
+
 static int
 i915_next_seqno_get(void *data, u64 *val)
 {
@@ -4217,6 +4258,7 @@ static const struct i915_debugfs_files {
 	{"i915_ring_test_irq", &i915_ring_test_irq_fops},
 	{"i915_gem_drop_caches", &i915_drop_caches_fops},
 	{"i915_error_state", &i915_error_state_fops},
+	{"i915_gpu_state", &i915_gpu_state_fops},
 	{"i915_next_seqno", &i915_next_seqno_fops},
 	{"i915_display_crc_ctl", &i915_display_crc_ctl_fops},
 	{"i915_pri_wm_latency", &i915_pri_wm_latency_fops},
drivers/gpu/drm/i915/i915_drv.h +4 -0
index 23e7f20..cbefc64 100644
@@ -2756,6 +2756,10 @@ static inline void i915_error_state_buf_release(
 {
 	kfree(eb->buf);
 }
+
+struct drm_i915_error_state *i915_capture_gpu_state(struct drm_device *dev);
+void i915_gpu_state_free(struct kref *error_ref);
+
 void i915_capture_error_state(struct drm_device *dev, bool wedge,
 			      const char *error_msg);
 void i915_error_state_get(struct drm_device *dev,
drivers/gpu/drm/i915/i915_gpu_error.c +18 -4
index c11882a..76211b5 100644
@@ -538,7 +538,7 @@ static void i915_error_object_free(struct drm_i915_error_object *obj)
 	kfree(obj);
 }
 
-static void i915_error_state_free(struct kref *error_ref)
+void i915_gpu_state_free(struct kref *error_ref)
 {
 	struct drm_i915_error_state *error = container_of(error_ref,
 							  typeof(*error), ref);
@@ -1291,6 +1291,20 @@ __i915_capture_gpu_state(struct drm_device *dev)
 	return error;
 }
 
+struct drm_i915_error_state *i915_capture_gpu_state(struct drm_device *dev)
+{
+	struct drm_i915_error_state *gpu_state;
+
+	gpu_state = __i915_capture_gpu_state(dev);
+	if (gpu_state == NULL)
+		return NULL;
+
+	scnprintf(gpu_state->error_msg, sizeof(gpu_state->error_msg),
+		  "GPU state snapshot\n");
+
+	return gpu_state;
+}
+
 /**
  * i915_capture_error_state - capture an error record for later analysis
  * @dev: drm device
@@ -1323,7 +1337,7 @@ void i915_capture_error_state(struct drm_device *dev, bool wedged,
 	spin_unlock_irqrestore(&dev_priv->gpu_error.lock, flags);
 
 	if (error) {
-		i915_error_state_free(&error->ref);
+		i915_gpu_state_free(&error->ref);
 		return;
 	}
 
@@ -1353,7 +1367,7 @@ void i915_error_state_get(struct drm_device *dev,
 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);
+		kref_put(&error_priv->error->ref, i915_gpu_state_free);
 }
 
 void i915_destroy_error_state(struct drm_device *dev)
@@ -1367,7 +1381,7 @@ void i915_destroy_error_state(struct drm_device *dev)
 	spin_unlock_irq(&dev_priv->gpu_error.lock);
 
 	if (error)
-		kref_put(&error->ref, i915_error_state_free);
+		kref_put(&error->ref, i915_gpu_state_free);
 }
 
 const char *i915_cache_level_str(struct drm_i915_private *i915, int type)
Signature · 1 line
1.9.1
#3 lore raw

Re: [PATCH 3/3] drm/i915: Grab gpu state through debugfs

Quoted 35 lines · Mika Kuoppala

because it is handy to direct bug reporters to do things like:
'grep -i suspend /sys/kernel/debug/dri/0/i915_gpu_state'

---
 drivers/gpu/drm/i915/i915_debugfs.c   | 42 +++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/i915_drv.h       |  4 ++++
 drivers/gpu/drm/i915/i915_gpu_error.c | 22 ++++++++++++++----
 3 files changed, 64 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +17 -0
index e60d5c2..8d3266d 100644
@@ -976,6 +976,47 @@ static const struct file_operations i915_error_state_fops = {
 	.release = i915_error_state_release,
 };
 
+static int i915_gpu_state_open(struct inode *inode, struct file *file)
+{
+	struct drm_device *dev = inode->i_private;
+	struct i915_error_state_file_priv *gpu_priv;
+
+	gpu_priv = kzalloc(sizeof(*gpu_priv), GFP_KERNEL);
+	if (!gpu_priv)
+		return -ENOMEM;
+
+	gpu_priv->dev = dev;
+
+	gpu_priv->error = i915_capture_gpu_state(dev);
+	if (gpu_priv->error == NULL) {
+		kfree(gpu_priv);
+		return -ENOMEM;
+	}
+

drivers/gpu/drm/i915/i915_debugfs.c static const struct file_operations i915_error_state_fops = { · line 1005

Quoted 10 lines
drivers/gpu/drm/i915/i915_debugfs.c +10 -0
+	file->private_data = gpu_priv;
+
+	return 0;
+}
+
+static int i915_gpu_state_release(struct inode *inode, struct file *file)
+{
+	struct i915_error_state_file_priv *gpu_priv = file->private_data;
+
+	kref_put(&gpu_priv->error->ref, i915_gpu_state_free);

A little bit of syntactic sugar here, and you can have my reviewed-by.

static inline void i915_error_state_put(struct drm_i915_error_state *err)

{
	kref_put(&err->ref, __i915_error_state_free);
}

I do agree that i915_gpu_state is a better name than i915_error_state. Another patch for a rainy day without intelskitchen.com? -Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
#4 lore raw

Re: [PATCH 3/3] drm/i915: Grab gpu state through debugfs

In reply to Mika Kuoppala
Quoted 99 lines · Mika Kuoppala

because it is handy to direct bug reporters to do things like:
'grep -i suspend /sys/kernel/debug/dri/0/i915_gpu_state'

---
 drivers/gpu/drm/i915/i915_debugfs.c   | 42 +++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/i915_drv.h       |  4 ++++
 drivers/gpu/drm/i915/i915_gpu_error.c | 22 ++++++++++++++----
 3 files changed, 64 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +42 -0
index e60d5c2..8d3266d 100644
@@ -976,6 +976,47 @@ static const struct file_operations i915_error_state_fops = {
 	.release = i915_error_state_release,
 };
 
+static int i915_gpu_state_open(struct inode *inode, struct file *file)
+{
+	struct drm_device *dev = inode->i_private;
+	struct i915_error_state_file_priv *gpu_priv;
+
+	gpu_priv = kzalloc(sizeof(*gpu_priv), GFP_KERNEL);
+	if (!gpu_priv)
+		return -ENOMEM;
+
+	gpu_priv->dev = dev;
+
+	gpu_priv->error = i915_capture_gpu_state(dev);
+	if (gpu_priv->error == NULL) {
+		kfree(gpu_priv);
+		return -ENOMEM;
+	}
+
+	file->private_data = gpu_priv;
+
+	return 0;
+}
+
+static int i915_gpu_state_release(struct inode *inode, struct file *file)
+{
+	struct i915_error_state_file_priv *gpu_priv = file->private_data;
+
+	kref_put(&gpu_priv->error->ref, i915_gpu_state_free);
+	kfree(gpu_priv);
+
+	return 0;
+}
+
+static const struct file_operations i915_gpu_state_fops = {
+	.owner = THIS_MODULE,
+	.open = i915_gpu_state_open,
+	.read = i915_error_state_read,
+	.write = NULL,
+	.llseek = default_llseek,
+	.release = i915_gpu_state_release,
+};
+
 static int
 i915_next_seqno_get(void *data, u64 *val)
 {
@@ -4217,6 +4258,7 @@ static const struct i915_debugfs_files {
 	{"i915_ring_test_irq", &i915_ring_test_irq_fops},
 	{"i915_gem_drop_caches", &i915_drop_caches_fops},
 	{"i915_error_state", &i915_error_state_fops},
+	{"i915_gpu_state", &i915_gpu_state_fops},
 	{"i915_next_seqno", &i915_next_seqno_fops},
 	{"i915_display_crc_ctl", &i915_display_crc_ctl_fops},
 	{"i915_pri_wm_latency", &i915_pri_wm_latency_fops},
drivers/gpu/drm/i915/i915_drv.h +4 -0
index 23e7f20..cbefc64 100644
@@ -2756,6 +2756,10 @@ static inline void i915_error_state_buf_release(
 {
 	kfree(eb->buf);
 }
+
+struct drm_i915_error_state *i915_capture_gpu_state(struct drm_device *dev);
+void i915_gpu_state_free(struct kref *error_ref);
+
 void i915_capture_error_state(struct drm_device *dev, bool wedge,
 			      const char *error_msg);
 void i915_error_state_get(struct drm_device *dev,
drivers/gpu/drm/i915/i915_gpu_error.c +1 -1
index c11882a..76211b5 100644
@@ -538,7 +538,7 @@ static void i915_error_object_free(struct drm_i915_error_object *obj)
 	kfree(obj);
 }
 
-static void i915_error_state_free(struct kref *error_ref)
+void i915_gpu_state_free(struct kref *error_ref)
 {
 	struct drm_i915_error_state *error = container_of(error_ref,
 							  typeof(*error), ref);

drivers/gpu/drm/i915/i915_gpu_error.c __i915_capture_gpu_state(struct drm_device *dev) · line 1294

Quoted 4 lines
drivers/gpu/drm/i915/i915_gpu_error.c +1 -0
@@ -1291,6 +1291,20 @@ __i915_capture_gpu_state(struct drm_device *dev)
 	return error;
 }
 
+struct drm_i915_error_state *i915_capture_gpu_state(struct drm_device *dev)

kerneldoc for this new non-static function is missing. -Daniel

Quoted 50 lines
drivers/gpu/drm/i915/i915_gpu_error.c +16 -3
+{
+	struct drm_i915_error_state *gpu_state;
+
+	gpu_state = __i915_capture_gpu_state(dev);
+	if (gpu_state == NULL)
+		return NULL;
+
+	scnprintf(gpu_state->error_msg, sizeof(gpu_state->error_msg),
+		  "GPU state snapshot\n");
+
+	return gpu_state;
+}
+
 /**
  * i915_capture_error_state - capture an error record for later analysis
  * @dev: drm device
@@ -1323,7 +1337,7 @@ void i915_capture_error_state(struct drm_device *dev, bool wedged,
 	spin_unlock_irqrestore(&dev_priv->gpu_error.lock, flags);
 
 	if (error) {
-		i915_error_state_free(&error->ref);
+		i915_gpu_state_free(&error->ref);
 		return;
 	}
 
@@ -1353,7 +1367,7 @@ void i915_error_state_get(struct drm_device *dev,
 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);
+		kref_put(&error_priv->error->ref, i915_gpu_state_free);
 }
 
 void i915_destroy_error_state(struct drm_device *dev)
@@ -1367,7 +1381,7 @@ void i915_destroy_error_state(struct drm_device *dev)
 	spin_unlock_irq(&dev_priv->gpu_error.lock);
 
 	if (error)
-		kref_put(&error->ref, i915_error_state_free);
+		kref_put(&error->ref, i915_gpu_state_free);
 }
 
 const char *i915_cache_level_str(struct drm_i915_private *i915, int type)
Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#5 lore raw
In reply to Mika Kuoppala
Quoted 3 lines · Mika Kuoppala

So that we gain more fine grained control how we want to do the recovery. The aim is to grab the gpu state and skip everything related to recovery.

Can you please explain what it is you want to accomplish? If you only want to do part of i915_handle_error() would it not be better to call a different function, or just the functions that did what you want? -Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
#6 lore raw
Quoted 8 lines · Chris Wilson
Quoted 3 lines · Mika Kuoppala

So that we gain more fine grained control how we want to do the recovery. The aim is to grab the gpu state and skip everything related to recovery.

Can you please explain what it is you want to accomplish? If you only want to do part of i915_handle_error() would it not be better to call a different function, or just the functions that did what you want?

This patch makes no sense at all. Sorry for time wasted.

-Mika

Quoted 4 lines

-Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx