diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c index 69aa0ab..c41cba4 100644 --- a/drivers/gpu/drm/drm_irq.c +++ b/drivers/gpu/drm/drm_irq.c @@ -341,7 +341,7 @@ int drm_control(struct drm_device *dev, void *data, * vblank events since the system was booted, including lost events due to * modesetting activity. */ -u32 drm_vblank_count(struct drm_device *dev, int crtc) +unsigned int drm_vblank_count(struct drm_device *dev, int crtc) { return atomic_read(&dev->_vblank_count[crtc]); } @@ -522,6 +522,11 @@ out: return ret; } +#define frame_after_eq(a,b) \ + (typecheck(unsigned int, a) && \ + typecheck(unsigned int, b) && \ + ((int)(a) - (int)(b) >= 0)) + /** * Wait for VBLANK. * @@ -589,10 +594,12 @@ int drm_wait_vblank(struct drm_device *dev, void *data, DRM_DEBUG("waiting on vblank count %d, crtc %d\n", vblwait->request.sequence, crtc); dev->last_vblank_wait[crtc] = vblwait->request.sequence; + + /* Wait for the sequence number to pass or IRQs to get disabled */ DRM_WAIT_ON(ret, dev->vbl_queue[crtc], 3 * DRM_HZ, - (((drm_vblank_count(dev, crtc) - - vblwait->request.sequence) <= (1 << 23)) || - !dev->irq_enabled)); + frame_after_eq(drm_vblank_count(dev, crtc), + vblwait->request.sequence) || + !dev->irq_enabled); if (ret != -EINTR) { struct timeval now;