xf86-video-intel: 3 commits - src/i830_dri.c

Jesse Barnes jbarnes at kemper.freedesktop.org
Mon Mar 8 15:44:04 PST 2010


 src/i830_dri.c |   44 ++++++++++++++++++++++++++++++++------------
 1 file changed, 32 insertions(+), 12 deletions(-)

New commits:
commit 68629b63740fb6e62c258b8a46669e77660fa4e4
Author: Jesse Barnes <jbarnes at virtuousgeek.org>
Date:   Mon Mar 8 15:42:39 2010 -0800

    DRI2: make WaitMSC error handling more consistent with ScheduleSwap
    
    Just make it mirror ScheduleSwap: complete the wait on any error
    condition so as not to crash the client if the kernel is misbehaving.
    
    Signed-off-by: Jesse Barnes <jbarnes at virtuousgeek.org>

diff --git a/src/i830_dri.c b/src/i830_dri.c
index fc17807..7c595dd 100644
--- a/src/i830_dri.c
+++ b/src/i830_dri.c
@@ -862,16 +862,12 @@ I830DRI2ScheduleWaitMSC(ClientPtr client, DrawablePtr draw, CARD64 target_msc,
 	remainder &= 0xffffffff;
 
 	/* Drawable not visible, return immediately */
-	if (pipe == -1) {
-		DRI2WaitMSCComplete(client, draw, target_msc, 0, 0);
-		return TRUE;
-	}
+	if (pipe == -1)
+		goto out_complete;
 
 	wait_info = xcalloc(1, sizeof(DRI2FrameEventRec));
-	if (!wait_info) {
-		DRI2WaitMSCComplete(client, draw, 0, 0, 0);
-		return TRUE;
-	}
+	if (!wait_info)
+		goto out_complete;
 
 	wait_info->drawable_id = draw->id;
 	wait_info->client = client;
@@ -886,7 +882,7 @@ I830DRI2ScheduleWaitMSC(ClientPtr client, DrawablePtr draw, CARD64 target_msc,
 	if (ret) {
 		xf86DrvMsg(scrn->scrnIndex, X_WARNING,
 			   "get vblank counter failed: %s\n", strerror(errno));
-		return FALSE;
+		goto out_complete;
 	}
 
 	current_msc = vbl.reply.sequence;
@@ -914,7 +910,7 @@ I830DRI2ScheduleWaitMSC(ClientPtr client, DrawablePtr draw, CARD64 target_msc,
 		if (ret) {
 			xf86DrvMsg(scrn->scrnIndex, X_WARNING,
 				   "get vblank counter failed: %s\n", strerror(errno));
-			return FALSE;
+			goto out_complete;
 		}
 
 		wait_info->frame = vbl.reply.sequence;
@@ -947,13 +943,17 @@ I830DRI2ScheduleWaitMSC(ClientPtr client, DrawablePtr draw, CARD64 target_msc,
 	if (ret) {
 		xf86DrvMsg(scrn->scrnIndex, X_WARNING,
 			   "get vblank counter failed: %s\n", strerror(errno));
-		return FALSE;
+		goto out_complete;
 	}
 
 	wait_info->frame = vbl.reply.sequence;
 	DRI2BlockClient(client, draw);
 
 	return TRUE;
+
+out_complete:
+	DRI2WaitMSCComplete(client, draw, target_msc, 0, 0);
+	return TRUE;
 }
 #endif
 
commit 6df74e61afb7831ebf3fbab8782f46ddccbe262b
Author: Jesse Barnes <jbarnes at virtuousgeek.org>
Date:   Mon Mar 8 15:33:20 2010 -0800

    DRI2: truncate OML values to 32 bits
    
    We can only handle 32 bit values unless we totally virtualize the count,
    since the kernel only handles 32 bits itself.  Rather than adding all
    that overhead, just tolerate the occasional missed event everytime the
    counter runs over.
    
    Reported-by: Mario Kleiner <mario.kleiner at tuebingen.mpg.de>
    Signed-off-by: Jesse Barnes <jbarnes at virtuousgeek.org>

diff --git a/src/i830_dri.c b/src/i830_dri.c
index e8f2424..fc17807 100644
--- a/src/i830_dri.c
+++ b/src/i830_dri.c
@@ -645,6 +645,12 @@ I830DRI2ScheduleSwap(ClientPtr client, DrawablePtr draw, DRI2BufferPtr front,
 	BoxRec box;
 	RegionRec region;
 
+	/* Truncate to match kernel interfaces; means occasional overflow
+	 * misses, but that's generally not a big deal */
+	*target_msc &= 0xffffffff;
+	divisor &= 0xffffffff;
+	remainder &= 0xffffffff;
+
 	swap_info = xcalloc(1, sizeof(DRI2FrameEventRec));
 
 	/* Drawable not displayed... just complete the swap */
@@ -849,6 +855,12 @@ I830DRI2ScheduleWaitMSC(ClientPtr client, DrawablePtr draw, CARD64 target_msc,
 	int ret, pipe = I830DRI2DrawablePipe(draw);
 	CARD64 current_msc;
 
+	/* Truncate to match kernel interfaces; means occasional overflow
+	 * misses, but that's generally not a big deal */
+	target_msc &= 0xffffffff;
+	divisor &= 0xffffffff;
+	remainder &= 0xffffffff;
+
 	/* Drawable not visible, return immediately */
 	if (pipe == -1) {
 		DRI2WaitMSCComplete(client, draw, target_msc, 0, 0);
commit c66d57080dc034aa7877f47612065e388bbc38a2
Author: Jesse Barnes <jbarnes at virtuousgeek.org>
Date:   Mon Mar 8 15:26:24 2010 -0800

    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 <mario.kleiner at tuebingen.mpg.de>
    Signed-off-by: Jesse Barnes <jbarnes at virtuousgeek.org>

diff --git a/src/i830_dri.c b/src/i830_dri.c
index a81eada..e8f2424 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;


More information about the xorg-commit mailing list