[Intel-gfx] [PATCH] drm/i915: Flush idle work when changing missed-irq fault injection

Chris Wilson chris at chris-wilson.co.uk
Mon Mar 6 09:57:26 UTC 2017


In order for the missed-irq update to take effect, the device must be
idle. So when the user updates the fault injection via debugfs, idle the
device.

Testcase: igt/drv_missed_irq
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/i915_debugfs.c | 29 ++++++++++++++++++++++++-----
 1 file changed, 24 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
index 4a3e5b9552f8..9b769ee231e9 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -4151,16 +4151,35 @@ i915_ring_missed_irq_set(void *data, u64 val)
 {
 	struct drm_i915_private *dev_priv = data;
 	struct drm_device *dev = &dev_priv->drm;
-	int ret;
+	int err;
+
+	err = mutex_lock_interruptible(&dev->struct_mutex);
+	if (err)
+		return err;
+
+	err = i915_gem_wait_for_idle(dev_priv,
+				     I915_WAIT_LOCKED |
+				     I915_WAIT_INTERRUPTIBLE);
+	if (err)
+		goto err_unlock;
+
+	/* Retire to kick idle work */
+	i915_gem_retire_requests(dev_priv);
+	GEM_BUG_ON(dev_priv->gt.active_requests);
 
-	/* Lock against concurrent debugfs callers */
-	ret = mutex_lock_interruptible(&dev->struct_mutex);
-	if (ret)
-		return ret;
 	dev_priv->gpu_error.missed_irq_rings = val;
 	mutex_unlock(&dev->struct_mutex);
 
+	/* Flush idle worker to disarm irq */
+	while (flush_delayed_work(&dev_priv->gt.idle_work))
+		;
+
+
 	return 0;
+
+err_unlock:
+	mutex_unlock(&dev->struct_mutex);
+	return err;
 }
 
 DEFINE_SIMPLE_ATTRIBUTE(i915_ring_missed_irq_fops,
-- 
2.11.0



More information about the Intel-gfx mailing list