aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2010-08-22 05:54:23 -0400
committerChris Wilson <chris@chris-wilson.co.uk>2010-09-07 06:14:19 -0400
commit8e647a279ca30029f19eca646de08a6338eab924 (patch)
treec3d6704c962d50174705abfb4426cadd38d164f6 /drivers/gpu
parenta25c25c2a2aa55e609099a9f74453c518aec29a6 (diff)
drm/i915: Tightly scope intel_encoder to prevent invalid use
We reset intel_encoder for every matching encoder whilst iterating over the encoders attached to this crtc when changing mode. As such in a cloned configuration intel_encoder may not correspond to the correct is_edp encoder. By scoping intel_encoder to the loop, not only is the compiler able to spot this mistake, we also improve readiability for ourselves. [It might not be a mistake, within this function it is unclear as to whether it is permissable for eDP to be cloned...] Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/i915/intel_display.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 83c85450608e..0b90443f1eb3 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -3508,10 +3508,9 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc,
3508 u32 dpll = 0, fp = 0, fp2 = 0, dspcntr, pipeconf; 3508 u32 dpll = 0, fp = 0, fp2 = 0, dspcntr, pipeconf;
3509 bool ok, has_reduced_clock = false, is_sdvo = false, is_dvo = false; 3509 bool ok, has_reduced_clock = false, is_sdvo = false, is_dvo = false;
3510 bool is_crt = false, is_lvds = false, is_tv = false, is_dp = false; 3510 bool is_crt = false, is_lvds = false, is_tv = false, is_dp = false;
3511 bool is_edp = false; 3511 struct intel_encoder *has_edp_encoder = NULL;
3512 struct drm_mode_config *mode_config = &dev->mode_config; 3512 struct drm_mode_config *mode_config = &dev->mode_config;
3513 struct drm_encoder *encoder; 3513 struct drm_encoder *encoder;
3514 struct intel_encoder *intel_encoder = NULL;
3515 const intel_limit_t *limit; 3514 const intel_limit_t *limit;
3516 int ret; 3515 int ret;
3517 struct fdi_m_n m_n = {0}; 3516 struct fdi_m_n m_n = {0};
@@ -3532,12 +3531,12 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc,
3532 drm_vblank_pre_modeset(dev, pipe); 3531 drm_vblank_pre_modeset(dev, pipe);
3533 3532
3534 list_for_each_entry(encoder, &mode_config->encoder_list, head) { 3533 list_for_each_entry(encoder, &mode_config->encoder_list, head) {
3534 struct intel_encoder *intel_encoder;
3535 3535
3536 if (!encoder || encoder->crtc != crtc) 3536 if (encoder->crtc != crtc)
3537 continue; 3537 continue;
3538 3538
3539 intel_encoder = enc_to_intel_encoder(encoder); 3539 intel_encoder = enc_to_intel_encoder(encoder);
3540
3541 switch (intel_encoder->type) { 3540 switch (intel_encoder->type) {
3542 case INTEL_OUTPUT_LVDS: 3541 case INTEL_OUTPUT_LVDS:
3543 is_lvds = true; 3542 is_lvds = true;
@@ -3561,7 +3560,7 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc,
3561 is_dp = true; 3560 is_dp = true;
3562 break; 3561 break;
3563 case INTEL_OUTPUT_EDP: 3562 case INTEL_OUTPUT_EDP:
3564 is_edp = true; 3563 has_edp_encoder = intel_encoder;
3565 break; 3564 break;
3566 } 3565 }
3567 3566
@@ -3639,10 +3638,10 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc,
3639 int lane = 0, link_bw, bpp; 3638 int lane = 0, link_bw, bpp;
3640 /* eDP doesn't require FDI link, so just set DP M/N 3639 /* eDP doesn't require FDI link, so just set DP M/N
3641 according to current link config */ 3640 according to current link config */
3642 if (is_edp) { 3641 if (has_edp_encoder) {
3643 target_clock = mode->clock; 3642 target_clock = mode->clock;
3644 intel_edp_link_config(intel_encoder, 3643 intel_edp_link_config(has_edp_encoder,
3645 &lane, &link_bw); 3644 &lane, &link_bw);
3646 } else { 3645 } else {
3647 /* DP over FDI requires target mode clock 3646 /* DP over FDI requires target mode clock
3648 instead of link clock */ 3647 instead of link clock */
@@ -3663,7 +3662,7 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc,
3663 temp |= PIPE_8BPC; 3662 temp |= PIPE_8BPC;
3664 else 3663 else
3665 temp |= PIPE_6BPC; 3664 temp |= PIPE_6BPC;
3666 } else if (is_edp || (is_dp && intel_pch_has_edp(crtc))) { 3665 } else if (has_edp_encoder || (is_dp && intel_pch_has_edp(crtc))) {
3667 switch (dev_priv->edp_bpp/3) { 3666 switch (dev_priv->edp_bpp/3) {
3668 case 8: 3667 case 8:
3669 temp |= PIPE_8BPC; 3668 temp |= PIPE_8BPC;
@@ -3736,7 +3735,7 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc,
3736 3735
3737 udelay(200); 3736 udelay(200);
3738 3737
3739 if (is_edp) { 3738 if (has_edp_encoder) {
3740 if (dev_priv->lvds_use_ssc) { 3739 if (dev_priv->lvds_use_ssc) {
3741 temp |= DREF_SSC1_ENABLE; 3740 temp |= DREF_SSC1_ENABLE;
3742 I915_WRITE(PCH_DREF_CONTROL, temp); 3741 I915_WRITE(PCH_DREF_CONTROL, temp);
@@ -3885,7 +3884,7 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc,
3885 dpll_reg = pch_dpll_reg; 3884 dpll_reg = pch_dpll_reg;
3886 } 3885 }
3887 3886
3888 if (!is_edp) { 3887 if (!has_edp_encoder) {
3889 I915_WRITE(fp_reg, fp); 3888 I915_WRITE(fp_reg, fp);
3890 I915_WRITE(dpll_reg, dpll & ~DPLL_VCO_ENABLE); 3889 I915_WRITE(dpll_reg, dpll & ~DPLL_VCO_ENABLE);
3891 I915_READ(dpll_reg); 3890 I915_READ(dpll_reg);
@@ -3980,7 +3979,7 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc,
3980 } 3979 }
3981 } 3980 }
3982 3981
3983 if (!is_edp) { 3982 if (!has_edp_encoder) {
3984 I915_WRITE(fp_reg, fp); 3983 I915_WRITE(fp_reg, fp);
3985 I915_WRITE(dpll_reg, dpll); 3984 I915_WRITE(dpll_reg, dpll);
3986 I915_READ(dpll_reg); 3985 I915_READ(dpll_reg);
@@ -4059,7 +4058,7 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc,
4059 I915_WRITE(link_m1_reg, m_n.link_m); 4058 I915_WRITE(link_m1_reg, m_n.link_m);
4060 I915_WRITE(link_n1_reg, m_n.link_n); 4059 I915_WRITE(link_n1_reg, m_n.link_n);
4061 4060
4062 if (is_edp) { 4061 if (has_edp_encoder) {
4063 ironlake_set_pll_edp(crtc, adjusted_mode->clock); 4062 ironlake_set_pll_edp(crtc, adjusted_mode->clock);
4064 } else { 4063 } else {
4065 /* enable FDI RX PLL too */ 4064 /* enable FDI RX PLL too */