Skip to contentSkip to conversation

drm/i915: simplify intel_ddi_pll_select()

PATCH In review Paulo Zanoni 4 participants 10 messages Mar 21, 2017 – Mar 22, 2017

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

PATCH 1/1 drm/i915: simplify intel_ddi_pll_select()

Because {hsw,skl,bxt}_ddi_pll_select all pretty much do the same thing in slightly different ways. Replace everything with a simple copy of the function and inline it inside intle_ddi_pll_select().

---
 drivers/gpu/drm/i915/intel_ddi.c | 58 +++++-----------------------------------
 1 file changed, 7 insertions(+), 51 deletions(-)
drivers/gpu/drm/i915/intel_ddi.c +7 -51
index d8214ba..bd6fd0b 100644
@@ -1127,47 +1127,6 @@ void intel_ddi_clock_get(struct intel_encoder *encoder,
 		bxt_ddi_clock_get(encoder, pipe_config);
 }
 
-static bool
-hsw_ddi_pll_select(struct intel_crtc *intel_crtc,
-		   struct intel_crtc_state *crtc_state,
-		   struct intel_encoder *encoder)
-{
-	struct intel_shared_dpll *pll;
-
-	pll = intel_get_shared_dpll(intel_crtc, crtc_state,
-				    encoder);
-	if (!pll)
-		DRM_DEBUG_DRIVER("failed to find PLL for pipe %c\n",
-				 pipe_name(intel_crtc->pipe));
-
-	return pll;
-}
-
-static bool
-skl_ddi_pll_select(struct intel_crtc *intel_crtc,
-		   struct intel_crtc_state *crtc_state,
-		   struct intel_encoder *encoder)
-{
-	struct intel_shared_dpll *pll;
-
-	pll = intel_get_shared_dpll(intel_crtc, crtc_state, encoder);
-	if (pll == NULL) {
-		DRM_DEBUG_DRIVER("failed to find PLL for pipe %c\n",
-				 pipe_name(intel_crtc->pipe));
-		return false;
-	}
-
-	return true;
-}
-
-static bool
-bxt_ddi_pll_select(struct intel_crtc *intel_crtc,
-		   struct intel_crtc_state *crtc_state,
-		   struct intel_encoder *encoder)
-{
-	return !!intel_get_shared_dpll(intel_crtc, crtc_state, encoder);
-}
-
 /*
  * Tries to find a *shared* PLL for the CRTC and store it in
  * intel_crtc->ddi_pll_sel.
@@ -1178,19 +1137,16 @@ bxt_ddi_pll_select(struct intel_crtc *intel_crtc,
 bool intel_ddi_pll_select(struct intel_crtc *intel_crtc,
 			  struct intel_crtc_state *crtc_state)
 {
-	struct drm_i915_private *dev_priv = to_i915(intel_crtc->base.dev);
 	struct intel_encoder *encoder =
 		intel_ddi_get_crtc_new_encoder(crtc_state);
+	struct intel_shared_dpll *pll;
 
-	if (IS_GEN9_BC(dev_priv))
-		return skl_ddi_pll_select(intel_crtc, crtc_state,
-					  encoder);
-	else if (IS_GEN9_LP(dev_priv))
-		return bxt_ddi_pll_select(intel_crtc, crtc_state,
-					  encoder);
-	else
-		return hsw_ddi_pll_select(intel_crtc, crtc_state,
-					  encoder);
+	pll = intel_get_shared_dpll(intel_crtc, crtc_state, encoder);
+	if (!pll)
+		DRM_DEBUG_DRIVER("failed to find PLL for pipe %c\n",
+				  pipe_name(intel_crtc->pipe));
+
+	return pll;
 }
 
 void intel_ddi_set_pipe_settings(const struct intel_crtc_state *crtc_state)
Signature · 6 lines
2.7.4

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

✓ Fi.CI.BAT: success for drm/i915: simplify intel_ddi_pll_select()

== Series Details ==

== Series Details ==

Series: drm/i915: simplify intel_ddi_pll_select()
URL : https://patchwork.freedesktop.org/series/21639/
State : success

== Summary ==

Series 21639v1 drm/i915: simplify intel_ddi_pll_select()
https://patchwork.freedesktop.org/api/1.0/series/21639/revisions/1/mbox/

fi-bdw-5557u     total:278  pass:267  dwarn:0   dfail:0   fail:0   skip:11  time: 460s
fi-bsw-n3050     total:278  pass:239  dwarn:0   dfail:0   fail:0   skip:39  time: 584s
fi-bxt-j4205     total:278  pass:259  dwarn:0   dfail:0   fail:0   skip:19  time: 537s
fi-bxt-t5700     total:278  pass:258  dwarn:0   dfail:0   fail:0   skip:20  time: 549s
fi-byt-j1900     total:278  pass:251  dwarn:0   dfail:0   fail:0   skip:27  time: 504s
fi-byt-n2820     total:278  pass:247  dwarn:0   dfail:0   fail:0   skip:31  time: 505s
fi-hsw-4770      total:278  pass:262  dwarn:0   dfail:0   fail:0   skip:16  time: 444s
fi-hsw-4770r     total:278  pass:262  dwarn:0   dfail:0   fail:0   skip:16  time: 440s
fi-ilk-650       total:278  pass:228  dwarn:0   dfail:0   fail:0   skip:50  time: 439s
fi-ivb-3520m     total:278  pass:260  dwarn:0   dfail:0   fail:0   skip:18  time: 516s
fi-ivb-3770      total:278  pass:260  dwarn:0   dfail:0   fail:0   skip:18  time: 486s
fi-kbl-7500u     total:278  pass:260  dwarn:0   dfail:0   fail:0   skip:18  time: 483s
fi-skl-6260u     total:278  pass:268  dwarn:0   dfail:0   fail:0   skip:10  time: 476s
fi-skl-6700hq    total:278  pass:261  dwarn:0   dfail:0   fail:0   skip:17  time: 594s
fi-skl-6700k     total:278  pass:256  dwarn:4   dfail:0   fail:0   skip:18  time: 490s
fi-skl-6770hq    total:278  pass:268  dwarn:0   dfail:0   fail:0   skip:10  time: 517s
fi-snb-2520m     total:278  pass:250  dwarn:0   dfail:0   fail:0   skip:28  time: 559s
fi-snb-2600      total:278  pass:249  dwarn:0   dfail:0   fail:0   skip:29  time: 421s

d17b31b3444ecffa68be0c331a4b20078fd10ccf drm-tip: 2017y-03m-21d-17h-36m-49s UTC integration manifest f9a09b3 drm/i915: simplify intel_ddi_pll_select()

== Logs ==

For more details see: https://intel-gfx-ci.01.org/CI/Patchwork_4254/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#2 lore raw
In reply to Paulo Zanoni
Quoted 16 lines · Paulo Zanoni

Because {hsw,skl,bxt}_ddi_pll_select all pretty much do the same thing in slightly different ways. Replace everything with a simple copy of the function and inline it inside intle_ddi_pll_select().

---
 drivers/gpu/drm/i915/intel_ddi.c | 58 +++++-----------------------------------
 1 file changed, 7 insertions(+), 51 deletions(-)
drivers/gpu/drm/i915/intel_ddi.c +0 -0
index d8214ba..bd6fd0b 100644
@@ -1127,47 +1127,6 @@ void intel_ddi_clock_get(struct intel_encoder *encoder,
 		bxt_ddi_clock_get(encoder, pipe_config);
 }

drivers/gpu/drm/i915/intel_ddi.c void intel_ddi_clock_get(struct intel_encoder *encoder, · line 1138

Quoted 10 lines
drivers/gpu/drm/i915/intel_ddi.c +0 -9
 
-static bool
-hsw_ddi_pll_select(struct intel_crtc *intel_crtc,
-		   struct intel_crtc_state *crtc_state,
-		   struct intel_encoder *encoder)
-{
-	struct intel_shared_dpll *pll;
-
-	pll = intel_get_shared_dpll(intel_crtc, crtc_state,
-				    encoder);

I have a related question, not a patch review :) Looks like we care only about the boolean returned from intel_get_shared_dpll(). Could not find any caller that uses the returned 'struct intel_shared_dpll *'. Should it's signature be simply changed to return a bool?

-DK

Quoted 52 lines
drivers/gpu/drm/i915/intel_ddi.c +1 -41
-	if (!pll)
-		DRM_DEBUG_DRIVER("failed to find PLL for pipe %c\n",
-				 pipe_name(intel_crtc->pipe));
-
-	return pll;
-}
-
-static bool
-skl_ddi_pll_select(struct intel_crtc *intel_crtc,
-		   struct intel_crtc_state *crtc_state,
-		   struct intel_encoder *encoder)
-{
-	struct intel_shared_dpll *pll;
-
-	pll = intel_get_shared_dpll(intel_crtc, crtc_state, encoder);
-	if (pll == NULL) {
-		DRM_DEBUG_DRIVER("failed to find PLL for pipe %c\n",
-				 pipe_name(intel_crtc->pipe));
-		return false;
-	}
-
-	return true;
-}
-
-static bool
-bxt_ddi_pll_select(struct intel_crtc *intel_crtc,
-		   struct intel_crtc_state *crtc_state,
-		   struct intel_encoder *encoder)
-{
-	return !!intel_get_shared_dpll(intel_crtc, crtc_state, encoder);
-}
-
 /*
  * Tries to find a *shared* PLL for the CRTC and store it in
  * intel_crtc->ddi_pll_sel.
@@ -1178,19 +1137,16 @@ bxt_ddi_pll_select(struct intel_crtc *intel_crtc,
 bool intel_ddi_pll_select(struct intel_crtc *intel_crtc,
 			  struct intel_crtc_state *crtc_state)
 {
-	struct drm_i915_private *dev_priv = to_i915(intel_crtc->base.dev);
 	struct intel_encoder *encoder =
 		intel_ddi_get_crtc_new_encoder(crtc_state);
+	struct intel_shared_dpll *pll;
 
-	if (IS_GEN9_BC(dev_priv))
-		return skl_ddi_pll_select(intel_crtc, crtc_state,
-					  encoder);
-	else if (IS_GEN9_LP(dev_priv))
-		return bxt_ddi_pll_select(intel_crtc, crtc_state,
-					  encoder);
-	else
-		return hsw_ddi_pll_select(intel_crtc, crtc_state,

drivers/gpu/drm/i915/intel_ddi.c bxt_ddi_pll_select(struct intel_crtc *intel_crtc, · line 1152

Quoted 10 lines
drivers/gpu/drm/i915/intel_ddi.c +6 -1
-					  encoder);
+	pll = intel_get_shared_dpll(intel_crtc, crtc_state, encoder);
+	if (!pll)
+		DRM_DEBUG_DRIVER("failed to find PLL for pipe %c\n",
+				  pipe_name(intel_crtc->pipe));
+
+	return pll;
 }
 
 void intel_ddi_set_pipe_settings(const struct intel_crtc_state *crtc_state)

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

#3 lore raw

Em Ter, 2017-03-21 às 23:05 +0000, Pandiyan, Dhinakaran escreveu:

Quoted 34 lines · Paulo Zanoni
Quoted 23 lines

Because {hsw,skl,bxt}_ddi_pll_select all pretty much do the same thing
in slightly different ways. Replace everything with a simple copy of
the function and inline it inside intle_ddi_pll_select().

---
 drivers/gpu/drm/i915/intel_ddi.c | 58 +++++-----------------------
------------

 1 file changed, 7 insertions(+), 51 deletions(-)
drivers/gpu/drm/i915/intel_ddi.c +0 -0
index d8214ba..bd6fd0b 100644
@@ -1127,47 +1127,6 @@ void intel_ddi_clock_get(struct
 intel_encoder *encoder,
  		bxt_ddi_clock_get(encoder, pipe_config);
  }

drivers/gpu/drm/i915/intel_ddi.c void intel_ddi_clock_get(struct intel_encoder *encoder, · line 1138

Quoted 9 lines
drivers/gpu/drm/i915/intel_ddi.c +0 -9
-static bool
-hsw_ddi_pll_select(struct intel_crtc *intel_crtc,
-		   struct intel_crtc_state *crtc_state,
-		   struct intel_encoder *encoder)
-{
-	struct intel_shared_dpll *pll;
-
-	pll = intel_get_shared_dpll(intel_crtc, crtc_state,
-				    encoder);
Quoted 7 lines

I have a related question, not a patch review :) Looks like we care only
about the boolean returned from intel_get_shared_dpll(). Could not find
any caller that uses the returned 'struct intel_shared_dpll *'. Should
it's signature be simply changed to return a bool?

There are only two callers. It would be possible to change the signature, although I don't see many benefits from doing it now.

Perhaps it would be better to unify the error handling.

Quoted 66 lines

-DK

Quoted 64 lines
drivers/gpu/drm/i915/intel_ddi.c +0 -2
-	if (!pll)
-		DRM_DEBUG_DRIVER("failed to find PLL for pipe

%c\n",

drivers/gpu/drm/i915/intel_ddi.c +0 -13
-				 pipe_name(intel_crtc->pipe));
-
-	return pll;
-}
-
-static bool
-skl_ddi_pll_select(struct intel_crtc *intel_crtc,
-		   struct intel_crtc_state *crtc_state,
-		   struct intel_encoder *encoder)
-{
-	struct intel_shared_dpll *pll;
-
-	pll = intel_get_shared_dpll(intel_crtc, crtc_state,

encoder);

drivers/gpu/drm/i915/intel_ddi.c +0 -2
-	if (pll == NULL) {
-		DRM_DEBUG_DRIVER("failed to find PLL for pipe

%c\n",

drivers/gpu/drm/i915/intel_ddi.c +0 -13
-				 pipe_name(intel_crtc->pipe));
-		return false;
-	}
-
-	return true;
-}
-
-static bool
-bxt_ddi_pll_select(struct intel_crtc *intel_crtc,
-		   struct intel_crtc_state *crtc_state,
-		   struct intel_encoder *encoder)
-{
-	return !!intel_get_shared_dpll(intel_crtc, crtc_state,

encoder);

drivers/gpu/drm/i915/intel_ddi.c +0 -2
-}
-

 /*
  * Tries to find a *shared* PLL for the CRTC and store it in
  * intel_crtc->ddi_pll_sel.

drivers/gpu/drm/i915/intel_ddi.c +0 -1
@@ -1178,19 +1137,16 @@ bxt_ddi_pll_select(struct intel_crtc
 *intel_crtc,
  bool intel_ddi_pll_select(struct intel_crtc *intel_crtc,
  			  struct intel_crtc_state *crtc_state)
  {
-	struct drm_i915_private *dev_priv = to_i915(intel_crtc-
 >base.dev);

  struct intel_encoder *encoder = intel_ddi_get_crtc_new_encoder(crtc_state);

drivers/gpu/drm/i915/intel_ddi.c +1 -0
+	struct intel_shared_dpll *pll;

drivers/gpu/drm/i915/intel_ddi.c +1 -9
-	if (IS_GEN9_BC(dev_priv))
-		return skl_ddi_pll_select(intel_crtc, crtc_state,
-					  encoder);
-	else if (IS_GEN9_LP(dev_priv))
-		return bxt_ddi_pll_select(intel_crtc, crtc_state,
-					  encoder);
-	else
-		return hsw_ddi_pll_select(intel_crtc, crtc_state,
-					  encoder);
+	pll = intel_get_shared_dpll(intel_crtc, crtc_state,

encoder);

drivers/gpu/drm/i915/intel_ddi.c +2 -0
+	if (!pll)
+		DRM_DEBUG_DRIVER("failed to find PLL for pipe
Quoted 9 lines
Quoted 8 lines

%c\n",

drivers/gpu/drm/i915/intel_ddi.c +3 -0
+				  pipe_name(intel_crtc->pipe));
+
+	return pll;

 }

 void intel_ddi_set_pipe_settings(const struct intel_crtc_state *crtc_state)

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

Reviewed-by on v1 1/1
#4 lore raw
In reply to Paulo Zanoni
Quoted 70 lines · Paulo Zanoni

Because {hsw,skl,bxt}_ddi_pll_select all pretty much do the same thing in slightly different ways. Replace everything with a simple copy of the function and inline it inside intle_ddi_pll_select().

---
 drivers/gpu/drm/i915/intel_ddi.c | 58 +++++-----------------------------------
 1 file changed, 7 insertions(+), 51 deletions(-)
drivers/gpu/drm/i915/intel_ddi.c +1 -42
index d8214ba..bd6fd0b 100644
@@ -1127,47 +1127,6 @@ void intel_ddi_clock_get(struct intel_encoder *encoder,
 		bxt_ddi_clock_get(encoder, pipe_config);
 }
 
-static bool
-hsw_ddi_pll_select(struct intel_crtc *intel_crtc,
-		   struct intel_crtc_state *crtc_state,
-		   struct intel_encoder *encoder)
-{
-	struct intel_shared_dpll *pll;
-
-	pll = intel_get_shared_dpll(intel_crtc, crtc_state,
-				    encoder);
-	if (!pll)
-		DRM_DEBUG_DRIVER("failed to find PLL for pipe %c\n",
-				 pipe_name(intel_crtc->pipe));
-
-	return pll;
-}
-
-static bool
-skl_ddi_pll_select(struct intel_crtc *intel_crtc,
-		   struct intel_crtc_state *crtc_state,
-		   struct intel_encoder *encoder)
-{
-	struct intel_shared_dpll *pll;
-
-	pll = intel_get_shared_dpll(intel_crtc, crtc_state, encoder);
-	if (pll == NULL) {
-		DRM_DEBUG_DRIVER("failed to find PLL for pipe %c\n",
-				 pipe_name(intel_crtc->pipe));
-		return false;
-	}
-
-	return true;
-}
-
-static bool
-bxt_ddi_pll_select(struct intel_crtc *intel_crtc,
-		   struct intel_crtc_state *crtc_state,
-		   struct intel_encoder *encoder)
-{
-	return !!intel_get_shared_dpll(intel_crtc, crtc_state, encoder);
-}
-
 /*
  * Tries to find a *shared* PLL for the CRTC and store it in
  * intel_crtc->ddi_pll_sel.
@@ -1178,19 +1137,16 @@ bxt_ddi_pll_select(struct intel_crtc *intel_crtc,
 bool intel_ddi_pll_select(struct intel_crtc *intel_crtc,
 			  struct intel_crtc_state *crtc_state)
 {
-	struct drm_i915_private *dev_priv = to_i915(intel_crtc->base.dev);
 	struct intel_encoder *encoder =
 		intel_ddi_get_crtc_new_encoder(crtc_state);
+	struct intel_shared_dpll *pll;
 

drivers/gpu/drm/i915/intel_ddi.c bxt_ddi_pll_select(struct intel_crtc *intel_crtc, · line 1144

Quoted 10 lines
drivers/gpu/drm/i915/intel_ddi.c +1 -9
-	if (IS_GEN9_BC(dev_priv))
-		return skl_ddi_pll_select(intel_crtc, crtc_state,
-					  encoder);
-	else if (IS_GEN9_LP(dev_priv))
-		return bxt_ddi_pll_select(intel_crtc, crtc_state,
-					  encoder);
-	else
-		return hsw_ddi_pll_select(intel_crtc, crtc_state,
-					  encoder);
+	pll = intel_get_shared_dpll(intel_crtc, crtc_state, encoder);

I wonder if intel_ddi_pll_select() has any good reason to even exist anymore. It's just calling this one function, so maybe we should just call it directly?

drivers/gpu/drm/i915/intel_ddi.c bxt_ddi_pll_select(struct intel_crtc *intel_crtc, · line 1149

Quoted 5 lines
drivers/gpu/drm/i915/intel_ddi.c +5 -0
+	if (!pll)
+		DRM_DEBUG_DRIVER("failed to find PLL for pipe %c\n",
+				  pipe_name(intel_crtc->pipe));
+
+	return pll;

I would probably write 'pll != NULL' for a bit of extra clarity.

Either way

Quoted 10 lines
drivers/gpu/drm/i915/intel_ddi.c +0 -0
 }
 
 void intel_ddi_set_pipe_settings(const struct intel_crtc_state *crtc_state)
Signature · 6 lines
2.7.4

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#5 lore raw

Em Qua, 2017-03-22 às 15:21 +0200, Ville Syrjälä escreveu:

Quoted 90 lines · Paulo Zanoni
Quoted 89 lines

Because {hsw,skl,bxt}_ddi_pll_select all pretty much do the same thing
in slightly different ways. Replace everything with a simple copy of
the function and inline it inside intle_ddi_pll_select().

---
 drivers/gpu/drm/i915/intel_ddi.c | 58 +++++-----------------------
------------

 1 file changed, 7 insertions(+), 51 deletions(-)
drivers/gpu/drm/i915/intel_ddi.c +0 -0
index d8214ba..bd6fd0b 100644
@@ -1127,47 +1127,6 @@ void intel_ddi_clock_get(struct
 intel_encoder *encoder,
  		bxt_ddi_clock_get(encoder, pipe_config);
  }

drivers/gpu/drm/i915/intel_ddi.c +0 -11
-static bool
-hsw_ddi_pll_select(struct intel_crtc *intel_crtc,
-		   struct intel_crtc_state *crtc_state,
-		   struct intel_encoder *encoder)
-{
-	struct intel_shared_dpll *pll;
-
-	pll = intel_get_shared_dpll(intel_crtc, crtc_state,
-				    encoder);
-	if (!pll)
-		DRM_DEBUG_DRIVER("failed to find PLL for pipe

%c\n",

drivers/gpu/drm/i915/intel_ddi.c +0 -13
-				 pipe_name(intel_crtc->pipe));
-
-	return pll;
-}
-
-static bool
-skl_ddi_pll_select(struct intel_crtc *intel_crtc,
-		   struct intel_crtc_state *crtc_state,
-		   struct intel_encoder *encoder)
-{
-	struct intel_shared_dpll *pll;
-
-	pll = intel_get_shared_dpll(intel_crtc, crtc_state,

encoder);

drivers/gpu/drm/i915/intel_ddi.c +0 -2
-	if (pll == NULL) {
-		DRM_DEBUG_DRIVER("failed to find PLL for pipe

%c\n",

drivers/gpu/drm/i915/intel_ddi.c +0 -13
-				 pipe_name(intel_crtc->pipe));
-		return false;
-	}
-
-	return true;
-}
-
-static bool
-bxt_ddi_pll_select(struct intel_crtc *intel_crtc,
-		   struct intel_crtc_state *crtc_state,
-		   struct intel_encoder *encoder)
-{
-	return !!intel_get_shared_dpll(intel_crtc, crtc_state,

encoder);

drivers/gpu/drm/i915/intel_ddi.c +0 -2
-}
-

 /*
  * Tries to find a *shared* PLL for the CRTC and store it in
  * intel_crtc->ddi_pll_sel.

drivers/gpu/drm/i915/intel_ddi.c +0 -1
@@ -1178,19 +1137,16 @@ bxt_ddi_pll_select(struct intel_crtc
 *intel_crtc,
  bool intel_ddi_pll_select(struct intel_crtc *intel_crtc,
  			  struct intel_crtc_state *crtc_state)
  {
-	struct drm_i915_private *dev_priv = to_i915(intel_crtc-
 >base.dev);

  struct intel_encoder *encoder = intel_ddi_get_crtc_new_encoder(crtc_state);

drivers/gpu/drm/i915/intel_ddi.c +1 -0
+	struct intel_shared_dpll *pll;

drivers/gpu/drm/i915/intel_ddi.c +0 -7
-	if (IS_GEN9_BC(dev_priv))
-		return skl_ddi_pll_select(intel_crtc, crtc_state,
-					  encoder);
-	else if (IS_GEN9_LP(dev_priv))
-		return bxt_ddi_pll_select(intel_crtc, crtc_state,
-					  encoder);
-	else
Quoted 8 lines
Quoted 4 lines
drivers/gpu/drm/i915/intel_ddi.c +1 -2
-		return hsw_ddi_pll_select(intel_crtc, crtc_state,
-					  encoder);
+	pll = intel_get_shared_dpll(intel_crtc, crtc_state,

encoder);

I wonder if intel_ddi_pll_select() has any good reason to even exist anymore. It's just calling this one function, so maybe we should just call it directly?

You're right here. Then the two callers would be haswell_crtc_compute_clock() and ironlake_crtc_compute_clock(), which makes even more sene. I'll submit another patch.

Quoted 10 lines

drivers/gpu/drm/i915/intel_ddi.c bxt_ddi_pll_select(struct intel_crtc *intel_crtc, · line 1149

Quoted 8 lines
drivers/gpu/drm/i915/intel_ddi.c +2 -0
+	if (!pll)
+		DRM_DEBUG_DRIVER("failed to find PLL for pipe

%c\n",

drivers/gpu/drm/i915/intel_ddi.c +3 -0
+				  pipe_name(intel_crtc->pipe));
+
+	return pll;

I would probably write 'pll != NULL' for a bit of extra clarity.

Are you talking about the return statement or the if condition?

I'll assume you're talking about the return statement. I can fix this. Another thing would be "return !!pll". I'm fine with all approaches.

Quoted 3 lines

Either way

Thanks!

Quoted 9 lines
Quoted 9 lines

 }

 void intel_ddi_set_pipe_settings(const struct intel_crtc_state *crtc_state)
--
2.7.4

Quoted 5 lines
Quoted 4 lines

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

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

#6 lore raw
Quoted 115 lines · Paulo Zanoni

Em Qua, 2017-03-22 às 15:21 +0200, Ville Syrjälä escreveu:

Quoted 90 lines · Paulo Zanoni
Quoted 89 lines

Because {hsw,skl,bxt}_ddi_pll_select all pretty much do the same thing
in slightly different ways. Replace everything with a simple copy of
the function and inline it inside intle_ddi_pll_select().

---
 drivers/gpu/drm/i915/intel_ddi.c | 58 +++++-----------------------
------------

 1 file changed, 7 insertions(+), 51 deletions(-)
drivers/gpu/drm/i915/intel_ddi.c +0 -0
index d8214ba..bd6fd0b 100644
@@ -1127,47 +1127,6 @@ void intel_ddi_clock_get(struct
 intel_encoder *encoder,
  		bxt_ddi_clock_get(encoder, pipe_config);
  }

drivers/gpu/drm/i915/intel_ddi.c +0 -11
-static bool
-hsw_ddi_pll_select(struct intel_crtc *intel_crtc,
-		   struct intel_crtc_state *crtc_state,
-		   struct intel_encoder *encoder)
-{
-	struct intel_shared_dpll *pll;
-
-	pll = intel_get_shared_dpll(intel_crtc, crtc_state,
-				    encoder);
-	if (!pll)
-		DRM_DEBUG_DRIVER("failed to find PLL for pipe

%c\n",

drivers/gpu/drm/i915/intel_ddi.c +0 -13
-				 pipe_name(intel_crtc->pipe));
-
-	return pll;
-}
-
-static bool
-skl_ddi_pll_select(struct intel_crtc *intel_crtc,
-		   struct intel_crtc_state *crtc_state,
-		   struct intel_encoder *encoder)
-{
-	struct intel_shared_dpll *pll;
-
-	pll = intel_get_shared_dpll(intel_crtc, crtc_state,

encoder);

drivers/gpu/drm/i915/intel_ddi.c +0 -2
-	if (pll == NULL) {
-		DRM_DEBUG_DRIVER("failed to find PLL for pipe

%c\n",

drivers/gpu/drm/i915/intel_ddi.c +0 -13
-				 pipe_name(intel_crtc->pipe));
-		return false;
-	}
-
-	return true;
-}
-
-static bool
-bxt_ddi_pll_select(struct intel_crtc *intel_crtc,
-		   struct intel_crtc_state *crtc_state,
-		   struct intel_encoder *encoder)
-{
-	return !!intel_get_shared_dpll(intel_crtc, crtc_state,

encoder);

drivers/gpu/drm/i915/intel_ddi.c +0 -2
-}
-

 /*
  * Tries to find a *shared* PLL for the CRTC and store it in
  * intel_crtc->ddi_pll_sel.

drivers/gpu/drm/i915/intel_ddi.c +0 -1
@@ -1178,19 +1137,16 @@ bxt_ddi_pll_select(struct intel_crtc
 *intel_crtc,
  bool intel_ddi_pll_select(struct intel_crtc *intel_crtc,
  			  struct intel_crtc_state *crtc_state)
  {
-	struct drm_i915_private *dev_priv = to_i915(intel_crtc-
 >base.dev);

  struct intel_encoder *encoder = intel_ddi_get_crtc_new_encoder(crtc_state);

drivers/gpu/drm/i915/intel_ddi.c +1 -0
+	struct intel_shared_dpll *pll;

drivers/gpu/drm/i915/intel_ddi.c +0 -7
-	if (IS_GEN9_BC(dev_priv))
-		return skl_ddi_pll_select(intel_crtc, crtc_state,
-					  encoder);
-	else if (IS_GEN9_LP(dev_priv))
-		return bxt_ddi_pll_select(intel_crtc, crtc_state,
-					  encoder);
-	else
Quoted 8 lines
Quoted 4 lines
drivers/gpu/drm/i915/intel_ddi.c +1 -2
-		return hsw_ddi_pll_select(intel_crtc, crtc_state,
-					  encoder);
+	pll = intel_get_shared_dpll(intel_crtc, crtc_state,

encoder);

I wonder if intel_ddi_pll_select() has any good reason to even exist anymore. It's just calling this one function, so maybe we should just call it directly?

You're right here. Then the two callers would be haswell_crtc_compute_clock() and ironlake_crtc_compute_clock(), which makes even more sene. I'll submit another patch.

Quoted 10 lines

drivers/gpu/drm/i915/intel_ddi.c bxt_ddi_pll_select(struct intel_crtc *intel_crtc, · line 1149

Quoted 8 lines
drivers/gpu/drm/i915/intel_ddi.c +2 -0
+	if (!pll)
+		DRM_DEBUG_DRIVER("failed to find PLL for pipe

%c\n",

drivers/gpu/drm/i915/intel_ddi.c +3 -0
+				  pipe_name(intel_crtc->pipe));
+
+	return pll;

I would probably write 'pll != NULL' for a bit of extra clarity.

Quoted 1 line

Are you talking about the return statement or the if condition?

The return.

Quoted 3 lines

I'll assume you're talking about the return statement. I can fix this. Another thing would be "return !!pll". I'm fine with all approaches.

For whatever reason I've started to prefer !=NULL type of stuff. Not really sure why since I used to dislike it when I was younger.

Quoted 21 lines
Quoted 4 lines

Either way

Thanks!

Quoted 14 lines
Quoted 13 lines

 }

 void intel_ddi_set_pipe_settings(const struct intel_crtc_state *crtc_state)
--
2.7.4

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

Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#7 lore raw

PATCH 1/2 drm/i915: simplify intel_ddi_pll_select()

Because {hsw,skl,bxt}_ddi_pll_select all pretty much do the same thing in slightly different ways. Replace everything with a simple copy of the function and inline it inside intle_ddi_pll_select().

v2: s/return pll/return pll != NULL/ (Ville)

---
 drivers/gpu/drm/i915/intel_ddi.c | 58 +++++-----------------------------------
 1 file changed, 7 insertions(+), 51 deletions(-)
drivers/gpu/drm/i915/intel_ddi.c +7 -51
index d8214ba..08a810d 100644
@@ -1127,47 +1127,6 @@ void intel_ddi_clock_get(struct intel_encoder *encoder,
 		bxt_ddi_clock_get(encoder, pipe_config);
 }
 
-static bool
-hsw_ddi_pll_select(struct intel_crtc *intel_crtc,
-		   struct intel_crtc_state *crtc_state,
-		   struct intel_encoder *encoder)
-{
-	struct intel_shared_dpll *pll;
-
-	pll = intel_get_shared_dpll(intel_crtc, crtc_state,
-				    encoder);
-	if (!pll)
-		DRM_DEBUG_DRIVER("failed to find PLL for pipe %c\n",
-				 pipe_name(intel_crtc->pipe));
-
-	return pll;
-}
-
-static bool
-skl_ddi_pll_select(struct intel_crtc *intel_crtc,
-		   struct intel_crtc_state *crtc_state,
-		   struct intel_encoder *encoder)
-{
-	struct intel_shared_dpll *pll;
-
-	pll = intel_get_shared_dpll(intel_crtc, crtc_state, encoder);
-	if (pll == NULL) {
-		DRM_DEBUG_DRIVER("failed to find PLL for pipe %c\n",
-				 pipe_name(intel_crtc->pipe));
-		return false;
-	}
-
-	return true;
-}
-
-static bool
-bxt_ddi_pll_select(struct intel_crtc *intel_crtc,
-		   struct intel_crtc_state *crtc_state,
-		   struct intel_encoder *encoder)
-{
-	return !!intel_get_shared_dpll(intel_crtc, crtc_state, encoder);
-}
-
 /*
  * Tries to find a *shared* PLL for the CRTC and store it in
  * intel_crtc->ddi_pll_sel.
@@ -1178,19 +1137,16 @@ bxt_ddi_pll_select(struct intel_crtc *intel_crtc,
 bool intel_ddi_pll_select(struct intel_crtc *intel_crtc,
 			  struct intel_crtc_state *crtc_state)
 {
-	struct drm_i915_private *dev_priv = to_i915(intel_crtc->base.dev);
 	struct intel_encoder *encoder =
 		intel_ddi_get_crtc_new_encoder(crtc_state);
+	struct intel_shared_dpll *pll;
 
-	if (IS_GEN9_BC(dev_priv))
-		return skl_ddi_pll_select(intel_crtc, crtc_state,
-					  encoder);
-	else if (IS_GEN9_LP(dev_priv))
-		return bxt_ddi_pll_select(intel_crtc, crtc_state,
-					  encoder);
-	else
-		return hsw_ddi_pll_select(intel_crtc, crtc_state,
-					  encoder);
+	pll = intel_get_shared_dpll(intel_crtc, crtc_state, encoder);
+	if (!pll)
+		DRM_DEBUG_DRIVER("failed to find PLL for pipe %c\n",
+				  pipe_name(intel_crtc->pipe));
+
+	return pll != NULL;
 }
 
 void intel_ddi_set_pipe_settings(const struct intel_crtc_state *crtc_state)
Signature · 6 lines
2.7.4

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

PATCH 2/2 drm/i915: kill intel_ddi_pll_select()

All it does is pick the encoder and call intel_get_shared_dpll(). We can just do this in the caller. One less indirection level during code reading.

As another plus, now the two callers of intel_get_shared_dpll() are {ironlake,haswell}_crtc_compute_clock().

---
 drivers/gpu/drm/i915/intel_ddi.c     | 25 ++-----------------------
 drivers/gpu/drm/i915/intel_display.c |  8 +++++++-
 drivers/gpu/drm/i915/intel_drv.h     |  4 ++--
 3 files changed, 11 insertions(+), 26 deletions(-)

To be honest I'm not super sure if this change is an improvement. I like keeping DDI-related code in intel_ddi.c. I'll let you guys decide with the upvote/downvote buttons in your email clients.

drivers/gpu/drm/i915/intel_ddi.c +2 -23
index 08a810d..3fbe498 100644
@@ -837,7 +837,8 @@ intel_ddi_get_crtc_encoder(struct intel_crtc *crtc)
 	return ret;
 }
 
-static struct intel_encoder *
+/* Finds the only possible encoder associated with the given CRTC. */
+struct intel_encoder *
 intel_ddi_get_crtc_new_encoder(struct intel_crtc_state *crtc_state)
 {
 	struct intel_crtc *crtc = to_intel_crtc(crtc_state->base.crtc);
@@ -1127,28 +1128,6 @@ void intel_ddi_clock_get(struct intel_encoder *encoder,
 		bxt_ddi_clock_get(encoder, pipe_config);
 }
 
-/*
- * Tries to find a *shared* PLL for the CRTC and store it in
- * intel_crtc->ddi_pll_sel.
- *
- * For private DPLLs, compute_config() should do the selection for us. This
- * function should be folded into compute_config() eventually.
- */
-bool intel_ddi_pll_select(struct intel_crtc *intel_crtc,
-			  struct intel_crtc_state *crtc_state)
-{
-	struct intel_encoder *encoder =
-		intel_ddi_get_crtc_new_encoder(crtc_state);
-	struct intel_shared_dpll *pll;
-
-	pll = intel_get_shared_dpll(intel_crtc, crtc_state, encoder);
-	if (!pll)
-		DRM_DEBUG_DRIVER("failed to find PLL for pipe %c\n",
-				  pipe_name(intel_crtc->pipe));
-
-	return pll != NULL;
-}
-
 void intel_ddi_set_pipe_settings(const struct intel_crtc_state *crtc_state)
 {
 	struct intel_crtc *crtc = to_intel_crtc(crtc_state->base.crtc);
drivers/gpu/drm/i915/intel_display.c +7 -1
index 010e5dd..9cdf9b2 100644
@@ -8862,8 +8862,14 @@ static int haswell_crtc_compute_clock(struct intel_crtc *crtc,
 				      struct intel_crtc_state *crtc_state)
 {
 	if (!intel_crtc_has_type(crtc_state, INTEL_OUTPUT_DSI)) {
-		if (!intel_ddi_pll_select(crtc, crtc_state))
+		struct intel_encoder *encoder =
+			intel_ddi_get_crtc_new_encoder(crtc_state);
+
+		if (!intel_get_shared_dpll(crtc, crtc_state, encoder)) {
+			DRM_DEBUG_DRIVER("failed to find PLL for pipe %c\n",
+					  pipe_name(crtc->pipe));
 			return -EINVAL;
+		}
 	}
 
 	crtc->lowfreq_avail = false;
drivers/gpu/drm/i915/intel_drv.h +2 -2
index 51228fe..ad7bdf5 100644
@@ -1236,8 +1236,8 @@ void intel_ddi_disable_transcoder_func(struct drm_i915_private *dev_priv,
 				       enum transcoder cpu_transcoder);
 void intel_ddi_enable_pipe_clock(const struct intel_crtc_state *crtc_state);
 void intel_ddi_disable_pipe_clock(const  struct intel_crtc_state *crtc_state);
-bool intel_ddi_pll_select(struct intel_crtc *crtc,
-			  struct intel_crtc_state *crtc_state);
+struct intel_encoder *
+intel_ddi_get_crtc_new_encoder(struct intel_crtc_state *crtc_state);
 void intel_ddi_set_pipe_settings(const struct intel_crtc_state *crtc_state);
 void intel_ddi_prepare_link_retrain(struct intel_dp *intel_dp);
 bool intel_ddi_connector_get_hw_state(struct intel_connector *intel_connector);
Signature · 6 lines
2.7.4

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 2/2
#9 lore raw

Re: [PATCH 2/2] drm/i915: kill intel_ddi_pll_select()

Quoted 16 lines · Paulo Zanoni

All it does is pick the encoder and call intel_get_shared_dpll(). We can just do this in the caller. One less indirection level during code reading.

As another plus, now the two callers of intel_get_shared_dpll() are {ironlake,haswell}_crtc_compute_clock().

---
 drivers/gpu/drm/i915/intel_ddi.c     | 25 ++-----------------------
 drivers/gpu/drm/i915/intel_display.c |  8 +++++++-
 drivers/gpu/drm/i915/intel_drv.h     |  4 ++--
 3 files changed, 11 insertions(+), 26 deletions(-)
Quoted 3 lines

To be honest I'm not super sure if this change is an improvement. I like keeping DDI-related code in intel_ddi.c. I'll let you guys decide with the upvote/downvote buttons in your email clients.

I guess the thing that sort of ruins is the intel_ddi_get_crtc_new_encoder() call. First I thought we could nuke that by using output_types instead of encoder->type, but looks like BXT wants to disagree with us and really requires the encoder in .get_dpll() :(

Oh well, we trade one ddi thing for another. Although intel_ddi_get_crtc_new_encoder() doesn't really have anything truly ddi specific in it so we could even move it elsewhere or even just inline it in .compute_clock() since it's not even called from anywhere else.

I do like the fact that there's at least one less hoop to jump through when tracing through the code. So this works for me.

Quoted 87 lines
drivers/gpu/drm/i915/intel_ddi.c +2 -23
index 08a810d..3fbe498 100644
@@ -837,7 +837,8 @@ intel_ddi_get_crtc_encoder(struct intel_crtc *crtc)
 	return ret;
 }
 
-static struct intel_encoder *
+/* Finds the only possible encoder associated with the given CRTC. */
+struct intel_encoder *
 intel_ddi_get_crtc_new_encoder(struct intel_crtc_state *crtc_state)
 {
 	struct intel_crtc *crtc = to_intel_crtc(crtc_state->base.crtc);
@@ -1127,28 +1128,6 @@ void intel_ddi_clock_get(struct intel_encoder *encoder,
 		bxt_ddi_clock_get(encoder, pipe_config);
 }
 
-/*
- * Tries to find a *shared* PLL for the CRTC and store it in
- * intel_crtc->ddi_pll_sel.
- *
- * For private DPLLs, compute_config() should do the selection for us. This
- * function should be folded into compute_config() eventually.
- */
-bool intel_ddi_pll_select(struct intel_crtc *intel_crtc,
-			  struct intel_crtc_state *crtc_state)
-{
-	struct intel_encoder *encoder =
-		intel_ddi_get_crtc_new_encoder(crtc_state);
-	struct intel_shared_dpll *pll;
-
-	pll = intel_get_shared_dpll(intel_crtc, crtc_state, encoder);
-	if (!pll)
-		DRM_DEBUG_DRIVER("failed to find PLL for pipe %c\n",
-				  pipe_name(intel_crtc->pipe));
-
-	return pll != NULL;
-}
-
 void intel_ddi_set_pipe_settings(const struct intel_crtc_state *crtc_state)
 {
 	struct intel_crtc *crtc = to_intel_crtc(crtc_state->base.crtc);
drivers/gpu/drm/i915/intel_display.c +7 -1
index 010e5dd..9cdf9b2 100644
@@ -8862,8 +8862,14 @@ static int haswell_crtc_compute_clock(struct intel_crtc *crtc,
 				      struct intel_crtc_state *crtc_state)
 {
 	if (!intel_crtc_has_type(crtc_state, INTEL_OUTPUT_DSI)) {
-		if (!intel_ddi_pll_select(crtc, crtc_state))
+		struct intel_encoder *encoder =
+			intel_ddi_get_crtc_new_encoder(crtc_state);
+
+		if (!intel_get_shared_dpll(crtc, crtc_state, encoder)) {
+			DRM_DEBUG_DRIVER("failed to find PLL for pipe %c\n",
+					  pipe_name(crtc->pipe));
 			return -EINVAL;
+		}
 	}
 
 	crtc->lowfreq_avail = false;
drivers/gpu/drm/i915/intel_drv.h +2 -2
index 51228fe..ad7bdf5 100644
@@ -1236,8 +1236,8 @@ void intel_ddi_disable_transcoder_func(struct drm_i915_private *dev_priv,
 				       enum transcoder cpu_transcoder);
 void intel_ddi_enable_pipe_clock(const struct intel_crtc_state *crtc_state);
 void intel_ddi_disable_pipe_clock(const  struct intel_crtc_state *crtc_state);
-bool intel_ddi_pll_select(struct intel_crtc *crtc,
-			  struct intel_crtc_state *crtc_state);
+struct intel_encoder *
+intel_ddi_get_crtc_new_encoder(struct intel_crtc_state *crtc_state);
 void intel_ddi_set_pipe_settings(const struct intel_crtc_state *crtc_state);
 void intel_ddi_prepare_link_retrain(struct intel_dp *intel_dp);
 bool intel_ddi_connector_get_hw_state(struct intel_connector *intel_connector);
Signature · 6 lines
2.7.4

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx