All of lore.kernel.org
 help / color / mirror / Atom feed
From: ville.syrjala@linux.intel.com
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH 08/21] drm/i915: Keep track of preferred cdclk vco frequency on SKL
Date: Fri, 13 May 2016 23:41:27 +0300	[thread overview]
Message-ID: <1463172100-24715-9-git-send-email-ville.syrjala@linux.intel.com> (raw)
In-Reply-To: <1463172100-24715-1-git-send-email-ville.syrjala@linux.intel.com>

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

Now that skl_vco_freq tracks the actual DPLL0 vco frequency, we'll need
something that keeps track of which vco frequency we want to use in case
the current vco is 0. This would be important across supend/resume since
we'll disable DPLL0 around those parts.

We'll also update our idea of max cdclk/dotclock when the preferred
vco changes. That could happen if out initial guess was wrong, and
later eDP would force us to change it. One issue here could be that
changing the max dotclock could cause our mode list to change during
next time the displays get probed. But I don't see a good way to avoid
that, except perhaps by allowing either vco frequency to be used as
needed. But the docs suggest that such usage wasn't really inteded.

Also need to make sure we don't update our max_cdclk value before we
have a preferred vco value, which means moving that to happen after
the cdclk sanitation.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/i915/i915_drv.h       |  1 +
 drivers/gpu/drm/i915/intel_display.c  | 48 +++++++++++++++++++++++++++++------
 drivers/gpu/drm/i915/intel_dpll_mgr.c |  5 ++++
 drivers/gpu/drm/i915/intel_drv.h      |  1 +
 4 files changed, 47 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index b319da970c8a..46a22732088e 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -1821,6 +1821,7 @@ struct drm_i915_private {
 
 	unsigned int fsb_freq, mem_freq, is_ddr3;
 	unsigned int skl_vco_freq;
+	unsigned int skl_preferred_vco_freq;
 	unsigned int cdclk_freq, max_cdclk_freq, atomic_cdclk_freq;
 	unsigned int max_dotclk_freq;
 	unsigned int rawclk_freq;
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index cd2809179042..107a7799bdde 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -5265,21 +5265,34 @@ static int intel_compute_max_dotclk(struct drm_i915_private *dev_priv)
 		return max_cdclk_freq*90/100;
 }
 
+static int skl_calc_cdclk(int max_pixclk, int vco);
+
 static void intel_update_max_cdclk(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 
 	if (IS_SKYLAKE(dev) || IS_KABYLAKE(dev)) {
 		u32 limit = I915_READ(SKL_DFSM) & SKL_DFSM_CDCLK_LIMIT_MASK;
+		int max_cdclk, vco;
+
+		vco = dev_priv->skl_preferred_vco_freq;
+		WARN_ON(vco != 8100 && vco != 8640);
 
+		/*
+		 * Use the lower (vco 8640) cdclk values as a
+		 * first guess. skl_calc_cdclk() will correct it
+		 * if the preferred vco is 8100 instead.
+		 */
 		if (limit == SKL_DFSM_CDCLK_LIMIT_675)
-			dev_priv->max_cdclk_freq = 675000;
+			max_cdclk = 617140;
 		else if (limit == SKL_DFSM_CDCLK_LIMIT_540)
-			dev_priv->max_cdclk_freq = 540000;
+			max_cdclk = 540000;
 		else if (limit == SKL_DFSM_CDCLK_LIMIT_450)
-			dev_priv->max_cdclk_freq = 450000;
+			max_cdclk = 432000;
 		else
-			dev_priv->max_cdclk_freq = 337500;
+			max_cdclk = 308570;
+
+		dev_priv->max_cdclk_freq = skl_calc_cdclk(max_cdclk, vco);
 	} else if (IS_BROXTON(dev)) {
 		dev_priv->max_cdclk_freq = 624000;
 	} else if (IS_BROADWELL(dev))  {
@@ -5336,9 +5349,6 @@ static void intel_update_cdclk(struct drm_device *dev)
 	 */
 	if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv))
 		I915_WRITE(GMBUSFREQ_VLV, DIV_ROUND_UP(dev_priv->cdclk_freq, 1000));
-
-	if (dev_priv->max_cdclk_freq == 0)
-		intel_update_max_cdclk(dev);
 }
 
 /* convert from kHz to .1 fixpoint MHz with -1MHz offset */
@@ -5587,12 +5597,24 @@ skl_dpll0_update(struct drm_i915_private *dev_priv)
 	}
 }
 
+void skl_set_preferred_cdclk_vco(struct drm_i915_private *dev_priv, int vco)
+{
+	bool changed = dev_priv->skl_preferred_vco_freq != vco;
+
+	dev_priv->skl_preferred_vco_freq = vco;
+
+	if (changed)
+		intel_update_max_cdclk(dev_priv->dev);
+}
+
 static void
 skl_dpll0_enable(struct drm_i915_private *dev_priv, int vco)
 {
 	int min_cdclk = skl_calc_cdclk(0, vco);
 	u32 val;
 
+	WARN_ON(vco != 8100 && vco != 8640);
+
 	/* select the minimum CDCLK before enabling DPLL 0 */
 	val = CDCLK_FREQ_337_308 | skl_cdclk_decimal(min_cdclk);
 	I915_WRITE(CDCLK_CTL, val);
@@ -5628,6 +5650,9 @@ skl_dpll0_enable(struct drm_i915_private *dev_priv, int vco)
 		DRM_ERROR("DPLL0 not locked\n");
 
 	dev_priv->skl_vco_freq = vco;
+
+	/* We'll want to keep using the current vco from now on. */
+	skl_set_preferred_cdclk_vco(dev_priv, vco);
 }
 
 static void
@@ -5744,7 +5769,9 @@ void skl_init_cdclk(struct drm_i915_private *dev_priv)
 		int cdclk, vco;
 
 		/* set CDCLK to the lowest frequency, Modeset follows */
-		vco = 8100;
+		vco = dev_priv->skl_preferred_vco_freq;
+		if (vco == 0)
+			vco = 8100;
 		cdclk = skl_calc_cdclk(0, vco);
 
 		skl_set_cdclk(dev_priv, cdclk, vco);
@@ -13359,6 +13386,8 @@ static int intel_modeset_checks(struct drm_atomic_state *state)
 	if (dev_priv->display.modeset_calc_cdclk) {
 		if (!intel_state->cdclk_pll_vco)
 			intel_state->cdclk_pll_vco = dev_priv->skl_vco_freq;
+		if (!intel_state->cdclk_pll_vco)
+			intel_state->cdclk_pll_vco = dev_priv->skl_preferred_vco_freq;
 
 		ret = dev_priv->display.modeset_calc_cdclk(state);
 		if (ret < 0)
@@ -15525,6 +15554,9 @@ void intel_modeset_init(struct drm_device *dev)
 
 	intel_shared_dpll_init(dev);
 
+	if (dev_priv->max_cdclk_freq == 0)
+		intel_update_max_cdclk(dev);
+
 	/* Just disable it once at startup */
 	i915_disable_vga(dev);
 	intel_setup_outputs(dev);
diff --git a/drivers/gpu/drm/i915/intel_dpll_mgr.c b/drivers/gpu/drm/i915/intel_dpll_mgr.c
index 5391ab66b64d..34ec149fde85 100644
--- a/drivers/gpu/drm/i915/intel_dpll_mgr.c
+++ b/drivers/gpu/drm/i915/intel_dpll_mgr.c
@@ -1635,6 +1635,11 @@ static void intel_ddi_pll_init(struct drm_device *dev)
 	if (IS_SKYLAKE(dev) || IS_KABYLAKE(dev)) {
 		if (skl_sanitize_cdclk(dev_priv))
 			DRM_DEBUG_KMS("Sanitized cdclk programmed by pre-os\n");
+
+		/* We'll want to keep using the current vco from now on */
+		if (dev_priv->skl_vco_freq != 0)
+			skl_set_preferred_cdclk_vco(dev_priv,
+						    dev_priv->skl_vco_freq);
 	} else if (!IS_BROXTON(dev_priv)) {
 		/*
 		 * The LCPLL register should be turned on by the BIOS. For now
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index c7cb9829547e..8f48a32e991b 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -1145,6 +1145,7 @@ void i915_audio_component_init(struct drm_i915_private *dev_priv);
 void i915_audio_component_cleanup(struct drm_i915_private *dev_priv);
 
 /* intel_display.c */
+void skl_set_preferred_cdclk_vco(struct drm_i915_private *dev_priv, int vco);
 void intel_update_rawclk(struct drm_i915_private *dev_priv);
 int vlv_get_cck_clock(struct drm_i915_private *dev_priv,
 		      const char *name, u32 reg, int ref_freq);
-- 
2.7.4

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

  parent reply	other threads:[~2016-05-13 20:42 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-13 20:41 [PATCH 00/21] drm/i915: SKL/KBL/BXT cdclk stuff ville.syrjala
2016-05-13 20:41 ` [PATCH 01/21] drm/i915: Fix BXT min_pixclk after state readout ville.syrjala
2016-05-17 18:09   ` Imre Deak
2016-05-17 18:21     ` Ville Syrjälä
2016-05-17 18:24       ` Imre Deak
2016-05-13 20:41 ` [PATCH 02/21] drm/i915/skl: SKL CDCLK change on modeset tracking VCO ville.syrjala
2016-05-19  9:08   ` Imre Deak
2016-05-19  9:18     ` Ville Syrjälä
2016-05-13 20:41 ` [PATCH 03/21] drm/i915: Move the SKL DPLL0 VCO computation into intel_dp_compute_config() ville.syrjala
2016-05-19 11:57   ` Imre Deak
2016-05-13 20:41 ` [PATCH 04/21] drm/i915: Extract skl_calc_cdclk() ville.syrjala
2016-05-19 12:02   ` Imre Deak
2016-05-13 20:41 ` [PATCH 05/21] drm/i915: Actually read out DPLL0 vco on skl from hardware ville.syrjala
2016-05-19 12:38   ` Imre Deak
2016-05-13 20:41 ` [PATCH 06/21] drm/i915: Report the current DPLL0 vco on SKL/KBL ville.syrjala
2016-05-19 12:40   ` Imre Deak
2016-05-13 20:41 ` [PATCH 07/21] drm/i915: Allow enable/disable of DPLL0 around cdclk changes on SKL ville.syrjala
2016-05-19 13:04   ` Imre Deak
2016-05-19 13:18     ` Ville Syrjälä
2016-05-19 13:39       ` Imre Deak
2016-05-13 20:41 ` ville.syrjala [this message]
2016-05-19 14:25   ` [PATCH 08/21] drm/i915: Keep track of preferred cdclk vco frequency " Imre Deak
2016-05-13 20:41 ` [PATCH 09/21] drm/i915: Beef up skl_sanitize_cdclk() a bit ville.syrjala
2016-05-19 14:30   ` Imre Deak
2016-05-13 20:41 ` [PATCH 10/21] drm/i915: Unify SKL cdclk init paths ville.syrjala
2016-05-19 15:43   ` Imre Deak
2016-05-23 18:20     ` Ville Syrjälä
2016-05-13 20:41 ` [PATCH 11/21] drm/i915: Move SKL+ DBUF enable/disable to display core init/uninit ville.syrjala
2016-05-19 15:48   ` Imre Deak
2016-05-23 18:20     ` Ville Syrjälä
2016-05-13 20:41 ` [PATCH 12/21] drm/i915: Make 308 and 671 MHz cdclks more accurate on SKL ville.syrjala
2016-05-19 16:03   ` Imre Deak
2016-05-13 20:41 ` [PATCH 13/21] drm/i915: Rename skl_vco_freq to cdclk_pll.vco ville.syrjala
2016-05-19 16:17   ` Imre Deak
2016-05-19 16:21     ` Ville Syrjälä
2016-05-13 20:41 ` [PATCH 14/21] drm/i915: Store cdclk PLL reference clock under dev_priv ville.syrjala
2016-05-19 17:00   ` Imre Deak
2016-05-13 20:41 ` [PATCH 15/21] drm/i915: Extract bxt DE PLL enable/disable from broxton_set_cdclk() ville.syrjala
2016-05-19 17:04   ` Imre Deak
2016-05-13 20:41 ` [PATCH 16/21] drm/i915: Store BXT DE PLL vco and ref clocks in dev_priv ville.syrjala
2016-05-19 18:43   ` Imre Deak
2016-05-13 20:41 ` [PATCH 17/21] drm/i915: Update cached cdclk state from broxton_init_cdclk() ville.syrjala
2016-05-19 18:46   ` Imre Deak
2016-05-13 20:41 ` [PATCH 18/21] drm/i915: Rewrite broxton_get_display_clock_speed() in terms of the DE PLL vco/refclk ville.syrjala
2016-05-19 19:05   ` Imre Deak
2016-05-13 20:41 ` [PATCH 19/21] drm/i915: Make bxt_set_cdclk() operate in terms of the current vs target DE PLL vco ville.syrjala
2016-05-19 19:40   ` Imre Deak
2016-05-13 20:41 ` [PATCH 20/21] drm/i915: Replace bxt_verify_cdclk_state() with a more generic cdclk check ville.syrjala
2016-05-19 19:41   ` Imre Deak
2016-05-13 20:41 ` [PATCH 21/21] drm/i915: Set BXT cdclk to minimum initially ville.syrjala
2016-05-19 19:45   ` Imre Deak
2016-05-14  5:25 ` ✗ Ro.CI.BAT: failure for drm/i915: SKL/KBL/BXT cdclk stuff Patchwork
2016-05-23 17:25   ` Ville Syrjälä
2016-05-16 13:59 ` [PATCH 22/21] drm/i915: Assert the dbuf is enabled when disabling DC5/6 ville.syrjala
2016-05-19 19:49   ` Imre Deak
2016-05-23 18:21     ` Ville Syrjälä
2016-05-23 18:21 ` [PATCH 00/21] drm/i915: SKL/KBL/BXT cdclk stuff Ville Syrjälä

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=1463172100-24715-9-git-send-email-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.