Commit 68036b08 authored by Dhinakaran Pandiyan's avatar Dhinakaran Pandiyan Committed by Rodrigo Vivi

drm/vblank: Do not update vblank count if interrupts are already disabled.

Updating vblank counts requires register reads and these reads may not
return meaningful values if the device was in a low power state after
vblank interrupts were last disabled. So, update the count only if vblank
interrupts are enabled. Secondly, this means the registers should be read
before disabling vblank interrupts.

v2: Don't check vblank->enabled outside it's lock (Chris)

Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Michel Dänzer <michel@daenzer.net>
Signed-off-by: default avatarDhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
Reviewed-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
Acked-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180203051302.9974-8-dhinakaran.pandiyan@intel.com
parent f4c0468e
...@@ -347,23 +347,25 @@ void drm_vblank_disable_and_save(struct drm_device *dev, unsigned int pipe) ...@@ -347,23 +347,25 @@ void drm_vblank_disable_and_save(struct drm_device *dev, unsigned int pipe)
spin_lock_irqsave(&dev->vblank_time_lock, irqflags); spin_lock_irqsave(&dev->vblank_time_lock, irqflags);
/* /*
* Only disable vblank interrupts if they're enabled. This avoids * Update vblank count and disable vblank interrupts only if the
* calling the ->disable_vblank() operation in atomic context with the * interrupts were enabled. This avoids calling the ->disable_vblank()
* hardware potentially runtime suspended. * operation in atomic context with the hardware potentially runtime
* suspended.
*/ */
if (vblank->enabled) { if (!vblank->enabled)
__disable_vblank(dev, pipe); goto out;
vblank->enabled = false;
}
/* /*
* Always update the count and timestamp to maintain the * Update the count and timestamp to maintain the
* appearance that the counter has been ticking all along until * appearance that the counter has been ticking all along until
* this time. This makes the count account for the entire time * this time. This makes the count account for the entire time
* between drm_crtc_vblank_on() and drm_crtc_vblank_off(). * between drm_crtc_vblank_on() and drm_crtc_vblank_off().
*/ */
drm_update_vblank_count(dev, pipe, false); drm_update_vblank_count(dev, pipe, false);
__disable_vblank(dev, pipe);
vblank->enabled = false;
out:
spin_unlock_irqrestore(&dev->vblank_time_lock, irqflags); spin_unlock_irqrestore(&dev->vblank_time_lock, irqflags);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment