Commit c4cc3839 authored by Mario Kleiner's avatar Mario Kleiner Committed by Dave Airlie

drm/vblank: Use abs64(diff_ns) for s64 diff_ns instead of abs(diff_ns)

Use of abs() wrongly wrapped diff_ns to 32 bit, which gives a 1/4000
probability of a missed vblank increment at each vblank irq reenable
if the kms driver doesn't support high precision vblank timestamping.
Not a big deal in practice, but let's make it nice.
Signed-off-by: default avatarMario Kleiner <mario.kleiner@tuebingen.mpg.de>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parent e40b6fc8
...@@ -164,7 +164,7 @@ static void vblank_disable_and_save(struct drm_device *dev, int crtc) ...@@ -164,7 +164,7 @@ static void vblank_disable_and_save(struct drm_device *dev, int crtc)
* available. In that case we can't account for this and just * available. In that case we can't account for this and just
* hope for the best. * hope for the best.
*/ */
if ((vblrc > 0) && (abs(diff_ns) > 1000000)) if ((vblrc > 0) && (abs64(diff_ns) > 1000000))
atomic_inc(&dev->_vblank_count[crtc]); atomic_inc(&dev->_vblank_count[crtc]);
/* Invalidate all timestamps while vblank irq's are off. */ /* Invalidate all timestamps while vblank irq's are off. */
...@@ -1293,7 +1293,7 @@ bool drm_handle_vblank(struct drm_device *dev, int crtc) ...@@ -1293,7 +1293,7 @@ bool drm_handle_vblank(struct drm_device *dev, int crtc)
* e.g., due to spurious vblank interrupts. We need to * e.g., due to spurious vblank interrupts. We need to
* ignore those for accounting. * ignore those for accounting.
*/ */
if (abs(diff_ns) > DRM_REDUNDANT_VBLIRQ_THRESH_NS) { if (abs64(diff_ns) > DRM_REDUNDANT_VBLIRQ_THRESH_NS) {
/* Store new timestamp in ringbuffer. */ /* Store new timestamp in ringbuffer. */
vblanktimestamp(dev, crtc, vblcount + 1) = tvblank; vblanktimestamp(dev, crtc, vblcount + 1) = tvblank;
smp_wmb(); smp_wmb();
......
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