[PATCH 2/3] drm/i915: Take runtime pm wakelock during hangcheck

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx>

During hangcheck we access the hardware registers, for which we must
hold a runtime pm reference. Hangcheck also should only be running
whilst the GPU is active, and we hold a runtime pm whilst the GPU is
busy. Therefore, if the runtime pm is suspended (no wakelocks held
anywhere) we know the GPU is already idle and we can skip the hangcheck
(and all further hangchecks until the next request is submitted to the
GPU, waking it up).

Currently, hangcheck relies upon being flushed during
intel_runtime_suspend() but is being done so too late causing invalid
hardware access whilst the device is being suspend. By taking an
explicit wakelock (albeit only if already awake) inside hangcheck we can
remove the synchronous cancellation from the suspend function.

v2:
- Actually make the code work (Joonas)
- Use previously introduced pm_runtime_get_noidle instead of directly
  touching PM object internals (Joonas)

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=93121
Signed-off-by: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx>
Signed-off-by: Joonas Lahtinen <joonas.lahtinen@xxxxxxxxxxxxxxx>
Cc: Imre Deak <imre.deak@xxxxxxxxx>
---
 drivers/gpu/drm/i915/i915_irq.c         |  9 +++++++++
 drivers/gpu/drm/i915/intel_drv.h        |  1 +
 drivers/gpu/drm/i915/intel_runtime_pm.c | 23 +++++++++++++++++++++++
 3 files changed, 33 insertions(+)

diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index e88d692..6c20d5b 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -2989,6 +2989,13 @@ static void i915_hangcheck_elapsed(struct work_struct *work)
 	if (!i915.enable_hangcheck)
 		return;
 
+	/* If the runtime pm is off, then the GPU is asleep and we are
+	 * completely idle, so we can belatedly cancel hangcheck. Hangcheck
+	 * will be restarted on the next request.
+	 */
+	if (!intel_runtime_get_noidle(dev_priv))
+		return;
+
 	for_each_ring(ring, dev_priv, i) {
 		u64 acthd;
 		u32 seqno;
@@ -3080,6 +3087,8 @@ static void i915_hangcheck_elapsed(struct work_struct *work)
 		}
 	}
 
+	intel_runtime_pm_put(dev_priv);
+
 	if (rings_hung)
 		return i915_handle_error(dev, true, "Ring hung");
 
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 8963a8a..022e612 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -1429,6 +1429,7 @@ void intel_display_power_put(struct drm_i915_private *dev_priv,
 			     enum intel_display_power_domain domain);
 void intel_runtime_pm_get(struct drm_i915_private *dev_priv);
 void intel_runtime_pm_get_noresume(struct drm_i915_private *dev_priv);
+bool intel_runtime_pm_get_noidle(struct drm_i915_private *dev_priv);
 void intel_runtime_pm_put(struct drm_i915_private *dev_priv);
 
 void intel_display_set_init_power(struct drm_i915_private *dev, bool enable);
diff --git a/drivers/gpu/drm/i915/intel_runtime_pm.c b/drivers/gpu/drm/i915/intel_runtime_pm.c
index 2c2151f..950e960 100644
--- a/drivers/gpu/drm/i915/intel_runtime_pm.c
+++ b/drivers/gpu/drm/i915/intel_runtime_pm.c
@@ -2263,6 +2263,29 @@ void intel_runtime_pm_get_noresume(struct drm_i915_private *dev_priv)
 }
 
 /**
+ * intel_runtime_pm_get_noidle - grab a runtime pm reference if not idle
+ * @dev_priv: i915 device instance
+ *
+ * This function grabs a device-level runtime pm reference if it the device
+ * is not idle.
+ *
+ * Any successful call must have a symmetric call to intel_runtime_pm_put()
+ * to release the reference.
+ *
+ * See intel_runtime_pm_get() for more.
+ */
+bool intel_runtime_pm_get_noidle(struct drm_i915_private *dev_priv)
+{
+	struct drm_device *dev = dev_priv->dev;
+	struct device *device = &dev->pdev->dev;
+
+	if (!HAS_RUNTIME_PM(dev))
+		return true;
+
+	return !!pm_runtime_get_noidle(device);
+}
+
+/**
  * intel_runtime_pm_put - release a runtime pm reference
  * @dev_priv: i915 device instance
  *
-- 
2.4.3

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux