All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ville Syrjala <ville.syrjala@linux.intel.com>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH 24/29] drm/i915: Centralize the SKL DDI A/E vs. B/C/D buf trans handling
Date: Mon, 18 Sep 2017 21:25:59 +0300	[thread overview]
Message-ID: <20170918182604.9519-25-ville.syrjala@linux.intel.com> (raw)
In-Reply-To: <20170918182604.9519-1-ville.syrjala@linux.intel.com>

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

SKL DDI B/C/D only have 9 usable buf trans registers for DP/eDP. That
matches the normal DP buf trans tables, but the low vswing eDP tables
have 10 entries. Thus the eDP tables can only be used safely with DDI A
and E.

We try to catch cases where DDI B/C/D gets used with the wrong number of
entires in some parts of the code, but not everywhere. Let's move the
code to deal with that deeper into intel_ddi_get_buf_trans_edp(). And
for sake of symmetry do the same in intel_ddi_get_buf_trans_dp(). That
would also avoid explosions in the rather unlikely case that the DP
tables would get revised to 10 entries as well.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/i915/intel_ddi.c | 60 +++++++++++++++++++++++-----------------
 1 file changed, 34 insertions(+), 26 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_ddi.c b/drivers/gpu/drm/i915/intel_ddi.c
index c804f4e91036..d625bfe6d420 100644
--- a/drivers/gpu/drm/i915/intel_ddi.c
+++ b/drivers/gpu/drm/i915/intel_ddi.c
@@ -587,14 +587,29 @@ skl_get_buf_trans_hdmi(struct drm_i915_private *dev_priv, int *n_entries)
 	}
 }
 
+static int skl_buf_trans_num_entries(enum port port, int n_entries)
+{
+	/* Only DDIA and DDIE can select the 10th register with DP */
+	if (port == PORT_A || port == PORT_E)
+		return min(n_entries, 10);
+	else
+		return min(n_entries, 9);
+}
+
 static const struct ddi_buf_trans *
 intel_ddi_get_buf_trans_dp(struct drm_i915_private *dev_priv,
-			   int *n_entries)
+			   enum port port, int *n_entries)
 {
 	if (IS_KABYLAKE(dev_priv) || IS_COFFEELAKE(dev_priv)) {
-		return kbl_get_buf_trans_dp(dev_priv, n_entries);
+		const struct ddi_buf_trans *ddi_translations =
+			kbl_get_buf_trans_dp(dev_priv, n_entries);
+		*n_entries = skl_buf_trans_num_entries(port, *n_entries);
+		return ddi_translations;
 	} else if (IS_SKYLAKE(dev_priv)) {
-		return skl_get_buf_trans_dp(dev_priv, n_entries);
+		const struct ddi_buf_trans *ddi_translations =
+			skl_get_buf_trans_dp(dev_priv, n_entries);
+		*n_entries = skl_buf_trans_num_entries(port, *n_entries);
+		return ddi_translations;
 	} else if (IS_BROADWELL(dev_priv)) {
 		*n_entries = ARRAY_SIZE(bdw_ddi_translations_dp);
 		return  bdw_ddi_translations_dp;
@@ -609,10 +624,13 @@ intel_ddi_get_buf_trans_dp(struct drm_i915_private *dev_priv,
 
 static const struct ddi_buf_trans *
 intel_ddi_get_buf_trans_edp(struct drm_i915_private *dev_priv,
-			    int *n_entries)
+			    enum port port, int *n_entries)
 {
 	if (IS_GEN9_BC(dev_priv)) {
-		return skl_get_buf_trans_edp(dev_priv, n_entries);
+		const struct ddi_buf_trans *ddi_translations =
+			skl_get_buf_trans_edp(dev_priv, n_entries);
+		*n_entries = skl_buf_trans_num_entries(port, *n_entries);
+		return ddi_translations;
 	} else if (IS_BROADWELL(dev_priv)) {
 		return bdw_get_buf_trans_edp(dev_priv, n_entries);
 	} else if (IS_HASWELL(dev_priv)) {
@@ -798,22 +816,16 @@ static void intel_prepare_dp_ddi_buffers(struct intel_encoder *encoder,
 		ddi_translations = intel_ddi_get_buf_trans_fdi(dev_priv,
 							       &n_entries);
 	else if (intel_crtc_has_type(crtc_state, INTEL_OUTPUT_EDP))
-		ddi_translations = intel_ddi_get_buf_trans_edp(dev_priv,
+		ddi_translations = intel_ddi_get_buf_trans_edp(dev_priv, port,
 							       &n_entries);
 	else
-		ddi_translations = intel_ddi_get_buf_trans_dp(dev_priv,
+		ddi_translations = intel_ddi_get_buf_trans_dp(dev_priv, port,
 							      &n_entries);
 
-	if (IS_GEN9_BC(dev_priv)) {
-		/* If we're boosting the current, set bit 31 of trans1 */
-		if (dev_priv->vbt.ddi_port_info[port].dp_boost_level)
-			iboost_bit = DDI_BUF_BALANCE_LEG_ENABLE;
-
-		if (WARN_ON(encoder->type == INTEL_OUTPUT_EDP &&
-			    port != PORT_A && port != PORT_E &&
-			    n_entries > 9))
-			n_entries = 9;
-	}
+	/* If we're boosting the current, set bit 31 of trans1 */
+	if (IS_GEN9_BC(dev_priv) &&
+	    dev_priv->vbt.ddi_port_info[port].dp_boost_level)
+		iboost_bit = DDI_BUF_BALANCE_LEG_ENABLE;
 
 	for (i = 0; i < n_entries; i++) {
 		I915_WRITE(DDI_BUF_TRANS_LO(port, i),
@@ -1810,14 +1822,9 @@ static void skl_ddi_set_iboost(struct intel_encoder *encoder,
 		if (type == INTEL_OUTPUT_HDMI)
 			ddi_translations = intel_ddi_get_buf_trans_hdmi(dev_priv, &n_entries);
 		else if (type == INTEL_OUTPUT_EDP)
-			ddi_translations = intel_ddi_get_buf_trans_edp(dev_priv, &n_entries);
+			ddi_translations = intel_ddi_get_buf_trans_edp(dev_priv, port, &n_entries);
 		else
-			ddi_translations = intel_ddi_get_buf_trans_dp(dev_priv, &n_entries);
-
-		if (WARN_ON(type != INTEL_OUTPUT_HDMI &&
-			    port != PORT_A &&
-			    port != PORT_E && n_entries > 9))
-			n_entries = 9;
+			ddi_translations = intel_ddi_get_buf_trans_dp(dev_priv, port, &n_entries);
 
 		iboost = ddi_translations[level].i_boost;
 	}
@@ -1859,6 +1866,7 @@ static void bxt_ddi_vswing_sequence(struct intel_encoder *encoder,
 u8 intel_ddi_dp_voltage_max(struct intel_encoder *encoder)
 {
 	struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
+	enum port port = encoder->port;
 	int n_entries;
 
 	if (IS_CANNONLAKE(dev_priv)) {
@@ -1873,9 +1881,9 @@ u8 intel_ddi_dp_voltage_max(struct intel_encoder *encoder)
 			bxt_get_buf_trans_dp(dev_priv, &n_entries);
 	} else {
 		if (encoder->type == INTEL_OUTPUT_EDP)
-			intel_ddi_get_buf_trans_edp(dev_priv, &n_entries);
+			intel_ddi_get_buf_trans_edp(dev_priv, port, &n_entries);
 		else
-			intel_ddi_get_buf_trans_dp(dev_priv, &n_entries);
+			intel_ddi_get_buf_trans_dp(dev_priv, port, &n_entries);
 	}
 
 	if (WARN_ON(n_entries < 1))
-- 
2.13.5

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

  parent reply	other threads:[~2017-09-18 18:27 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-18 18:25 [PATCH 00/29] drm/i915: Eliminate DDI encoder->type frobbery redux Ville Syrjala
2017-09-18 18:25 ` [PATCH 01/29] drm/i915: Replace some spaces with tabs Ville Syrjala
2017-09-18 18:38   ` Chris Wilson
2017-09-18 18:53   ` Jani Nikula
2017-09-18 18:25 ` [PATCH 02/29] drm/i915: Shrink bxt_ddi_buf_trans Ville Syrjala
2017-09-18 18:54   ` Jani Nikula
2017-09-18 18:25 ` [PATCH 03/29] drm/i915: Shrink cnl_ddi_buf_trans Ville Syrjala
2017-09-18 18:39   ` Chris Wilson
2017-09-18 18:40   ` Chris Wilson
2017-09-18 19:02     ` Chris Wilson
2017-09-18 18:25 ` [PATCH 04/29] drm/i915: Dump 'output_types' in crtc state dump Ville Syrjala
2017-09-18 18:43   ` Chris Wilson
2017-09-18 18:56     ` Ville Syrjälä
2017-09-18 18:54   ` Jani Nikula
2017-09-20 14:03   ` [PATCH v2 " Ville Syrjala
2017-09-18 18:25 ` [PATCH 05/29] drm/i915: Extract intel_ddi_clk_disable() Ville Syrjala
2017-09-18 18:45   ` Chris Wilson
2017-09-18 19:09     ` Ville Syrjälä
2017-09-18 18:25 ` [PATCH 06/29] drm/i915: Extract intel_disable_ddi_buf() Ville Syrjala
2017-09-18 18:55   ` Jani Nikula
2017-09-18 18:25 ` [PATCH 07/29] drm/i915: Inline the required bits of intel_ddi_post_disable() into intel_ddi_fdi_post_disable() Ville Syrjala
2017-09-18 18:55   ` Jani Nikula
2017-09-18 18:25 ` [PATCH 08/29] drm/i915: Split intel_ddi_post_disable() into DP vs. HDMI variants Ville Syrjala
2017-09-18 18:56   ` Jani Nikula
2017-09-18 18:25 ` [PATCH 09/29] drm/i915: Remove useless eDP check from intel_ddi_pre_enable_dp() Ville Syrjala
2017-09-18 18:56   ` Jani Nikula
2017-09-18 18:25 ` [PATCH 10/29] drm/i915: Split intel_disable_ddi() into DP vs. HDMI variants Ville Syrjala
2017-09-18 18:25 ` [PATCH 11/29] drm/i915: Plump crtc_state etc. directly to intel_ddi_pre_enable_{dp, hdmi}() Ville Syrjala
2017-09-18 18:25 ` [PATCH 12/29] drm/i915: Split intel_enable_ddi() into DP and HDMI variants Ville Syrjala
2017-09-18 18:25 ` [PATCH 13/29] drm/i915: Relocate intel_ddi_get_buf_trans_*() functions Ville Syrjala
2017-09-18 18:25 ` [PATCH 14/29] drm/i915: Extract intel_ddi_get_buf_trans_hdmi() Ville Syrjala
2017-09-18 18:25 ` [PATCH 15/29] drm/i915: Pass the encoder type explicitly to skl_set_iboost() Ville Syrjala
2017-09-18 18:25 ` [PATCH 16/29] drm/i915: Pass the level to intel_prepare_hdmi_ddi_buffers() Ville Syrjala
2017-09-18 18:25 ` [PATCH 17/29] drm/i915: Integrate BXT into intel_ddi_dp_voltage_max() Ville Syrjala
2017-09-18 18:25 ` [PATCH 18/29] drm/i915: Pass encoder type to cnl_ddi_vswing_sequence() explicitly Ville Syrjala
2017-09-18 18:25 ` [PATCH 19/29] drm/i915: Kill off the BXT buf_trans default_index Ville Syrjala
2017-09-18 18:25 ` [PATCH 20/29] drm/i915: Don't use encoder->type in intel_ddi_set_pipe_settings() Ville Syrjala
2017-09-18 18:25 ` [PATCH 21/29] drm/i915: Pass crtc state to intel_prepare_dp_ddi_buffers() Ville Syrjala
2017-09-18 18:25 ` [PATCH 22/29] drm/i915: Start using output_types for DPLL selection Ville Syrjala
2017-09-18 18:25 ` [PATCH 23/29] drm/i915: Stop using encoder->type in intel_ddi_enable_transcoder_func() Ville Syrjala
2017-09-18 18:25 ` Ville Syrjala [this message]
2017-09-18 18:26 ` [PATCH 25/29] drm/i915: Stop frobbing with DDI encoder->type Ville Syrjala
2017-09-21 11:06   ` [PATCH v2 " Ville Syrjala
2017-09-21 14:56   ` [PATCH v3 " Ville Syrjala
2017-09-18 18:26 ` [PATCH 26/29] drm/i915: Unify error handling for missing DDI buf trans tables Ville Syrjala
2017-09-18 18:26 ` [PATCH 27/29] drm/i915: Clear up the types we use for DDI buf trans level/n_entries Ville Syrjala
2017-09-18 18:26 ` [PATCH 28/29] drm/i915: Replace most intel_ddi_get_encoder_port() alls with encoder->port Ville Syrjala
2017-09-18 18:26 ` [PATCH 29/29] drm/i915: Pass a crtc state to ddi post_disable from MST code Ville Syrjala
2017-09-18 19:02   ` Jani Nikula
2017-09-18 19:04 ` [PATCH 00/29] drm/i915: Eliminate DDI encoder->type frobbery redux Jani Nikula
2017-09-18 19:46 ` ✗ Fi.CI.BAT: failure for " Patchwork
2017-09-20 14:26 ` ✗ Fi.CI.BAT: failure for drm/i915: Eliminate DDI encoder->type frobbery redux (rev2) Patchwork
2017-09-20 15:40 ` Patchwork
2017-09-20 15:46   ` Ville Syrjälä
2017-09-25 11:40     ` Jani Nikula
2017-09-21 13:18 ` ✗ Fi.CI.BAT: failure for drm/i915: Eliminate DDI encoder->type frobbery redux (rev3) Patchwork
2017-09-21 15:36 ` ✓ Fi.CI.BAT: success for drm/i915: Eliminate DDI encoder->type frobbery redux (rev4) Patchwork
2017-09-21 18:26 ` ✗ Fi.CI.IGT: failure " 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=20170918182604.9519-25-ville.syrjala@linux.intel.com \
    --to=ville.syrjala@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.