Skip to contentSkip to conversation

drm/i915: Backport some VLV clock fixes to 3.12

PATCH In review [email protected] 2 participants 5 messages Dec 10, 2013 – Dec 18, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover drm/i915: Backport some VLV clock fixes to 3.12

Hi stable team,

Here's a backport of the following upstream commits for 3.12:

commit 662c6ecbcdca1fe8a5402f6c83d98d242917a043

Author: Chris Wilson <[email protected]>
Date:   Wed Sep 25 14:24:01 2013 -0700

drm/i915/vlv: fix up broken precision in vlv_crtc_clock_get

commit acbec814a27f233b5ddb88a1bcaa2ac20daf64e0

Author: Jesse Barnes <[email protected]>
Date:   Fri Sep 20 11:29:32 2013 -0700

drm/i915/vlv: add VLV specific clock_get function v3

commit f60711666bcab6df2c6c91d851e07ed54088453c

Author: Jesse Barnes <[email protected]>
Date:   Tue Oct 1 10:41:38 2013 -0700

i915/vlv: untangle integrated clock source handling v4

All are VLV/BYT specific. f60711666bcab6df2c6c91d851e07ed54088453c fixes some "display not working" type of issues. The rest make the i915 hardware state checker much happier. Without them, dmesg will be full of WARN()s from the state checker.

#1 lore raw

PATCH 1/3 i915/vlv: untangle integrated clock source handling v4

From: Jesse Barnes <[email protected]>

commit f60711666bcab6df2c6c91d851e07ed54088453c upstream.

The global integrated clock source bit resides in DPLL B on VLV, but we were treating it as a per-pipe resource. It needs to be set whenever any PLL is active, so pull setting the bit out of vlv_update_pll and into vlv_enable_pll. Also add a vlv_disable_pll to prevent disabling it when pipe B shuts down.

I'm guessing on the references here, I expect this to bite any config where multiple displays are active or displays are moved from pipe to pipe.

v2: re-add bits in vlv_update_pll to keep from confusing the state checker
v3: use enum pipe checks (Daniel)
set CRI clock source early (Ville)
consistently set CRI clock source everywhere (Ville)
v4: drop unnecessary setting of bit in vlv enable pll (Ville)

References: https://bugs.freedesktop.org/show_bug.cgi?id=67245
References: https://bugs.freedesktop.org/show_bug.cgi?id=69693

Conflicts:
drivers/gpu/drm/i915/intel_display.c

---
 drivers/gpu/drm/i915/intel_display.c | 30 +++++++++++++++++++++++++++---
 1 file changed, 27 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/intel_display.c +27 -3
index 333aa1b..c97221a 100644
@@ -1429,6 +1429,20 @@ static void i9xx_disable_pll(struct drm_i915_private *dev_priv, enum pipe pipe)
 	POSTING_READ(DPLL(pipe));
 }
 
+static void vlv_disable_pll(struct drm_i915_private *dev_priv, enum pipe pipe)
+{
+	u32 val = 0;
+
+	/* Make sure the pipe isn't still relying on us */
+	assert_pipe_disabled(dev_priv, pipe);
+
+	/* Leave integrated clock source enabled */
+	if (pipe == PIPE_B)
+		val = DPLL_INTEGRATED_CRI_CLK_VLV;
+	I915_WRITE(DPLL(pipe), val);
+	POSTING_READ(DPLL(pipe));
+}
+
 void vlv_wait_port_ready(struct drm_i915_private *dev_priv, int port)
 {
 	u32 port_mask;
@@ -3824,7 +3838,10 @@ static void i9xx_crtc_disable(struct drm_crtc *crtc)
 		if (encoder->post_disable)
 			encoder->post_disable(encoder);
 
-	i9xx_disable_pll(dev_priv, pipe);
+	if (IS_VALLEYVIEW(dev))
+		vlv_disable_pll(dev_priv, pipe);
+	else
+		i9xx_disable_pll(dev_priv, pipe);
 
 	intel_crtc->active = false;
 	intel_update_fbc(dev);
@@ -4553,9 +4570,9 @@ static void vlv_update_pll(struct intel_crtc *crtc)
 	/* Enable DPIO clock input */
 	dpll = DPLL_EXT_BUFFER_ENABLE_VLV | DPLL_REFA_CLK_ENABLE_VLV |
 		DPLL_VGA_MODE_DIS | DPLL_INTEGRATED_CLOCK_VLV;
-	if (pipe)
+	/* We should never disable this, set it here for state tracking */
+	if (pipe == PIPE_B)
 		dpll |= DPLL_INTEGRATED_CRI_CLK_VLV;
-
 	dpll |= DPLL_VCO_ENABLE;
 	crtc->config.dpll_hw_state.dpll = dpll;
 
@@ -10088,12 +10105,19 @@ static void i915_disable_vga(struct drm_device *dev)
 
 void intel_modeset_init_hw(struct drm_device *dev)
 {
+	struct drm_i915_private *dev_priv = dev->dev_private;
+
 	intel_init_power_well(dev);
 
 	intel_prepare_ddi(dev);
 
 	intel_init_clock_gating(dev);
 
+	/* Enable the CRI clock source so we can get at the display */
+	if (IS_VALLEYVIEW(dev))
+		I915_WRITE(DPLL(PIPE_B), I915_READ(DPLL(PIPE_B)) |
+			   DPLL_INTEGRATED_CRI_CLK_VLV);
+
 	mutex_lock(&dev->struct_mutex);
 	intel_enable_gt_powersave(dev);
 	mutex_unlock(&dev->struct_mutex);
Signature · 6 lines
1.8.3.2

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw

PATCH 2/3 drm/i915/vlv: add VLV specific clock_get function v3

In reply to [email protected]

From: Jesse Barnes <[email protected]>

commit acbec814a27f233b5ddb88a1bcaa2ac20daf64e0 upstream.

Calculation is a little different than other platforms.

v2: update to use port_clock instead
rebase on top of Ville's changes
v3: update to new port_clock semantics - don't divide by
pixel_multiplier (Ville)

References: https://bugs.freedesktop.org/show_bug.cgi?id=67345

Conflicts:
drivers/gpu/drm/i915/intel_display.c

---
 drivers/gpu/drm/i915/intel_display.c | 30 +++++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_display.c +29 -1
index c97221a..3c9ac84 100644
@@ -5032,6 +5032,34 @@ static void i9xx_get_pfit_config(struct intel_crtc *crtc,
 			I915_READ(LVDS) & LVDS_BORDER_ENABLE;
 }
 
+static void vlv_crtc_clock_get(struct intel_crtc *crtc,
+			       struct intel_crtc_config *pipe_config)
+{
+	struct drm_device *dev = crtc->base.dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	int pipe = pipe_config->cpu_transcoder;
+	intel_clock_t clock;
+	u32 mdiv;
+	int refclk = 100000, fastclk, update_rate;
+
+	mutex_lock(&dev_priv->dpio_lock);
+	mdiv = vlv_dpio_read(dev_priv, DPIO_DIV(pipe));
+	mutex_unlock(&dev_priv->dpio_lock);
+
+	clock.m1 = (mdiv >> DPIO_M1DIV_SHIFT) & 7;
+	clock.m2 = mdiv & DPIO_M2DIV_MASK;
+	clock.n = (mdiv >> DPIO_N_SHIFT) & 0xf;
+	clock.p1 = (mdiv >> DPIO_P1_SHIFT) & 7;
+	clock.p2 = (mdiv >> DPIO_P2_SHIFT) & 0x1f;
+
+	update_rate = refclk / clock.n;
+	clock.vco = update_rate * clock.m1 * clock.m2;
+	fastclk = clock.vco / clock.p1 / clock.p2;
+	clock.dot = (2 * fastclk);
+
+	pipe_config->adjusted_mode.clock = clock.dot / 10;
+}
+
 static bool i9xx_get_pipe_config(struct intel_crtc *crtc,
 				 struct intel_crtc_config *pipe_config)
 {
@@ -9849,7 +9877,7 @@ static void intel_init_display(struct drm_device *dev)
 		dev_priv->display.update_plane = ironlake_update_plane;
 	} else if (IS_VALLEYVIEW(dev)) {
 		dev_priv->display.get_pipe_config = i9xx_get_pipe_config;
-		dev_priv->display.get_clock = i9xx_crtc_clock_get;
+		dev_priv->display.get_clock = vlv_crtc_clock_get;
 		dev_priv->display.crtc_mode_set = i9xx_crtc_mode_set;
 		dev_priv->display.crtc_enable = valleyview_crtc_enable;
 		dev_priv->display.crtc_disable = i9xx_crtc_disable;
Signature · 6 lines
1.8.3.2

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#3 lore raw

PATCH 3/3 drm/i915/vlv: fix up broken precision in vlv_crtc_clock_get

In reply to [email protected]

From: Chris Wilson <[email protected]>

commit 662c6ecbcdca1fe8a5402f6c83d98d242917a043 upstream.

With some divider values we end up with the wrong result. So remove the intermediates (like Ville suggested in the first place) to get the right answer.

---
 drivers/gpu/drm/i915/intel_display.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/intel_display.c +3 -5
index 3c9ac84..cb5a60e 100644
@@ -5040,7 +5040,7 @@ static void vlv_crtc_clock_get(struct intel_crtc *crtc,
 	int pipe = pipe_config->cpu_transcoder;
 	intel_clock_t clock;
 	u32 mdiv;
-	int refclk = 100000, fastclk, update_rate;
+	int refclk = 100000;
 
 	mutex_lock(&dev_priv->dpio_lock);
 	mdiv = vlv_dpio_read(dev_priv, DPIO_DIV(pipe));
@@ -5052,10 +5052,8 @@ static void vlv_crtc_clock_get(struct intel_crtc *crtc,
 	clock.p1 = (mdiv >> DPIO_P1_SHIFT) & 7;
 	clock.p2 = (mdiv >> DPIO_P2_SHIFT) & 0x1f;
 
-	update_rate = refclk / clock.n;
-	clock.vco = update_rate * clock.m1 * clock.m2;
-	fastclk = clock.vco / clock.p1 / clock.p2;
-	clock.dot = (2 * fastclk);
+	clock.vco = refclk * clock.m1 * clock.m2 / clock.n;
+	clock.dot = 2 * clock.vco / (clock.p1 * clock.p2);
 
 	pipe_config->adjusted_mode.clock = clock.dot / 10;
 }
Signature · 6 lines
1.8.3.2

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#4 lore raw
In reply to [email protected]
Quoted 20 lines · On Tue, Dec 10, 2013 at 05:07:13PM +0200, [email protected] wrote:

Hi stable team,

Here's a backport of the following upstream commits for 3.12:

commit 662c6ecbcdca1fe8a5402f6c83d98d242917a043

Author: Chris Wilson <[email protected]>
Date:   Wed Sep 25 14:24:01 2013 -0700

drm/i915/vlv: fix up broken precision in vlv_crtc_clock_get

commit acbec814a27f233b5ddb88a1bcaa2ac20daf64e0

Author: Jesse Barnes <[email protected]>
Date:   Fri Sep 20 11:29:32 2013 -0700

drm/i915/vlv: add VLV specific clock_get function v3

commit f60711666bcab6df2c6c91d851e07ed54088453c

Author: Jesse Barnes <[email protected]>
Date:   Tue Oct 1 10:41:38 2013 -0700
Quoted 6 lines

i915/vlv: untangle integrated clock source handling v4

All are VLV/BYT specific. f60711666bcab6df2c6c91d851e07ed54088453c fixes some "display not working" type of issues. The rest make the i915 hardware state checker much happier. Without them, dmesg will be full of WARN()s from the state checker.

All now applied, thanks.

greg k-h