From c66d57080dc034aa7877f47612065e388bbc38a2 Mon Sep 17 00:00:00 2001 From: Jesse Barnes Date: Mon, 8 Mar 2010 15:26:24 -0800 Subject: [PATCH] DRI2: more WaitMSC fixes A couple more niggles: make sure we return a target_msc that at least matches the current count; this is a little more friendly to clients that missed an event. Also check for >= when calculating the remainder so we'll catch the *next* vblank event when the calculation is satisfied, rather than the current one as might happen at times. Reported-by: Mario Kleiner Signed-off-by: Jesse Barnes --- src/i830_dri.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/i830_dri.c b/src/i830_dri.c index a81eada8..e8f24247 100644 --- a/src/i830_dri.c +++ b/src/i830_dri.c @@ -885,6 +885,14 @@ I830DRI2ScheduleWaitMSC(ClientPtr client, DrawablePtr draw, CARD64 target_msc, * client. */ if (divisor == 0 || current_msc < target_msc) { + /* If target_msc already reached or passed, set it to + * current_msc to ensure we return a reasonable value back + * to the caller. This keeps the client from continually + * sending us MSC targets from the past by forcibly updating + * their count on this call. + */ + if (current_msc >= target_msc) + target_msc = current_msc; vbl.request.type = DRM_VBLANK_ABSOLUTE | DRM_VBLANK_EVENT; if (pipe > 0) vbl.request.type |= DRM_VBLANK_SECONDARY; @@ -919,7 +927,7 @@ I830DRI2ScheduleWaitMSC(ClientPtr client, DrawablePtr draw, CARD64 target_msc, * seq % divisor == remainder, so we need to wait for the next time * that will happen. */ - if ((current_msc % divisor) > remainder) + if ((current_msc % divisor) >= remainder) vbl.request.sequence += divisor; vbl.request.signal = (unsigned long)wait_info;