aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/drm_irq.c
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2014-09-10 11:36:09 -0400
committerDaniel Vetter <daniel.vetter@ffwll.ch>2014-09-11 07:32:05 -0400
commit855d30b402b91f09c90f65c34ec91debaae8cf3a (patch)
tree49dc14e33919cf232cc37b49666cc21d317885db /drivers/gpu/drm/drm_irq.c
parentab8905f1c6a74d695c6096791ec4b349bc985b8a (diff)
drm: Only update final vblank count when precise ts is available
Drivers without a hardware vblank counter simply can't account for the vblanks that happened while the vblank interrupt was off. To check this grab a vblank timestamp and if the result is dubious follow the normal save-and-disable logic. Drivers should prevent this by setting vblank_disable_allowed = false, but since running vblank interrupts constantly is not good for power consumption most drivers lie. Testing for precise vblank timestamps is the next best thing we can check for. Suggested-by: Mario Kleiner <mario.kleiner.de@gmail.com> Cc: Mario Kleiner <mario.kleiner.de@gmail.com> Cc: Matt Roper <matthew.d.roper@intel.com> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com> Reviewed-by: Mario Kleiner <mario.kleiner.de@gmail.com> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Diffstat (limited to 'drivers/gpu/drm/drm_irq.c')
-rw-r--r--drivers/gpu/drm/drm_irq.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index 87d148cec877..ad699b729278 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -148,8 +148,15 @@ static void vblank_disable_and_save(struct drm_device *dev, int crtc)
148 * has been ticking all along until this time. This makes the 148 * has been ticking all along until this time. This makes the
149 * count account for the entire time between drm_vblank_on() and 149 * count account for the entire time between drm_vblank_on() and
150 * drm_vblank_off(). 150 * drm_vblank_off().
151 *
152 * But only do this if precise vblank timestamps are available.
153 * Otherwise we might read a totally bogus timestamp since drivers
154 * lacking precise timestamp support rely upon sampling the system clock
155 * at vblank interrupt time. Which obviously won't work out well if the
156 * vblank interrupt is disabled.
151 */ 157 */
152 if (!vblank->enabled) { 158 if (!vblank->enabled &&
159 drm_get_last_vbltimestamp(dev, crtc, &tvblank, 0) > 0) {
153 drm_update_vblank_count(dev, crtc); 160 drm_update_vblank_count(dev, crtc);
154 spin_unlock_irqrestore(&dev->vblank_time_lock, irqflags); 161 spin_unlock_irqrestore(&dev->vblank_time_lock, irqflags);
155 return; 162 return;