@@ -1843,8 +1843,7 @@ static void ironlake_enable_pch_transcoder(struct drm_i915_private *dev_priv,
18431843 BUG_ON (!HAS_PCH_SPLIT (dev ));
18441844
18451845 /* Make sure PCH DPLL is enabled */
1846- assert_shared_dpll_enabled (dev_priv ,
1847- intel_crtc_to_shared_dpll (intel_crtc ));
1846+ assert_shared_dpll_enabled (dev_priv , intel_crtc -> config -> shared_dpll );
18481847
18491848 /* FDI must be feeding us bits for PCH ports */
18501849 assert_fdi_tx_enabled (dev_priv , pipe );
@@ -4147,7 +4146,8 @@ static void ironlake_pch_enable(struct drm_crtc *crtc)
41474146 temp = I915_READ (PCH_DPLL_SEL );
41484147 temp |= TRANS_DPLL_ENABLE (pipe );
41494148 sel = TRANS_DPLLB_SEL (pipe );
4150- if (intel_crtc -> config -> shared_dpll == DPLL_ID_PCH_PLL_B )
4149+ if (intel_crtc -> config -> shared_dpll ==
4150+ intel_get_shared_dpll_by_id (dev_priv , DPLL_ID_PCH_PLL_B ))
41514151 temp |= sel ;
41524152 else
41534153 temp &= ~sel ;
@@ -4883,7 +4883,7 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)
48834883 intel_set_pch_fifo_underrun_reporting (dev_priv , TRANSCODER_A ,
48844884 false);
48854885
4886- if (intel_crtc_to_shared_dpll ( intel_crtc ) )
4886+ if (intel_crtc -> config -> shared_dpll )
48874887 intel_enable_shared_dpll (intel_crtc );
48884888
48894889 if (intel_crtc -> config -> has_dp_encoder )
@@ -8052,7 +8052,7 @@ static bool i9xx_get_pipe_config(struct intel_crtc *crtc,
80528052 return false;
80538053
80548054 pipe_config -> cpu_transcoder = (enum transcoder ) crtc -> pipe ;
8055- pipe_config -> shared_dpll = DPLL_ID_PRIVATE ;
8055+ pipe_config -> shared_dpll = NULL ;
80568056
80578057 ret = false;
80588058
@@ -9256,7 +9256,7 @@ static bool ironlake_get_pipe_config(struct intel_crtc *crtc,
92569256 return false;
92579257
92589258 pipe_config -> cpu_transcoder = (enum transcoder ) crtc -> pipe ;
9259- pipe_config -> shared_dpll = DPLL_ID_PRIVATE ;
9259+ pipe_config -> shared_dpll = NULL ;
92609260
92619261 ret = false;
92629262 tmp = I915_READ (PIPECONF (crtc -> pipe ));
@@ -9285,6 +9285,7 @@ static bool ironlake_get_pipe_config(struct intel_crtc *crtc,
92859285
92869286 if (I915_READ (PCH_TRANSCONF (crtc -> pipe )) & TRANS_ENABLE ) {
92879287 struct intel_shared_dpll * pll ;
9288+ enum intel_dpll_id pll_id ;
92889289
92899290 pipe_config -> has_pch_encoder = true;
92909291
@@ -9295,17 +9296,18 @@ static bool ironlake_get_pipe_config(struct intel_crtc *crtc,
92959296 ironlake_get_fdi_m_n_config (crtc , pipe_config );
92969297
92979298 if (HAS_PCH_IBX (dev_priv -> dev )) {
9298- pipe_config -> shared_dpll =
9299- (enum intel_dpll_id ) crtc -> pipe ;
9299+ pll_id = (enum intel_dpll_id ) crtc -> pipe ;
93009300 } else {
93019301 tmp = I915_READ (PCH_DPLL_SEL );
93029302 if (tmp & TRANS_DPLLB_SEL (crtc -> pipe ))
9303- pipe_config -> shared_dpll = DPLL_ID_PCH_PLL_B ;
9303+ pll_id = DPLL_ID_PCH_PLL_B ;
93049304 else
9305- pipe_config -> shared_dpll = DPLL_ID_PCH_PLL_A ;
9305+ pll_id = DPLL_ID_PCH_PLL_A ;
93069306 }
93079307
9308- pll = & dev_priv -> shared_dplls [pipe_config -> shared_dpll ];
9308+ pipe_config -> shared_dpll =
9309+ intel_get_shared_dpll_by_id (dev_priv , pll_id );
9310+ pll = pipe_config -> shared_dpll ;
93099311
93109312 WARN_ON (!pll -> get_hw_state (dev_priv , pll ,
93119313 & pipe_config -> dpll_hw_state ));
@@ -9741,28 +9743,34 @@ static void bxt_get_ddi_pll(struct drm_i915_private *dev_priv,
97419743 enum port port ,
97429744 struct intel_crtc_state * pipe_config )
97439745{
9746+ enum intel_dpll_id id ;
9747+
97449748 switch (port ) {
97459749 case PORT_A :
97469750 pipe_config -> ddi_pll_sel = SKL_DPLL0 ;
9747- pipe_config -> shared_dpll = DPLL_ID_SKL_DPLL1 ;
9751+ id = DPLL_ID_SKL_DPLL1 ;
97489752 break ;
97499753 case PORT_B :
97509754 pipe_config -> ddi_pll_sel = SKL_DPLL1 ;
9751- pipe_config -> shared_dpll = DPLL_ID_SKL_DPLL2 ;
9755+ id = DPLL_ID_SKL_DPLL2 ;
97529756 break ;
97539757 case PORT_C :
97549758 pipe_config -> ddi_pll_sel = SKL_DPLL2 ;
9755- pipe_config -> shared_dpll = DPLL_ID_SKL_DPLL3 ;
9759+ id = DPLL_ID_SKL_DPLL3 ;
97569760 break ;
97579761 default :
97589762 DRM_ERROR ("Incorrect port type\n" );
9763+ return ;
97599764 }
9765+
9766+ pipe_config -> shared_dpll = intel_get_shared_dpll_by_id (dev_priv , id );
97609767}
97619768
97629769static void skylake_get_ddi_pll (struct drm_i915_private * dev_priv ,
97639770 enum port port ,
97649771 struct intel_crtc_state * pipe_config )
97659772{
9773+ enum intel_dpll_id id ;
97669774 u32 temp , dpll_ctl1 ;
97679775
97689776 temp = I915_READ (DPLL_CTRL2 ) & DPLL_CTRL2_DDI_CLK_SEL_MASK (port );
@@ -9777,36 +9785,53 @@ static void skylake_get_ddi_pll(struct drm_i915_private *dev_priv,
97779785 */
97789786 dpll_ctl1 = I915_READ (DPLL_CTRL1 );
97799787 pipe_config -> dpll_hw_state .ctrl1 = dpll_ctl1 & 0x3f ;
9780- break ;
9788+ return ;
97819789 case SKL_DPLL1 :
9782- pipe_config -> shared_dpll = DPLL_ID_SKL_DPLL1 ;
9790+ id = DPLL_ID_SKL_DPLL1 ;
97839791 break ;
97849792 case SKL_DPLL2 :
9785- pipe_config -> shared_dpll = DPLL_ID_SKL_DPLL2 ;
9793+ id = DPLL_ID_SKL_DPLL2 ;
97869794 break ;
97879795 case SKL_DPLL3 :
9788- pipe_config -> shared_dpll = DPLL_ID_SKL_DPLL3 ;
9796+ id = DPLL_ID_SKL_DPLL3 ;
97899797 break ;
9798+ default :
9799+ MISSING_CASE (pipe_config -> ddi_pll_sel );
9800+ return ;
97909801 }
9802+
9803+ pipe_config -> shared_dpll = intel_get_shared_dpll_by_id (dev_priv , id );
97919804}
97929805
97939806static void haswell_get_ddi_pll (struct drm_i915_private * dev_priv ,
97949807 enum port port ,
97959808 struct intel_crtc_state * pipe_config )
97969809{
9810+ enum intel_dpll_id id ;
9811+
97979812 pipe_config -> ddi_pll_sel = I915_READ (PORT_CLK_SEL (port ));
97989813
97999814 switch (pipe_config -> ddi_pll_sel ) {
98009815 case PORT_CLK_SEL_WRPLL1 :
9801- pipe_config -> shared_dpll = DPLL_ID_WRPLL1 ;
9816+ id = DPLL_ID_WRPLL1 ;
98029817 break ;
98039818 case PORT_CLK_SEL_WRPLL2 :
9804- pipe_config -> shared_dpll = DPLL_ID_WRPLL2 ;
9819+ id = DPLL_ID_WRPLL2 ;
98059820 break ;
98069821 case PORT_CLK_SEL_SPLL :
9807- pipe_config -> shared_dpll = DPLL_ID_SPLL ;
9822+ id = DPLL_ID_SPLL ;
98089823 break ;
9824+ default :
9825+ MISSING_CASE (pipe_config -> ddi_pll_sel );
9826+ /* fall through */
9827+ case PORT_CLK_SEL_NONE :
9828+ case PORT_CLK_SEL_LCPLL_810 :
9829+ case PORT_CLK_SEL_LCPLL_1350 :
9830+ case PORT_CLK_SEL_LCPLL_2700 :
9831+ return ;
98099832 }
9833+
9834+ pipe_config -> shared_dpll = intel_get_shared_dpll_by_id (dev_priv , id );
98109835}
98119836
98129837static void haswell_get_ddi_port_state (struct intel_crtc * crtc ,
@@ -9829,9 +9854,8 @@ static void haswell_get_ddi_port_state(struct intel_crtc *crtc,
98299854 else
98309855 haswell_get_ddi_pll (dev_priv , port , pipe_config );
98319856
9832- if (pipe_config -> shared_dpll >= 0 ) {
9833- pll = & dev_priv -> shared_dplls [pipe_config -> shared_dpll ];
9834-
9857+ pll = pipe_config -> shared_dpll ;
9858+ if (pll ) {
98359859 WARN_ON (!pll -> get_hw_state (dev_priv , pll ,
98369860 & pipe_config -> dpll_hw_state ));
98379861 }
@@ -9871,7 +9895,7 @@ static bool haswell_get_pipe_config(struct intel_crtc *crtc,
98719895 ret = false;
98729896
98739897 pipe_config -> cpu_transcoder = (enum transcoder ) crtc -> pipe ;
9874- pipe_config -> shared_dpll = DPLL_ID_PRIVATE ;
9898+ pipe_config -> shared_dpll = NULL ;
98759899
98769900 tmp = I915_READ (TRANS_DDI_FUNC_CTL (TRANSCODER_EDP ));
98779901 if (tmp & TRANS_DDI_FUNC_ENABLE ) {
@@ -11868,7 +11892,7 @@ static int intel_crtc_atomic_check(struct drm_crtc *crtc,
1186811892
1186911893 if (mode_changed && crtc_state -> enable &&
1187011894 dev_priv -> display .crtc_compute_clock &&
11871- !WARN_ON (pipe_config -> shared_dpll != DPLL_ID_PRIVATE )) {
11895+ !WARN_ON (pipe_config -> shared_dpll )) {
1187211896 ret = dev_priv -> display .crtc_compute_clock (intel_crtc ,
1187311897 pipe_config );
1187411898 if (ret )
@@ -12213,7 +12237,7 @@ clear_intel_crtc_state(struct intel_crtc_state *crtc_state)
1221312237 struct drm_crtc_state tmp_state ;
1221412238 struct intel_crtc_scaler_state scaler_state ;
1221512239 struct intel_dpll_hw_state dpll_hw_state ;
12216- enum intel_dpll_id shared_dpll ;
12240+ struct intel_shared_dpll * shared_dpll ;
1221712241 uint32_t ddi_pll_sel ;
1221812242 bool force_thru ;
1221912243
@@ -12483,6 +12507,15 @@ intel_pipe_config_compare(struct drm_device *dev,
1248312507 ret = false; \
1248412508 }
1248512509
12510+ #define PIPE_CONF_CHECK_P (name ) \
12511+ if (current_config->name != pipe_config->name) { \
12512+ INTEL_ERR_OR_DBG_KMS("mismatch in " #name " " \
12513+ "(expected %p, found %p)\n", \
12514+ current_config->name, \
12515+ pipe_config->name); \
12516+ ret = false; \
12517+ }
12518+
1248612519#define PIPE_CONF_CHECK_M_N (name ) \
1248712520 if (!intel_compare_link_m_n(¤t_config->name, \
1248812521 &pipe_config->name,\
@@ -12650,7 +12683,7 @@ intel_pipe_config_compare(struct drm_device *dev,
1265012683
1265112684 PIPE_CONF_CHECK_X (ddi_pll_sel );
1265212685
12653- PIPE_CONF_CHECK_I (shared_dpll );
12686+ PIPE_CONF_CHECK_P (shared_dpll );
1265412687 PIPE_CONF_CHECK_X (dpll_hw_state .dpll );
1265512688 PIPE_CONF_CHECK_X (dpll_hw_state .dpll_md );
1265612689 PIPE_CONF_CHECK_X (dpll_hw_state .fp0 );
@@ -12669,6 +12702,7 @@ intel_pipe_config_compare(struct drm_device *dev,
1266912702
1267012703#undef PIPE_CONF_CHECK_X
1267112704#undef PIPE_CONF_CHECK_I
12705+ #undef PIPE_CONF_CHECK_P
1267212706#undef PIPE_CONF_CHECK_I_ALT
1267312707#undef PIPE_CONF_CHECK_FLAGS
1267412708#undef PIPE_CONF_CHECK_CLOCK_FUZZY
@@ -12892,7 +12926,8 @@ check_shared_dpll_state(struct drm_device *dev)
1289212926 int i ;
1289312927
1289412928 for (i = 0 ; i < dev_priv -> num_shared_dpll ; i ++ ) {
12895- struct intel_shared_dpll * pll = & dev_priv -> shared_dplls [i ];
12929+ struct intel_shared_dpll * pll =
12930+ intel_get_shared_dpll_by_id (dev_priv , i );
1289612931 int enabled_crtcs = 0 , active_crtcs = 0 ;
1289712932 bool active ;
1289812933
@@ -12914,9 +12949,9 @@ check_shared_dpll_state(struct drm_device *dev)
1291412949 pll -> on , active );
1291512950
1291612951 for_each_intel_crtc (dev , crtc ) {
12917- if (crtc -> base .state -> enable && intel_crtc_to_shared_dpll ( crtc ) == pll )
12952+ if (crtc -> base .state -> enable && crtc -> config -> shared_dpll == pll )
1291812953 enabled_crtcs ++ ;
12919- if (crtc -> active && intel_crtc_to_shared_dpll ( crtc ) == pll )
12954+ if (crtc -> active && crtc -> config -> shared_dpll == pll )
1292012955 active_crtcs ++ ;
1292112956 }
1292212957 I915_STATE_WARN (pll -> active != active_crtcs ,
@@ -12995,20 +13030,21 @@ static void intel_modeset_clear_plls(struct drm_atomic_state *state)
1299513030
1299613031 for_each_crtc_in_state (state , crtc , crtc_state , i ) {
1299713032 struct intel_crtc * intel_crtc = to_intel_crtc (crtc );
12998- int old_dpll = to_intel_crtc_state (crtc -> state )-> shared_dpll ;
13033+ struct intel_shared_dpll * old_dpll =
13034+ to_intel_crtc_state (crtc -> state )-> shared_dpll ;
1299913035
1300013036 if (!needs_modeset (crtc_state ))
1300113037 continue ;
1300213038
13003- to_intel_crtc_state (crtc_state )-> shared_dpll = DPLL_ID_PRIVATE ;
13039+ to_intel_crtc_state (crtc_state )-> shared_dpll = NULL ;
1300413040
13005- if (old_dpll == DPLL_ID_PRIVATE )
13041+ if (! old_dpll )
1300613042 continue ;
1300713043
1300813044 if (!shared_dpll )
1300913045 shared_dpll = intel_atomic_get_shared_dpll_state (state );
1301013046
13011- shared_dpll [ old_dpll ]. crtc_mask &= ~( 1 << intel_crtc -> pipe );
13047+ intel_shared_dpll_config_put ( shared_dpll , old_dpll , intel_crtc );
1301213048 }
1301313049}
1301413050
@@ -15655,7 +15691,7 @@ static void intel_modeset_readout_hw_state(struct drm_device *dev)
1565515691 pll -> active = 0 ;
1565615692 pll -> config .crtc_mask = 0 ;
1565715693 for_each_intel_crtc (dev , crtc ) {
15658- if (crtc -> active && intel_crtc_to_shared_dpll ( crtc ) == pll ) {
15694+ if (crtc -> active && crtc -> config -> shared_dpll == pll ) {
1565915695 pll -> active ++ ;
1566015696 pll -> config .crtc_mask |= 1 << crtc -> pipe ;
1566115697 }
0 commit comments