diff options
author | Jesse Barnes <jbarnes@virtuousgeek.org> | 2010-08-18 16:20:54 -0400 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2010-08-22 01:59:23 -0400 |
commit | 9d0498a2bf7455159b317f19531a3e5db2ecc9c4 (patch) | |
tree | 41f2a8b1013d2ee12852d8885b9952120f3d6ebb /drivers/gpu/drm/i915/intel_display.c | |
parent | d240f20f545fa4ed78ce48d1eb62ab529f2b1467 (diff) |
drm/i915: wait for actual vblank, not just 20ms
Waiting for a hard coded 20ms isn't always enough to make sure a vblank
period has actually occurred, so add code to make sure we really have
passed through a vblank period (or that the pipe is off when disabling).
This prevents problems with mode setting and link training, and seems to
fix a bug like https://bugs.freedesktop.org/show_bug.cgi?id=29278, but
on an HP 8440p instead. Hopefully also fixes
https://bugs.freedesktop.org/show_bug.cgi?id=29141.
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Signed-off-by: Eric Anholt <eric@anholt.net>
Diffstat (limited to 'drivers/gpu/drm/i915/intel_display.c')
-rw-r--r-- | drivers/gpu/drm/i915/intel_display.c | 78 |
1 files changed, 56 insertions, 22 deletions
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index 14c45b1e877..bdea9464b67 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c | |||
@@ -977,14 +977,54 @@ intel_find_pll_g4x_dp(const intel_limit_t *limit, struct drm_crtc *crtc, | |||
977 | return true; | 977 | return true; |
978 | } | 978 | } |
979 | 979 | ||
980 | void | 980 | /** |
981 | intel_wait_for_vblank(struct drm_device *dev) | 981 | * intel_wait_for_vblank - wait for vblank on a given pipe |
982 | * @dev: drm device | ||
983 | * @pipe: pipe to wait for | ||
984 | * | ||
985 | * Wait for vblank to occur on a given pipe. Needed for various bits of | ||
986 | * mode setting code. | ||
987 | */ | ||
988 | void intel_wait_for_vblank(struct drm_device *dev, int pipe) | ||
982 | { | 989 | { |
983 | /* Wait for 20ms, i.e. one cycle at 50hz. */ | 990 | struct drm_i915_private *dev_priv = dev->dev_private; |
984 | if (in_dbg_master()) | 991 | int pipestat_reg = (pipe == 0 ? PIPEASTAT : PIPEBSTAT); |
985 | mdelay(20); /* The kernel debugger cannot call msleep() */ | 992 | |
986 | else | 993 | /* Wait for vblank interrupt bit to set */ |
987 | msleep(20); | 994 | if (wait_for((I915_READ(pipestat_reg) & |
995 | PIPE_VBLANK_INTERRUPT_STATUS) == 0, | ||
996 | 50, 0)) | ||
997 | DRM_DEBUG_KMS("vblank wait timed out\n"); | ||
998 | } | ||
999 | |||
1000 | /** | ||
1001 | * intel_wait_for_vblank_off - wait for vblank after disabling a pipe | ||
1002 | * @dev: drm device | ||
1003 | * @pipe: pipe to wait for | ||
1004 | * | ||
1005 | * After disabling a pipe, we can't wait for vblank in the usual way, | ||
1006 | * spinning on the vblank interrupt status bit, since we won't actually | ||
1007 | * see an interrupt when the pipe is disabled. | ||
1008 | * | ||
1009 | * So this function waits for the display line value to settle (it | ||
1010 | * usually ends up stopping at the start of the next frame). | ||
1011 | */ | ||
1012 | void intel_wait_for_vblank_off(struct drm_device *dev, int pipe) | ||
1013 | { | ||
1014 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
1015 | int pipedsl_reg = (pipe == 0 ? PIPEADSL : PIPEBDSL); | ||
1016 | unsigned long timeout = jiffies + msecs_to_jiffies(100); | ||
1017 | u32 last_line; | ||
1018 | |||
1019 | /* Wait for the display line to settle */ | ||
1020 | do { | ||
1021 | last_line = I915_READ(pipedsl_reg) & DSL_LINEMASK; | ||
1022 | mdelay(5); | ||
1023 | } while (((I915_READ(pipedsl_reg) & DSL_LINEMASK) != last_line) && | ||
1024 | time_after(timeout, jiffies)); | ||
1025 | |||
1026 | if (time_after(jiffies, timeout)) | ||
1027 | DRM_DEBUG_KMS("vblank wait timed out\n"); | ||
988 | } | 1028 | } |
989 | 1029 | ||
990 | /* Parameters have changed, update FBC info */ | 1030 | /* Parameters have changed, update FBC info */ |
@@ -1057,8 +1097,6 @@ void i8xx_disable_fbc(struct drm_device *dev) | |||
1057 | return; | 1097 | return; |
1058 | } | 1098 | } |
1059 | 1099 | ||
1060 | intel_wait_for_vblank(dev); | ||
1061 | |||
1062 | DRM_DEBUG_KMS("disabled FBC\n"); | 1100 | DRM_DEBUG_KMS("disabled FBC\n"); |
1063 | } | 1101 | } |
1064 | 1102 | ||
@@ -1115,7 +1153,6 @@ void g4x_disable_fbc(struct drm_device *dev) | |||
1115 | dpfc_ctl = I915_READ(DPFC_CONTROL); | 1153 | dpfc_ctl = I915_READ(DPFC_CONTROL); |
1116 | dpfc_ctl &= ~DPFC_CTL_EN; | 1154 | dpfc_ctl &= ~DPFC_CTL_EN; |
1117 | I915_WRITE(DPFC_CONTROL, dpfc_ctl); | 1155 | I915_WRITE(DPFC_CONTROL, dpfc_ctl); |
1118 | intel_wait_for_vblank(dev); | ||
1119 | 1156 | ||
1120 | DRM_DEBUG_KMS("disabled FBC\n"); | 1157 | DRM_DEBUG_KMS("disabled FBC\n"); |
1121 | } | 1158 | } |
@@ -1176,7 +1213,6 @@ void ironlake_disable_fbc(struct drm_device *dev) | |||
1176 | dpfc_ctl = I915_READ(ILK_DPFC_CONTROL); | 1213 | dpfc_ctl = I915_READ(ILK_DPFC_CONTROL); |
1177 | dpfc_ctl &= ~DPFC_CTL_EN; | 1214 | dpfc_ctl &= ~DPFC_CTL_EN; |
1178 | I915_WRITE(ILK_DPFC_CONTROL, dpfc_ctl); | 1215 | I915_WRITE(ILK_DPFC_CONTROL, dpfc_ctl); |
1179 | intel_wait_for_vblank(dev); | ||
1180 | 1216 | ||
1181 | DRM_DEBUG_KMS("disabled FBC\n"); | 1217 | DRM_DEBUG_KMS("disabled FBC\n"); |
1182 | } | 1218 | } |
@@ -1475,7 +1511,7 @@ intel_pipe_set_base_atomic(struct drm_crtc *crtc, struct drm_framebuffer *fb, | |||
1475 | if ((IS_I965G(dev) || plane == 0)) | 1511 | if ((IS_I965G(dev) || plane == 0)) |
1476 | intel_update_fbc(crtc, &crtc->mode); | 1512 | intel_update_fbc(crtc, &crtc->mode); |
1477 | 1513 | ||
1478 | intel_wait_for_vblank(dev); | 1514 | intel_wait_for_vblank(dev, intel_crtc->pipe); |
1479 | intel_increase_pllclock(crtc, true); | 1515 | intel_increase_pllclock(crtc, true); |
1480 | 1516 | ||
1481 | return 0; | 1517 | return 0; |
@@ -1593,7 +1629,7 @@ intel_pipe_set_base(struct drm_crtc *crtc, int x, int y, | |||
1593 | if ((IS_I965G(dev) || plane == 0)) | 1629 | if ((IS_I965G(dev) || plane == 0)) |
1594 | intel_update_fbc(crtc, &crtc->mode); | 1630 | intel_update_fbc(crtc, &crtc->mode); |
1595 | 1631 | ||
1596 | intel_wait_for_vblank(dev); | 1632 | intel_wait_for_vblank(dev, pipe); |
1597 | 1633 | ||
1598 | if (old_fb) { | 1634 | if (old_fb) { |
1599 | intel_fb = to_intel_framebuffer(old_fb); | 1635 | intel_fb = to_intel_framebuffer(old_fb); |
@@ -2343,10 +2379,8 @@ static void i9xx_crtc_dpms(struct drm_crtc *crtc, int mode) | |||
2343 | I915_READ(dspbase_reg); | 2379 | I915_READ(dspbase_reg); |
2344 | } | 2380 | } |
2345 | 2381 | ||
2346 | if (!IS_I9XX(dev)) { | 2382 | /* Wait for vblank for the disable to take effect */ |
2347 | /* Wait for vblank for the disable to take effect */ | 2383 | intel_wait_for_vblank_off(dev, pipe); |
2348 | intel_wait_for_vblank(dev); | ||
2349 | } | ||
2350 | 2384 | ||
2351 | /* Don't disable pipe A or pipe A PLLs if needed */ | 2385 | /* Don't disable pipe A or pipe A PLLs if needed */ |
2352 | if (pipeconf_reg == PIPEACONF && | 2386 | if (pipeconf_reg == PIPEACONF && |
@@ -2361,7 +2395,7 @@ static void i9xx_crtc_dpms(struct drm_crtc *crtc, int mode) | |||
2361 | } | 2395 | } |
2362 | 2396 | ||
2363 | /* Wait for vblank for the disable to take effect. */ | 2397 | /* Wait for vblank for the disable to take effect. */ |
2364 | intel_wait_for_vblank(dev); | 2398 | intel_wait_for_vblank_off(dev, pipe); |
2365 | 2399 | ||
2366 | temp = I915_READ(dpll_reg); | 2400 | temp = I915_READ(dpll_reg); |
2367 | if ((temp & DPLL_VCO_ENABLE) != 0) { | 2401 | if ((temp & DPLL_VCO_ENABLE) != 0) { |
@@ -4096,7 +4130,7 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc, | |||
4096 | I915_WRITE(pipeconf_reg, pipeconf); | 4130 | I915_WRITE(pipeconf_reg, pipeconf); |
4097 | I915_READ(pipeconf_reg); | 4131 | I915_READ(pipeconf_reg); |
4098 | 4132 | ||
4099 | intel_wait_for_vblank(dev); | 4133 | intel_wait_for_vblank(dev, pipe); |
4100 | 4134 | ||
4101 | if (IS_IRONLAKE(dev)) { | 4135 | if (IS_IRONLAKE(dev)) { |
4102 | /* enable address swizzle for tiling buffer */ | 4136 | /* enable address swizzle for tiling buffer */ |
@@ -4508,7 +4542,7 @@ struct drm_crtc *intel_get_load_detect_pipe(struct intel_encoder *intel_encoder, | |||
4508 | encoder_funcs->commit(encoder); | 4542 | encoder_funcs->commit(encoder); |
4509 | } | 4543 | } |
4510 | /* let the connector get through one full cycle before testing */ | 4544 | /* let the connector get through one full cycle before testing */ |
4511 | intel_wait_for_vblank(dev); | 4545 | intel_wait_for_vblank(dev, intel_crtc->pipe); |
4512 | 4546 | ||
4513 | return crtc; | 4547 | return crtc; |
4514 | } | 4548 | } |
@@ -4713,7 +4747,7 @@ static void intel_increase_pllclock(struct drm_crtc *crtc, bool schedule) | |||
4713 | dpll &= ~DISPLAY_RATE_SELECT_FPA1; | 4747 | dpll &= ~DISPLAY_RATE_SELECT_FPA1; |
4714 | I915_WRITE(dpll_reg, dpll); | 4748 | I915_WRITE(dpll_reg, dpll); |
4715 | dpll = I915_READ(dpll_reg); | 4749 | dpll = I915_READ(dpll_reg); |
4716 | intel_wait_for_vblank(dev); | 4750 | intel_wait_for_vblank(dev, pipe); |
4717 | dpll = I915_READ(dpll_reg); | 4751 | dpll = I915_READ(dpll_reg); |
4718 | if (dpll & DISPLAY_RATE_SELECT_FPA1) | 4752 | if (dpll & DISPLAY_RATE_SELECT_FPA1) |
4719 | DRM_DEBUG_DRIVER("failed to upclock LVDS!\n"); | 4753 | DRM_DEBUG_DRIVER("failed to upclock LVDS!\n"); |
@@ -4757,7 +4791,7 @@ static void intel_decrease_pllclock(struct drm_crtc *crtc) | |||
4757 | dpll |= DISPLAY_RATE_SELECT_FPA1; | 4791 | dpll |= DISPLAY_RATE_SELECT_FPA1; |
4758 | I915_WRITE(dpll_reg, dpll); | 4792 | I915_WRITE(dpll_reg, dpll); |
4759 | dpll = I915_READ(dpll_reg); | 4793 | dpll = I915_READ(dpll_reg); |
4760 | intel_wait_for_vblank(dev); | 4794 | intel_wait_for_vblank(dev, pipe); |
4761 | dpll = I915_READ(dpll_reg); | 4795 | dpll = I915_READ(dpll_reg); |
4762 | if (!(dpll & DISPLAY_RATE_SELECT_FPA1)) | 4796 | if (!(dpll & DISPLAY_RATE_SELECT_FPA1)) |
4763 | DRM_DEBUG_DRIVER("failed to downclock LVDS!\n"); | 4797 | DRM_DEBUG_DRIVER("failed to downclock LVDS!\n"); |