Michel may want to change this a bit (make the check smaller), but I'd still like something like this to go in. The current wait_vblank condition won't return if the wait sequence is more than 8M behind the current counter. This causes problems in the wraparound case, which can happen if vblank interrupts have been disabled by the timer (after 5s of no waiters), but then re-enabled after a DPMS event.
(An alternative fix might be to not account for lost frames between off->on periods at all, removing the drm_update_vblank_count code entirely.) Signed-off-by: Jesse Barnes <jbar...@virtuousgeek.org> Tested-by: Timo Aaltonen <tjaal...@cc.hut.fi> 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; ------------------------------------------------------------------------------ Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM) software. With Adobe AIR, Ajax developers can use existing skills and code to build responsive, highly engaging applications that combine the power of local resources and data with the reach of the web. Download the Adobe AIR SDK and Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com -- _______________________________________________ Dri-devel mailing list Dri-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/dri-devel