All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Wilson <chris@chris-wilson.co.uk>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH v2 09/11] drm/i915: Merge sandybride_pcode_(read|write)
Date: Mon, 15 Jan 2018 08:47:21 +0000	[thread overview]
Message-ID: <20180115084723.2221-10-chris@chris-wilson.co.uk> (raw)
In-Reply-To: <20180115084723.2221-1-chris@chris-wilson.co.uk>

These routines are identical except in the nature of the value parameter.
For writes it is a pure in-param, but for a read, we need an out-param.
Since they differ in a single line, merge the two routines into one.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/intel_pm.c | 51 ++++++++---------------------------------
 1 file changed, 10 insertions(+), 41 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
index 7e66917a6564..18945264b835 100644
--- a/drivers/gpu/drm/i915/intel_pm.c
+++ b/drivers/gpu/drm/i915/intel_pm.c
@@ -9125,13 +9125,15 @@ static inline int gen7_check_mailbox_status(struct drm_i915_private *dev_priv)
 	}
 }
 
-static int __sandybridge_pcode_read(struct drm_i915_private *dev_priv, u32 mbox, u32 *val)
+static int __sandybridge_pcode_rw(struct drm_i915_private *dev_priv,
+				  u32 mbox, u32 *val, bool is_read)
 {
 	int status;
 
 	lockdep_assert_held(&dev_priv->sb_lock);
 
-	/* GEN6_PCODE_* are outside of the forcewake domain, we can
+	/*
+	 * GEN6_PCODE_* are outside of the forcewake domain, we can
 	 * use te fw I915_READ variants to reduce the amount of work
 	 * required when reading/writing.
 	 */
@@ -9148,7 +9150,8 @@ static int __sandybridge_pcode_read(struct drm_i915_private *dev_priv, u32 mbox,
 					 500, 0, NULL))
 		return -ETIMEDOUT;
 
-	*val = I915_READ_FW(GEN6_PCODE_DATA);
+	if (is_read)
+		*val = I915_READ_FW(GEN6_PCODE_DATA);
 	I915_WRITE_FW(GEN6_PCODE_DATA, 0);
 
 	if (INTEL_GEN(dev_priv) > 6)
@@ -9164,7 +9167,7 @@ int sandybridge_pcode_read(struct drm_i915_private *dev_priv, u32 mbox, u32 *val
 	int status;
 
 	mutex_lock(&dev_priv->sb_lock);
-	status = __sandybridge_pcode_read(dev_priv, mbox, val);
+	status = __sandybridge_pcode_rw(dev_priv, mbox, val, true);
 	mutex_unlock(&dev_priv->sb_lock);
 
 	if (status) {
@@ -9175,45 +9178,13 @@ int sandybridge_pcode_read(struct drm_i915_private *dev_priv, u32 mbox, u32 *val
 	return status;
 }
 
-static int __sandybridge_pcode_write(struct drm_i915_private *dev_priv,
-				     u32 mbox, u32 val)
-{
-	int status;
-
-	/* GEN6_PCODE_* are outside of the forcewake domain, we can
-	 * use te fw I915_READ variants to reduce the amount of work
-	 * required when reading/writing.
-	 */
-
-	if (I915_READ_FW(GEN6_PCODE_MAILBOX) & GEN6_PCODE_READY)
-		return -EAGAIN;
-
-	I915_WRITE_FW(GEN6_PCODE_DATA, val);
-	I915_WRITE_FW(GEN6_PCODE_DATA1, 0);
-	I915_WRITE_FW(GEN6_PCODE_MAILBOX, GEN6_PCODE_READY | mbox);
-
-	if (__intel_wait_for_register_fw(dev_priv,
-					 GEN6_PCODE_MAILBOX, GEN6_PCODE_READY, 0,
-					 500, 0, NULL))
-		return -ETIMEDOUT;
-
-	I915_WRITE_FW(GEN6_PCODE_DATA, 0);
-
-	if (INTEL_GEN(dev_priv) > 6)
-		status = gen7_check_mailbox_status(dev_priv);
-	else
-		status = gen6_check_mailbox_status(dev_priv);
-
-	return status;
-}
-
 int sandybridge_pcode_write(struct drm_i915_private *dev_priv,
 			    u32 mbox, u32 val)
 {
 	int status;
 
 	mutex_lock(&dev_priv->sb_lock);
-	status = __sandybridge_pcode_write(dev_priv, mbox, val);
+	status = __sandybridge_pcode_rw(dev_priv, mbox, &val, false);
 	mutex_unlock(&dev_priv->sb_lock);
 
 	if (status) {
@@ -9228,11 +9199,9 @@ static bool skl_pcode_try_request(struct drm_i915_private *dev_priv, u32 mbox,
 				  u32 request, u32 reply_mask, u32 reply,
 				  u32 *status)
 {
-	u32 val = request;
-
-	*status = __sandybridge_pcode_read(dev_priv, mbox, &val);
+	*status = __sandybridge_pcode_rw(dev_priv, mbox, &request, true);
 
-	return *status || ((val & reply_mask) == reply);
+	return *status || ((request & reply_mask) == reply);
 }
 
 /**
-- 
2.15.1

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

  parent reply	other threads:[~2018-01-15  8:47 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-15  8:47 Vlv punit w/a (take two) Chris Wilson
2018-01-15  8:47 ` [PATCH v2 01/11] drm/i915: Disable preemption and sleeping while using the punit sideband Chris Wilson
2018-01-15 12:04   ` Mika Kuoppala
2018-01-15 12:13     ` Chris Wilson
2018-01-16 15:27       ` Mika Kuoppala
2018-01-15 12:21     ` Chris Wilson
2018-01-15 13:07       ` Hans de Goede
2018-01-15 13:43       ` Mika Kuoppala
2018-01-22 12:54     ` Chris Wilson
2018-01-15  8:47 ` [PATCH v2 02/11] drm/i915: Lift acquiring the vlv punit magic to a common sb-get Chris Wilson
2018-01-15 10:36   ` Mika Kuoppala
2018-01-15  8:47 ` [PATCH v2 03/11] drm/i915: Lift sideband locking for vlv_punit_(read|write) Chris Wilson
2018-01-15  8:47 ` [PATCH v2 04/11] drm/i915: Reduce RPS update frequency on Valleyview/Cherryview Chris Wilson
2018-01-15  8:47 ` [PATCH v2 05/11] Revert "drm/i915: Avoid tweaking evaluation thresholds on Baytrail v3" Chris Wilson
2018-01-15  8:47 ` [PATCH v2 06/11] drm/i915: Replace pcu_lock with sb_lock Chris Wilson
2018-01-15  8:47 ` [PATCH v2 07/11] drm/i915: Separate sideband declarations to intel_sideband.h Chris Wilson
2018-01-15  8:47 ` [PATCH v2 08/11] drm/i915: Merge sbi read/write into a single accessor Chris Wilson
2018-01-15  8:47 ` Chris Wilson [this message]
2018-01-15  8:47 ` [PATCH v2 10/11] drm/i915: Move sandybride pcode access to intel_sideband.c Chris Wilson
2018-01-19  8:21   ` Mika Kuoppala
2018-01-19  8:33     ` Chris Wilson
2018-01-15  8:47 ` [PATCH v2 11/11] drm/i915: Avoid waitboosting on the active request Chris Wilson
2018-01-18  9:49   ` Joonas Lahtinen
2018-01-15  9:19 ` ✓ Fi.CI.BAT: success for series starting with [v2,01/11] drm/i915: Disable preemption and sleeping while using the punit sideband Patchwork
2018-01-15 10:23 ` ✗ Fi.CI.IGT: failure " Patchwork
2018-01-15 10:27   ` Chris Wilson

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=20180115084723.2221-10-chris@chris-wilson.co.uk \
    --to=chris@chris-wilson.co.uk \
    --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.