Skip to contentSkip to conversation

drm/i915: fix DDI PLLs HW state readout code

PATCH In review Paulo Zanoni 4 participants 9 messages Jan 8, 2014

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

PATCH 1/2 drm/i915: fix DDI PLLs HW state readout code

From: Paulo Zanoni <[email protected]>

Properly zero the refcounts and crtc->ddi_pll_set so the previous HW state doesn't affect the result of reading the current HW state.

This fixes WARNs about WRPLL refcount if we have an HDMI monitor on HSW and then suspend/resume.

Cc: [email protected]
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=64379

---
 drivers/gpu/drm/i915/intel_ddi.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_ddi.c +7 -1
index 4ec1665..0def5ef 100644
@@ -1136,12 +1136,18 @@ void intel_ddi_setup_hw_pll_state(struct drm_device *dev)
 	enum pipe pipe;
 	struct intel_crtc *intel_crtc;
 
+	dev_priv->ddi_plls.spll_refcount = 0;
+	dev_priv->ddi_plls.wrpll1_refcount = 0;
+	dev_priv->ddi_plls.wrpll2_refcount = 0;
+
 	for_each_pipe(pipe) {
 		intel_crtc =
 			to_intel_crtc(dev_priv->pipe_to_crtc_mapping[pipe]);
 
-		if (!intel_crtc->active)
+		if (!intel_crtc->active) {
+			intel_crtc->ddi_pll_sel = PORT_CLK_SEL_NONE;
 			continue;
+		}
 
 		intel_crtc->ddi_pll_sel = intel_ddi_get_crtc_pll(dev_priv,
 								 pipe);
Signature · 1 line
1.8.4.2
#1 lore raw

PATCH 2/2 drm/i915: fix wrong PLL debug messages.

From: Paulo Zanoni <[email protected]>

LPT does have PCH refclk, but it's different form the IBX/CPT/PPT one and doesn't use the same structs. It is wrong to have a message saying that "LPT does not has PCH refclk" (sic). While at it, signal that we only want this function on IBX/CPT/PPT by renaming it and adding a WARN.

On HSW we also print "0 shared PLLs initialized", but we *do* have shared PLLs on HSW (LCPLL, WRPLL, SPLL) and we *do* initialize them. We just don't use "struct intel_shared_dpll". So remove the debug message.

In the future we may want to rename all that "intel shared pll" code to "ibx shared pll", but I'll leave this to another patch.

---
 drivers/gpu/drm/i915/intel_display.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)
drivers/gpu/drm/i915/intel_display.c +3 -8
index 034952c..df3cf69 100644
@@ -1211,15 +1211,12 @@ static void assert_sprites_disabled(struct drm_i915_private *dev_priv,
 	}
 }
 
-static void assert_pch_refclk_enabled(struct drm_i915_private *dev_priv)
+static void ibx_assert_pch_refclk_enabled(struct drm_i915_private *dev_priv)
 {
 	u32 val;
 	bool enabled;
 
-	if (HAS_PCH_LPT(dev_priv->dev)) {
-		DRM_DEBUG_DRIVER("LPT does not has PCH refclk, skipping check\n");
-		return;
-	}
+	WARN_ON(!(HAS_PCH_IBX(dev_priv->dev) || HAS_PCH_CPT(dev_priv->dev)));
 
 	val = I915_READ(PCH_DREF_CONTROL);
 	enabled = !!(val & (DREF_SSC_SOURCE_MASK | DREF_NONSPREAD_SOURCE_MASK |
@@ -10067,7 +10064,7 @@ static void ibx_pch_dpll_enable(struct drm_i915_private *dev_priv,
 				struct intel_shared_dpll *pll)
 {
 	/* PCH refclock must be enabled first */
-	assert_pch_refclk_enabled(dev_priv);
+	ibx_assert_pch_refclk_enabled(dev_priv);
 
 	I915_WRITE(PCH_DPLL(pll->id), pll->hw_state.dpll);
 
@@ -10135,8 +10132,6 @@ static void intel_shared_dpll_init(struct drm_device *dev)
 		dev_priv->num_shared_dpll = 0;
 
 	BUG_ON(dev_priv->num_shared_dpll > I915_NUM_PLLS);
-	DRM_DEBUG_KMS("%i shared PLLs initialized\n",
-		      dev_priv->num_shared_dpll);
 }
 
 static void intel_crtc_init(struct drm_device *dev, int pipe)
Signature · 1 line
1.8.4.2
Reviewed-by on v1 1/2
#4 lore raw
In reply to Paulo Zanoni
Quoted 5 lines · Paulo Zanoni

From: Paulo Zanoni <[email protected]>

Properly zero the refcounts and crtc->ddi_pll_set so the previous HW state doesn't affect the result of reading the current HW state.

Quoted 7 lines

This fixes WARNs about WRPLL refcount if we have an HDMI monitor on HSW and then suspend/resume.

Cc: [email protected]
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=64379

Signature · 1 line
Damien
Quoted 35 lines
---
 drivers/gpu/drm/i915/intel_ddi.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_ddi.c +7 -1
index 4ec1665..0def5ef 100644
@@ -1136,12 +1136,18 @@ void intel_ddi_setup_hw_pll_state(struct drm_device *dev)
 	enum pipe pipe;
 	struct intel_crtc *intel_crtc;
 
+	dev_priv->ddi_plls.spll_refcount = 0;
+	dev_priv->ddi_plls.wrpll1_refcount = 0;
+	dev_priv->ddi_plls.wrpll2_refcount = 0;
+
 	for_each_pipe(pipe) {
 		intel_crtc =
 			to_intel_crtc(dev_priv->pipe_to_crtc_mapping[pipe]);
 
-		if (!intel_crtc->active)
+		if (!intel_crtc->active) {
+			intel_crtc->ddi_pll_sel = PORT_CLK_SEL_NONE;
 			continue;
+		}
 
 		intel_crtc->ddi_pll_sel = intel_ddi_get_crtc_pll(dev_priv,
 								 pipe);
Signature · 6 lines
1.8.4.2

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

Re: [PATCH 2/2] drm/i915: fix wrong PLL debug messages.

In reply to Paulo Zanoni
Quoted 8 lines · Paulo Zanoni

From: Paulo Zanoni <[email protected]>

LPT does have PCH refclk, but it's different form the IBX/CPT/PPT one and doesn't use the same structs. It is wrong to have a message saying that "LPT does not has PCH refclk" (sic). While at it, signal that we only want this function on IBX/CPT/PPT by renaming it and adding a WARN.

Quoted 7 lines

On HSW we also print "0 shared PLLs initialized", but we *do* have shared PLLs on HSW (LCPLL, WRPLL, SPLL) and we *do* initialize them. We just don't use "struct intel_shared_dpll". So remove the debug message.

In the future we may want to rename all that "intel shared pll" code to "ibx shared pll", but I'll leave this to another patch.

I remember Daniel saying that his plan was to make the DDI clocks use the shared PLL struct. I guess that'd take care of the debug message correctness.

So I defer this one to higher authorities, you have my r-b tag as the patch makes sense, not sure if Daniel will take it though :)

Quoted 52 lines
---
 drivers/gpu/drm/i915/intel_display.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)
drivers/gpu/drm/i915/intel_display.c +3 -8
index 034952c..df3cf69 100644
@@ -1211,15 +1211,12 @@ static void assert_sprites_disabled(struct drm_i915_private *dev_priv,
 	}
 }
 
-static void assert_pch_refclk_enabled(struct drm_i915_private *dev_priv)
+static void ibx_assert_pch_refclk_enabled(struct drm_i915_private *dev_priv)
 {
 	u32 val;
 	bool enabled;
 
-	if (HAS_PCH_LPT(dev_priv->dev)) {
-		DRM_DEBUG_DRIVER("LPT does not has PCH refclk, skipping check\n");
-		return;
-	}
+	WARN_ON(!(HAS_PCH_IBX(dev_priv->dev) || HAS_PCH_CPT(dev_priv->dev)));
 
 	val = I915_READ(PCH_DREF_CONTROL);
 	enabled = !!(val & (DREF_SSC_SOURCE_MASK | DREF_NONSPREAD_SOURCE_MASK |
@@ -10067,7 +10064,7 @@ static void ibx_pch_dpll_enable(struct drm_i915_private *dev_priv,
 				struct intel_shared_dpll *pll)
 {
 	/* PCH refclock must be enabled first */
-	assert_pch_refclk_enabled(dev_priv);
+	ibx_assert_pch_refclk_enabled(dev_priv);
 
 	I915_WRITE(PCH_DPLL(pll->id), pll->hw_state.dpll);
 
@@ -10135,8 +10132,6 @@ static void intel_shared_dpll_init(struct drm_device *dev)
 		dev_priv->num_shared_dpll = 0;
 
 	BUG_ON(dev_priv->num_shared_dpll > I915_NUM_PLLS);
-	DRM_DEBUG_KMS("%i shared PLLs initialized\n",
-		      dev_priv->num_shared_dpll);
 }
 
 static void intel_crtc_init(struct drm_device *dev, int pipe)
Signature · 6 lines
1.8.4.2

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#5 lore raw
In reply to Paulo Zanoni
Quoted 21 lines · Paulo Zanoni

From: Paulo Zanoni <[email protected]>

Properly zero the refcounts and crtc->ddi_pll_set so the previous HW state doesn't affect the result of reading the current HW state.

This fixes WARNs about WRPLL refcount if we have an HDMI monitor on HSW and then suspend/resume.

Cc: [email protected]
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=64379

---
 drivers/gpu/drm/i915/intel_ddi.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_ddi.c +0 -0
index 4ec1665..0def5ef 100644

drivers/gpu/drm/i915/intel_ddi.c void intel_ddi_setup_hw_pll_state(struct drm_device *dev) · line 1141

Quoted 6 lines
drivers/gpu/drm/i915/intel_ddi.c +3 -0
@@ -1136,12 +1136,18 @@ void intel_ddi_setup_hw_pll_state(struct drm_device *dev)
 	enum pipe pipe;
 	struct intel_crtc *intel_crtc;
 
+	dev_priv->ddi_plls.spll_refcount = 0;
+	dev_priv->ddi_plls.wrpll1_refcount = 0;
+	dev_priv->ddi_plls.wrpll2_refcount = 0;

One idea I have for the longer-term is to unify the ddi pll refcounting/readout stuff with the logic I've created for shared pch plls. The pch pll sharing checks and refcount logic is now really solid and completely paranoid with self-checks, and it took about 10 iterations to get there in a mostly bug-free manner. It looks a bit like ddi pll sharing is on track to duplicate that, so merging them would be benificial. It might also help the state pre-computation stuff we still need to do for plls.

Anyway, patch merged to -fixes (but I'll probably only get in after 3.14 is out).
-Daniel

Quoted 20 lines
drivers/gpu/drm/i915/intel_ddi.c +4 -1
+
 	for_each_pipe(pipe) {
 		intel_crtc =
 			to_intel_crtc(dev_priv->pipe_to_crtc_mapping[pipe]);
 
-		if (!intel_crtc->active)
+		if (!intel_crtc->active) {
+			intel_crtc->ddi_pll_sel = PORT_CLK_SEL_NONE;
 			continue;
+		}
 
 		intel_crtc->ddi_pll_sel = intel_ddi_get_crtc_pll(dev_priv,
 								 pipe);
Signature · 6 lines
1.8.4.2

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#6 lore raw
Quoted 25 lines · Daniel Vetter
Quoted 24 lines · Paulo Zanoni

From: Paulo Zanoni <[email protected]>

Properly zero the refcounts and crtc->ddi_pll_set so the previous HW state doesn't affect the result of reading the current HW state.

This fixes WARNs about WRPLL refcount if we have an HDMI monitor on HSW and then suspend/resume.

Cc: [email protected]
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=64379

---
 drivers/gpu/drm/i915/intel_ddi.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_ddi.c +0 -0
index 4ec1665..0def5ef 100644
@@ -1136,12 +1136,18 @@ void intel_ddi_setup_hw_pll_state(struct drm_device *dev)
 	enum pipe pipe;
 	struct intel_crtc *intel_crtc;
 
Quoted 12 lines

drivers/gpu/drm/i915/intel_ddi.c void intel_ddi_setup_hw_pll_state(struct drm_device *dev) · line 1141

Quoted 3 lines
drivers/gpu/drm/i915/intel_ddi.c +3 -0
+	dev_priv->ddi_plls.spll_refcount = 0;
+	dev_priv->ddi_plls.wrpll1_refcount = 0;
+	dev_priv->ddi_plls.wrpll2_refcount = 0;

One idea I have for the longer-term is to unify the ddi pll refcounting/readout stuff with the logic I've created for shared pch plls. The pch pll sharing checks and refcount logic is now really solid and completely paranoid with self-checks, and it took about 10 iterations to get there in a mostly bug-free manner. It looks a bit like ddi pll sharing is on track to duplicate that, so merging them would be benificial. It might also help the state pre-computation stuff we still need to do for plls.

We might also want to look into PLL sharing on VLV as well.

Signature · 2 lines
Ville Syrjälä
Intel OTC
#7 lore raw
In reply to Daniel Vetter

2014/1/8 Daniel Vetter <[email protected]>:

Quoted 25 lines · Paulo Zanoni
Quoted 24 lines

From: Paulo Zanoni <[email protected]>

Properly zero the refcounts and crtc->ddi_pll_set so the previous HW state doesn't affect the result of reading the current HW state.

This fixes WARNs about WRPLL refcount if we have an HDMI monitor on HSW and then suspend/resume.

Cc: [email protected]
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=64379

---
 drivers/gpu/drm/i915/intel_ddi.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_ddi.c +0 -0
index 4ec1665..0def5ef 100644
@@ -1136,12 +1136,18 @@ void intel_ddi_setup_hw_pll_state(struct drm_device *dev)
      enum pipe pipe;
      struct intel_crtc *intel_crtc;
 
Quoted 12 lines

drivers/gpu/drm/i915/intel_ddi.c void intel_ddi_setup_hw_pll_state(struct drm_device *dev) · line 1141

Quoted 3 lines
drivers/gpu/drm/i915/intel_ddi.c +3 -0
+     dev_priv->ddi_plls.spll_refcount = 0;
+     dev_priv->ddi_plls.wrpll1_refcount = 0;
+     dev_priv->ddi_plls.wrpll2_refcount = 0;

One idea I have for the longer-term is to unify the ddi pll refcounting/readout stuff with the logic I've created for shared pch plls. The pch pll sharing checks and refcount logic is now really solid and completely paranoid with self-checks, and it took about 10 iterations to get there in a mostly bug-free manner. It looks a bit like ddi pll sharing is on track to duplicate that, so merging them would be benificial. It might also help the state pre-computation stuff we still need to do for plls.

I'm aware that's your plan, but I'm not really sure if the advantages beat the disadvantages. Also, I remember you said you were going to implement that, so I was waiting.

I had just written a huge list of reasons explaining why I think we shouldn't do what you suggested, but I erased it because I know I'm going to get flamed: merging code like this is always better in theory.

I also think we should consider doing the other way around: making IBX/CPT/PPT code follow the HSW implementation model, because the HSW implementation IMHO looks much simpler and easier to understand.

Quoted 30 lines

Anyway, patch merged to -fixes (but I'll probably only get in after 3.14 is out).
-Daniel

Quoted 16 lines
drivers/gpu/drm/i915/intel_ddi.c +4 -2
+
      for_each_pipe(pipe) {
              intel_crtc =
                      to_intel_crtc(dev_priv->pipe_to_crtc_mapping[pipe]);
 
-             if (!intel_crtc->active)
+             if (!intel_crtc->active) {
+                     intel_crtc->ddi_pll_sel = PORT_CLK_SEL_NONE;
                      continue;
+             }
 
              intel_crtc->ddi_pll_sel = intel_ddi_get_crtc_pll(dev_priv,
                                                               pipe);
--

1.8.4.2

Quoted 4 lines

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

--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

Signature · 1 line
Paulo Zanoni
#8 lore raw
Quoted 39 lines · Paulo Zanoni

2014/1/8 Daniel Vetter <[email protected]>:

Quoted 25 lines · Paulo Zanoni
Quoted 24 lines

From: Paulo Zanoni <[email protected]>

Properly zero the refcounts and crtc->ddi_pll_set so the previous HW state doesn't affect the result of reading the current HW state.

This fixes WARNs about WRPLL refcount if we have an HDMI monitor on HSW and then suspend/resume.

Cc: [email protected]
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=64379

---
 drivers/gpu/drm/i915/intel_ddi.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_ddi.c +0 -0
index 4ec1665..0def5ef 100644
@@ -1136,12 +1136,18 @@ void intel_ddi_setup_hw_pll_state(struct drm_device *dev)
      enum pipe pipe;
      struct intel_crtc *intel_crtc;
 
Quoted 12 lines

drivers/gpu/drm/i915/intel_ddi.c void intel_ddi_setup_hw_pll_state(struct drm_device *dev) · line 1141

Quoted 3 lines
drivers/gpu/drm/i915/intel_ddi.c +3 -0
+     dev_priv->ddi_plls.spll_refcount = 0;
+     dev_priv->ddi_plls.wrpll1_refcount = 0;
+     dev_priv->ddi_plls.wrpll2_refcount = 0;

One idea I have for the longer-term is to unify the ddi pll refcounting/readout stuff with the logic I've created for shared pch plls. The pch pll sharing checks and refcount logic is now really solid and completely paranoid with self-checks, and it took about 10 iterations to get there in a mostly bug-free manner. It looks a bit like ddi pll sharing is on track to duplicate that, so merging them would be benificial. It might also help the state pre-computation stuff we still need to do for plls.

Quoted 3 lines

I'm aware that's your plan, but I'm not really sure if the advantages beat the disadvantages. Also, I remember you said you were going to implement that, so I was waiting.

Well there's lots of stuff somewhere on my todo continually falling off the end. So if you have some spare bandwidth just ping to make sure I don't start at the same time. Otherwise I don't mind at all if people steal my todo items ;-)

Quoted 8 lines

I had just written a huge list of reasons explaining why I think we shouldn't do what you suggested, but I erased it because I know I'm going to get flamed: merging code like this is always better in theory.

I also think we should consider doing the other way around: making IBX/CPT/PPT code follow the HSW implementation model, because the HSW implementation IMHO looks much simpler and easier to understand.

Yeah, it's fairly complex and abstracted since the older code was imo too fragile. Imo the separation between the hw enable/disable code and the refcounting/checking is fairly nice.

But it sounds like you disagree, so I really want to hear your reasons and objections. Can you please dig them out again?
-Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#3 lore raw

Re: [PATCH 2/2] drm/i915: fix wrong PLL debug messages.

In reply to Damien Lespiau

2014/1/8 Damien Lespiau <[email protected]>:

Quoted 14 lines · Paulo Zanoni
Quoted 13 lines

From: Paulo Zanoni <[email protected]>

LPT does have PCH refclk, but it's different form the IBX/CPT/PPT one and doesn't use the same structs. It is wrong to have a message saying that "LPT does not has PCH refclk" (sic). While at it, signal that we only want this function on IBX/CPT/PPT by renaming it and adding a WARN.

On HSW we also print "0 shared PLLs initialized", but we *do* have shared PLLs on HSW (LCPLL, WRPLL, SPLL) and we *do* initialize them. We just don't use "struct intel_shared_dpll". So remove the debug message.

Quoted 6 lines
Quoted 2 lines

In the future we may want to rename all that "intel shared pll" code to "ibx shared pll", but I'll leave this to another patch.

I remember Daniel saying that his plan was to make the DDI clocks use the shared PLL struct. I guess that'd take care of the debug message correctness.

Yes, but there's currently no plan actually do that conversion, so we'll stay with wrong messages for an undefined amount of time. The first message I removed is not even ever print, and the second message always prints "2" for IBX/CPT/PPT and 0 for LPT+: you can easily check that by looking at the code, so the messages are not even useful.

Thanks for the reviews!
Paulo

Quoted 56 lines

So I defer this one to higher authorities, you have my r-b tag as the patch makes sense, not sure if Daniel will take it though :)

Quoted 52 lines
---
 drivers/gpu/drm/i915/intel_display.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)
drivers/gpu/drm/i915/intel_display.c +3 -9
index 034952c..df3cf69 100644
@@ -1211,15 +1211,12 @@ static void assert_sprites_disabled(struct drm_i915_private *dev_priv,
      }
 }
 
-static void assert_pch_refclk_enabled(struct drm_i915_private *dev_priv)
+static void ibx_assert_pch_refclk_enabled(struct drm_i915_private *dev_priv)
 {
      u32 val;
      bool enabled;
 
-     if (HAS_PCH_LPT(dev_priv->dev)) {
-             DRM_DEBUG_DRIVER("LPT does not has PCH refclk, skipping check\n");
-             return;
-     }
+     WARN_ON(!(HAS_PCH_IBX(dev_priv->dev) || HAS_PCH_CPT(dev_priv->dev)));
 
      val = I915_READ(PCH_DREF_CONTROL);
      enabled = !!(val & (DREF_SSC_SOURCE_MASK | DREF_NONSPREAD_SOURCE_MASK |
@@ -10067,7 +10064,7 @@ static void ibx_pch_dpll_enable(struct drm_i915_private *dev_priv,
                              struct intel_shared_dpll *pll)
 {
      /* PCH refclock must be enabled first */
-     assert_pch_refclk_enabled(dev_priv);
+     ibx_assert_pch_refclk_enabled(dev_priv);
 
      I915_WRITE(PCH_DPLL(pll->id), pll->hw_state.dpll);
 
@@ -10135,8 +10132,6 @@ static void intel_shared_dpll_init(struct drm_device *dev)
              dev_priv->num_shared_dpll = 0;
 
      BUG_ON(dev_priv->num_shared_dpll > I915_NUM_PLLS);
-     DRM_DEBUG_KMS("%i shared PLLs initialized\n",
-                   dev_priv->num_shared_dpll);
 }
 
 static void intel_crtc_init(struct drm_device *dev, int pipe)
--

1.8.4.2

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

Signature · 1 line
Paulo Zanoni