All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Weinehall <david.weinehall@linux.intel.com>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH 3/3] drm/i915: optimise intel_runtime_pm_{get, put}
Date: Fri, 18 Nov 2016 12:06:03 +0200	[thread overview]
Message-ID: <20161118100603.14284-4-david.weinehall@linux.intel.com> (raw)
In-Reply-To: <20161118100603.14284-1-david.weinehall@linux.intel.com>

Benchmarking shows that on resume we spend quite a bit of time
just taking and dropping these references, leaving us two options;
either rewriting the code not to take these references more than
once, which would be a rather invasive change since the involved
functions are used from other places, or to optimise
intel_runtime_pm_{get,put}().  This patch does the latter.
Initial benchmarking indicate improvements of a couple
of milliseconds on resume.

Original patch by Chris, with slight fixes by me.

Signed-off-by: David Weinehall <david.weinehall@linux.intel.com>
CC: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/intel_runtime_pm.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/gpu/drm/i915/intel_runtime_pm.c b/drivers/gpu/drm/i915/intel_runtime_pm.c
index 356c662ad453..4bf279023b39 100644
--- a/drivers/gpu/drm/i915/intel_runtime_pm.c
+++ b/drivers/gpu/drm/i915/intel_runtime_pm.c
@@ -2632,6 +2632,9 @@ void intel_runtime_pm_get(struct drm_i915_private *dev_priv)
 	struct pci_dev *pdev = dev_priv->drm.pdev;
 	struct device *kdev = &pdev->dev;
 
+	if (atomic_inc_not_zero(&dev_priv->pm.wakeref_count))
+		return;
+
 	pm_runtime_get_sync(kdev);
 
 	atomic_inc(&dev_priv->pm.wakeref_count);
@@ -2653,6 +2656,9 @@ bool intel_runtime_pm_get_if_in_use(struct drm_i915_private *dev_priv)
 	struct pci_dev *pdev = dev_priv->drm.pdev;
 	struct device *kdev = &pdev->dev;
 
+	if (atomic_inc_not_zero(&dev_priv->pm.wakeref_count))
+		return;
+
 	if (IS_ENABLED(CONFIG_PM)) {
 		int ret = pm_runtime_get_if_in_use(kdev);
 
@@ -2695,6 +2701,9 @@ void intel_runtime_pm_get_noresume(struct drm_i915_private *dev_priv)
 	struct pci_dev *pdev = dev_priv->drm.pdev;
 	struct device *kdev = &pdev->dev;
 
+	if (atomic_inc_not_zero(&dev_priv->pm.wakeref_count))
+		return;
+
 	assert_rpm_wakelock_held(dev_priv);
 	pm_runtime_get_noresume(kdev);
 
@@ -2714,6 +2723,9 @@ void intel_runtime_pm_put(struct drm_i915_private *dev_priv)
 	struct pci_dev *pdev = dev_priv->drm.pdev;
 	struct device *kdev = &pdev->dev;
 
+	if (!atomic_dec_and_test(&dev_priv->pm.wakeref_count))
+		return;
+
 	assert_rpm_wakelock_held(dev_priv);
 	atomic_dec(&dev_priv->pm.wakeref_count);
 
-- 
2.10.2

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

  parent reply	other threads:[~2016-11-18 10:10 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-18 10:06 [PATCH 0/3] Resume time optimisation David Weinehall
2016-11-18 10:06 ` [PATCH 1/3] drm/i915: Cleanup i915_gem_restore_gtt_mappings() David Weinehall
2016-11-18 10:37   ` Daniel Vetter
2016-11-18 10:45   ` Chris Wilson
2016-11-18 10:06 ` [PATCH 2/3] drm/i915: Take runtime pm in i915_gem_resume() David Weinehall
2016-11-18 10:47   ` Chris Wilson
2016-11-18 10:06 ` David Weinehall [this message]
2016-11-18 10:37   ` [PATCH 3/3] drm/i915: optimise intel_runtime_pm_{get, put} Chris Wilson
2016-11-18 11:15     ` David Weinehall
2016-11-18 12:21   ` kbuild test robot
2016-11-18 10:31 ` ✗ Fi.CI.BAT: failure for Resume time optimisation Patchwork

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=20161118100603.14284-4-david.weinehall@linux.intel.com \
    --to=david.weinehall@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.