Skip to contentSkip to conversation

drm/i915: manage PCH PLLs separately from pipes

PATCH New Jesse Barnes 3 participants 7 messages Apr 11, 2012 – Apr 20, 2012

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

PATCH 1/1 drm/i915: manage PCH PLLs separately from pipes

PCH PLLs aren't required for outputs on the CPU, so we shouldn't just treat them as part of the pipe.

So split the code out and manage PCH PLLs separately, allocating them when needed or trying to re-use existing PCH PLL setups when the timings match.

v2: add num_pch_pll field to dev_priv (Daniel)
don't NULL the pch_pll pointer in disable or DPMS will fail (Jesse) put register offsets in pll struct (Chris)

NOTE: this still has what looks like an enable order bug; every other
mode set on a 3 pipe config works as expected, but in between one or more of the heads won't come up

Fixes https://bugs.freedesktop.org/show_bug.cgi?id=44309

---
 drivers/gpu/drm/i915/i915_drv.c      |    4 +
 drivers/gpu/drm/i915/i915_drv.h      |    3 +
 drivers/gpu/drm/i915/i915_reg.h      |    6 +-
 drivers/gpu/drm/i915/i915_suspend.c  |    2 +-
 drivers/gpu/drm/i915/intel_display.c |  198 ++++++++++++++++++++++------------
 drivers/gpu/drm/i915/intel_dp.c      |    1 +
 drivers/gpu/drm/i915/intel_drv.h     |   11 ++-
 7 files changed, 150 insertions(+), 75 deletions(-)
drivers/gpu/drm/i915/i915_drv.c +4 -0
index 3effcf7..355bd68 100644
@@ -377,16 +377,20 @@ void intel_detect_pch(struct drm_device *dev)
 
 			if (id == INTEL_PCH_IBX_DEVICE_ID_TYPE) {
 				dev_priv->pch_type = PCH_IBX;
+				dev_priv->num_pch_pll = 2;
 				DRM_DEBUG_KMS("Found Ibex Peak PCH\n");
 			} else if (id == INTEL_PCH_CPT_DEVICE_ID_TYPE) {
 				dev_priv->pch_type = PCH_CPT;
+				dev_priv->num_pch_pll = 2;
 				DRM_DEBUG_KMS("Found CougarPoint PCH\n");
 			} else if (id == INTEL_PCH_PPT_DEVICE_ID_TYPE) {
 				/* PantherPoint is CPT compatible */
 				dev_priv->pch_type = PCH_CPT;
+				dev_priv->num_pch_pll = 2;
 				DRM_DEBUG_KMS("Found PatherPoint PCH\n");
 			} else if (id == INTEL_PCH_LPT_DEVICE_ID_TYPE) {
 				dev_priv->pch_type = PCH_LPT;
+				dev_priv->num_pch_pll = 0;
 				DRM_DEBUG_KMS("Found LynxPoint PCH\n");
 			}
 		}
drivers/gpu/drm/i915/i915_drv.h +3 -0
index 422f424..68add98 100644
@@ -392,6 +392,7 @@ typedef struct drm_i915_private {
 	unsigned int sr01, adpa, ppcr, dvob, dvoc, lvds;
 	int vblank_pipe;
 	int num_pipe;
+	int num_pch_pll;
 
 	/* For hangcheck timer */
 #define DRM_I915_HANGCHECK_PERIOD 1500 /* in ms */
@@ -754,6 +755,8 @@ typedef struct drm_i915_private {
 	wait_queue_head_t pending_flip_queue;
 	bool flip_pending_is_done;
 
+	struct intel_pch_pll *pch_plls;
+
 	/* Reclocking support */
 	bool render_reclock_avail;
 	bool lvds_downclock_avail;
drivers/gpu/drm/i915/i915_reg.h +3 -3
index 972321f..96449b7 100644
@@ -3370,15 +3370,15 @@
 
 #define _PCH_DPLL_A              0xc6014
 #define _PCH_DPLL_B              0xc6018
-#define PCH_DPLL(pipe) (pipe == 0 ?  _PCH_DPLL_A : _PCH_DPLL_B)
+#define _PCH_DPLL(pll) (pll == 0 ?  _PCH_DPLL_A : _PCH_DPLL_B)
 
 #define _PCH_FPA0                0xc6040
 #define  FP_CB_TUNE		(0x3<<22)
 #define _PCH_FPA1                0xc6044
 #define _PCH_FPB0                0xc6048
 #define _PCH_FPB1                0xc604c
-#define PCH_FP0(pipe) (pipe == 0 ? _PCH_FPA0 : _PCH_FPB0)
-#define PCH_FP1(pipe) (pipe == 0 ? _PCH_FPA1 : _PCH_FPB1)
+#define _PCH_FP0(pll) (pll == 0 ? _PCH_FPA0 : _PCH_FPB0)
+#define _PCH_FP1(pll) (pll == 0 ? _PCH_FPA1 : _PCH_FPB1)
 
 #define PCH_DPLL_TEST           0xc606c
 
drivers/gpu/drm/i915/i915_suspend.c +1 -1
index 0c3e3bf..73a5c3c 100644
@@ -40,7 +40,7 @@ static bool i915_pipe_enabled(struct drm_device *dev, enum pipe pipe)
 		return false;
 
 	if (HAS_PCH_SPLIT(dev))
-		dpll_reg = PCH_DPLL(pipe);
+		dpll_reg = _PCH_DPLL(pipe);
 	else
 		dpll_reg = (pipe == PIPE_A) ? _DPLL_A : _DPLL_B;
 
drivers/gpu/drm/i915/intel_display.c +129 -69

334 lines not on this page · raw message

drivers/gpu/drm/i915/intel_dp.c +1 -0
index 6346b29..f07652b 100644
@@ -2417,6 +2417,7 @@ intel_dp_init(struct drm_device *dev, int output_reg)
 	}
 
 	intel_encoder->crtc_mask = (1 << 0) | (1 << 1) | (1 << 2);
+
 	connector->interlace_allowed = true;
 	connector->doublescan_allowed = 0;
 
drivers/gpu/drm/i915/intel_drv.h +9 -2
index 79cabf5..5ae8bff 100644
@@ -158,6 +158,14 @@ struct intel_connector {
 	struct intel_encoder *encoder;
 };
 
+/* We can share PLLs across outputs if the timings match */
+struct intel_pch_pll {
+	int pll_reg;
+	int fp0_reg;
+	int fp1_reg;
+	int refcount;
+};
+
 struct intel_crtc {
 	struct drm_crtc base;
 	enum pipe pipe;
@@ -179,8 +187,7 @@ struct intel_crtc {
 	bool cursor_visible;
 	unsigned int bpp;
 
-	bool no_pll; /* tertiary pipe for IVB */
-	bool use_pll_a;
+	struct intel_pch_pll *pch_pll; /* If any */
 };
 
 struct intel_plane {
Signature · 1 line
1.7.4.1
#1 lore raw

PATCH 1/1 drm/i915: manage PCH PLLs separately from pipes

From: Jesse Barnes <[email protected]>

PCH PLLs aren't required for outputs on the CPU, so we shouldn't just treat them as part of the pipe.

So split the code out and manage PCH PLLs separately, allocating them when needed or trying to re-use existing PCH PLL setups when the timings match.

v2: add num_pch_pll field to dev_priv (Daniel)
don't NULL the pch_pll pointer in disable or DPMS will fail (Jesse) put register offsets in pll struct (Chris)

v3: Decouple enable/disable of PLLs from get/put.

Fixes https://bugs.freedesktop.org/show_bug.cgi?id=44309

---
 drivers/gpu/drm/i915/i915_drv.c      |    4 +
 drivers/gpu/drm/i915/i915_drv.h      |    4 +
 drivers/gpu/drm/i915/i915_reg.h      |    6 +-
 drivers/gpu/drm/i915/i915_suspend.c  |    2 +-
 drivers/gpu/drm/i915/intel_display.c |  243 +++++++++++++++++++++++-----------
 drivers/gpu/drm/i915/intel_dp.c      |    1 +
 drivers/gpu/drm/i915/intel_drv.h     |   12 ++-
 7 files changed, 189 insertions(+), 83 deletions(-)
drivers/gpu/drm/i915/i915_drv.c +4 -0
index b66bf5e..504db72 100644
@@ -381,16 +381,20 @@ void intel_detect_pch(struct drm_device *dev)
 
 			if (id == INTEL_PCH_IBX_DEVICE_ID_TYPE) {
 				dev_priv->pch_type = PCH_IBX;
+				dev_priv->num_pch_pll = 2;
 				DRM_DEBUG_KMS("Found Ibex Peak PCH\n");
 			} else if (id == INTEL_PCH_CPT_DEVICE_ID_TYPE) {
 				dev_priv->pch_type = PCH_CPT;
+				dev_priv->num_pch_pll = 2;
 				DRM_DEBUG_KMS("Found CougarPoint PCH\n");
 			} else if (id == INTEL_PCH_PPT_DEVICE_ID_TYPE) {
 				/* PantherPoint is CPT compatible */
 				dev_priv->pch_type = PCH_CPT;
+				dev_priv->num_pch_pll = 2;
 				DRM_DEBUG_KMS("Found PatherPoint PCH\n");
 			} else if (id == INTEL_PCH_LPT_DEVICE_ID_TYPE) {
 				dev_priv->pch_type = PCH_LPT;
+				dev_priv->num_pch_pll = 0;
 				DRM_DEBUG_KMS("Found LynxPoint PCH\n");
 			}
 		}
drivers/gpu/drm/i915/i915_drv.h +4 -0
index 057169a..902f918 100644
@@ -233,6 +233,7 @@ struct drm_i915_display_funcs {
 			     struct drm_display_mode *adjusted_mode,
 			     int x, int y,
 			     struct drm_framebuffer *old_fb);
+	void (*off)(struct drm_crtc *crtc);
 	void (*write_eld)(struct drm_connector *connector,
 			  struct drm_crtc *crtc);
 	void (*fdi_link_train)(struct drm_crtc *crtc);
@@ -394,6 +395,7 @@ typedef struct drm_i915_private {
 	unsigned int sr01, adpa, ppcr, dvob, dvoc, lvds;
 	int vblank_pipe;
 	int num_pipe;
+	int num_pch_pll;
 
 	/* For hangcheck timer */
 #define DRM_I915_HANGCHECK_PERIOD 1500 /* in ms */
@@ -749,6 +751,8 @@ typedef struct drm_i915_private {
 	wait_queue_head_t pending_flip_queue;
 	bool flip_pending_is_done;
 
+	struct intel_pch_pll *pch_plls;
+
 	/* Reclocking support */
 	bool render_reclock_avail;
 	bool lvds_downclock_avail;
drivers/gpu/drm/i915/i915_reg.h +3 -3
index 4c8243e..418aa27 100644
@@ -3374,15 +3374,15 @@
 
 #define _PCH_DPLL_A              0xc6014
 #define _PCH_DPLL_B              0xc6018
-#define PCH_DPLL(pipe) (pipe == 0 ?  _PCH_DPLL_A : _PCH_DPLL_B)
+#define _PCH_DPLL(pll) (pll == 0 ? _PCH_DPLL_A : _PCH_DPLL_B)
 
 #define _PCH_FPA0                0xc6040
 #define  FP_CB_TUNE		(0x3<<22)
 #define _PCH_FPA1                0xc6044
 #define _PCH_FPB0                0xc6048
 #define _PCH_FPB1                0xc604c
-#define PCH_FP0(pipe) (pipe == 0 ? _PCH_FPA0 : _PCH_FPB0)
-#define PCH_FP1(pipe) (pipe == 0 ? _PCH_FPA1 : _PCH_FPB1)
+#define _PCH_FP0(pll) (pll == 0 ? _PCH_FPA0 : _PCH_FPB0)
+#define _PCH_FP1(pll) (pll == 0 ? _PCH_FPA1 : _PCH_FPB1)
 
 #define PCH_DPLL_TEST           0xc606c
 
drivers/gpu/drm/i915/i915_suspend.c +1 -1
index 0c3e3bf..73a5c3c 100644
@@ -40,7 +40,7 @@ static bool i915_pipe_enabled(struct drm_device *dev, enum pipe pipe)
 		return false;
 
 	if (HAS_PCH_SPLIT(dev))
-		dpll_reg = PCH_DPLL(pipe);
+		dpll_reg = _PCH_DPLL(pipe);
 	else
 		dpll_reg = (pipe == PIPE_A) ? _DPLL_A : _DPLL_B;
 
drivers/gpu/drm/i915/intel_display.c +166 -77

406 lines not on this page · raw message

drivers/gpu/drm/i915/intel_dp.c +1 -0
index 6346b29..f07652b 100644
@@ -2417,6 +2417,7 @@ intel_dp_init(struct drm_device *dev, int output_reg)
 	}
 
 	intel_encoder->crtc_mask = (1 << 0) | (1 << 1) | (1 << 2);
+
 	connector->interlace_allowed = true;
 	connector->doublescan_allowed = 0;
 
drivers/gpu/drm/i915/intel_drv.h +10 -2
index 1f073f0..bcc7da5 100644
@@ -158,6 +158,15 @@ struct intel_connector {
 	struct intel_encoder *encoder;
 };
 
+/* We can share PLLs across outputs if the timings match */
+struct intel_pch_pll {
+	int refcount;
+	int active;
+	int pll_reg;
+	int fp0_reg;
+	int fp1_reg;
+};
+
 struct intel_crtc {
 	struct drm_crtc base;
 	enum pipe pipe;
@@ -182,8 +191,7 @@ struct intel_crtc {
 	bool cursor_visible;
 	unsigned int bpp;
 
-	bool no_pll; /* tertiary pipe for IVB */
-	bool use_pll_a;
+	struct intel_pch_pll *pch_pll; /* If any */
 };
 
 struct intel_plane {
Signature · 1 line
1.7.9.1
#2 lore raw
Quoted 13 lines · On Fri, 13 Apr 2012 18:24:38 +0100 Chris Wilson <[email protected]>…

From: Jesse Barnes <[email protected]>

PCH PLLs aren't required for outputs on the CPU, so we shouldn't just treat them as part of the pipe.

So split the code out and manage PCH PLLs separately, allocating them when needed or trying to re-use existing PCH PLL setups when the timings match.

v2: add num_pch_pll field to dev_priv (Daniel)
don't NULL the pch_pll pointer in disable or DPMS will fail (Jesse) put register offsets in pll struct (Chris)

Quoted 7 lines

v3: Decouple enable/disable of PLLs from get/put.

Fixes https://bugs.freedesktop.org/show_bug.cgi?id=44309

---

I think this one can be applied. I still have a mode setting issue, but this patch at least lets me see the error rather than hiding it behind an -EINVAL.

Any my issue could be due to some early hardware anyway; I'll verify once I get my upgrade.

Thanks,

Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
#3 lore raw
In reply to Chris Wilson
Quoted 13 lines · Chris Wilson

From: Jesse Barnes <[email protected]>

PCH PLLs aren't required for outputs on the CPU, so we shouldn't just treat them as part of the pipe.

So split the code out and manage PCH PLLs separately, allocating them when needed or trying to re-use existing PCH PLL setups when the timings match.

v2: add num_pch_pll field to dev_priv (Daniel)
don't NULL the pch_pll pointer in disable or DPMS will fail (Jesse) put register offsets in pll struct (Chris)

Quoted 6 lines

v3: Decouple enable/disable of PLLs from get/put.

Fixes https://bugs.freedesktop.org/show_bug.cgi?id=44309

Patch applied to dinq with Jesse's irc reviewed-by and tested-by, thanks for the patch.
-Daniel

Signature · 3 lines
Daniel Vetter
Mail: [email protected]
Mobile: +41 (0)79 365 57 48
#4 lore raw
Quoted 16 lines · Daniel Vetter
Quoted 15 lines · Chris Wilson

From: Jesse Barnes <[email protected]>

PCH PLLs aren't required for outputs on the CPU, so we shouldn't just treat them as part of the pipe.

So split the code out and manage PCH PLLs separately, allocating them when needed or trying to re-use existing PCH PLL setups when the timings match.

v2: add num_pch_pll field to dev_priv (Daniel)
don't NULL the pch_pll pointer in disable or DPMS will fail (Jesse) put register offsets in pll struct (Chris)

v3: Decouple enable/disable of PLLs from get/put.

Quoted 7 lines
Quoted 4 lines

Fixes https://bugs.freedesktop.org/show_bug.cgi?id=44309

Patch applied to dinq with Jesse's irc reviewed-by and tested-by, thanks for the patch.

QA reported that this blows up:

https://bugs.freedesktop.org/process_bug.cgi

I've taken this patch out of dinq again.
-Daniel

Signature · 3 lines
Daniel Vetter
Mail: [email protected]
Mobile: +41 (0)79 365 57 48