All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
To: Intel graphics driver community testing & development
	<intel-gfx@lists.freedesktop.org>
Subject: [PATCH 2/3] drm/i915: Take runtime pm wakelock during hangcheck
Date: Wed,  9 Dec 2015 17:45:19 +0200	[thread overview]
Message-ID: <1449675920-12986-2-git-send-email-joonas.lahtinen@linux.intel.com> (raw)
In-Reply-To: <1449675920-12986-1-git-send-email-joonas.lahtinen@linux.intel.com>

From: Chris Wilson <chris@chris-wilson.co.uk>

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@chris-wilson.co.uk>
Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Imre Deak <imre.deak@intel.com>
---
 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@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2015-12-09 15:45 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-09 15:45 [PATCH 1/3] PM / Runtime: Introduce pm_runtime_get_noidle Joonas Lahtinen
2015-12-09 15:45 ` Joonas Lahtinen [this message]
2015-12-09 15:45 ` [PATCH 3/3] drm/i915: Do not cancel hangcheck prior to runtime suspend Joonas Lahtinen
2015-12-09 16:22 ` [PATCH v2] PM / Runtime: Introduce pm_runtime_get_noidle Joonas Lahtinen
2015-12-10  0:58   ` Rafael J. Wysocki
2015-12-10  9:43     ` [Intel-gfx] " Imre Deak
2015-12-10 21:36       ` Rafael J. Wysocki
2015-12-10 21:42         ` Rafael J. Wysocki
2015-12-10 21:20           ` Imre Deak
2015-12-10 22:14             ` Rafael J. Wysocki
2015-12-11 11:08               ` Dave Gordon
2015-12-11 12:03               ` Ulf Hansson
2015-12-11 15:13                 ` Rafael J. Wysocki
2015-12-11 15:59                   ` Ulf Hansson
2015-12-11 23:37                     ` Rafael J. Wysocki
2015-12-11 12:54               ` Imre Deak
2015-12-11 15:40                 ` [Intel-gfx] " Rafael J. Wysocki
2015-12-11 15:47                   ` Imre Deak
2015-12-11 23:21                     ` Rafael J. Wysocki
2015-12-11 23:41                       ` Rafael J. Wysocki
2015-12-12  1:51                         ` Rafael J. Wysocki
2015-12-12 19:40                           ` Imre Deak
2015-12-12 19:49                             ` Chris Wilson
2015-12-14  2:04                               ` Rafael J. Wysocki
2015-12-14 22:22                               ` [PATCH] PM / runtime: Add new helper for conditional usage count incrementation Rafael J. Wysocki
2015-12-15 10:21                                 ` Joonas Lahtinen
2015-12-15 14:28                                 ` Ulf Hansson
2015-12-16  3:10                                   ` Rafael J. Wysocki
2015-12-15 15:06                                 ` Alan Stern
2015-12-16  3:11                                   ` Rafael J. Wysocki
2015-12-17  1:54                                 ` [PATCH v2] " Rafael J. Wysocki
2015-12-17  9:03                                   ` Ulf Hansson

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=1449675920-12986-2-git-send-email-joonas.lahtinen@linux.intel.com \
    --to=joonas.lahtinen@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 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.