xf86-video-intel: src/sna/sna_dri2.c

Chris Wilson ickle at kemper.freedesktop.org
Sat Apr 4 13:01:40 PDT 2015


 src/sna/sna_dri2.c |   15 +++++++++++++++
 1 file changed, 15 insertions(+)

New commits:
commit 226a58bc592d4ed305b7ad0e460f1ee2548e0ddf
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sat Apr 4 20:58:24 2015 +0100

    sna/dri2: Prevent the sw cursor from copyig to a buffer as we discard it
    
    During swapbuffers, the sw cursor tries to write to the old buffer.
    Ordinary this is not an issue as we are discarding it, but under
    TearFree that write causes us to instantiate the shadow buffer with a
    possible recursion into set_bo and mayhem.
    
    Reported-by: Chris Bainbridge <chris.bainbridge at gmail.com>
    References: https://bugs.freedesktop.org/show_bug.cgi?id=89903
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/sna_dri2.c b/src/sna/sna_dri2.c
index e8100e4..2b7187d 100644
--- a/src/sna/sna_dri2.c
+++ b/src/sna/sna_dri2.c
@@ -818,7 +818,10 @@ static void set_bo(PixmapPtr pixmap, struct kgem_bo *bo)
 	assert(priv->flush);
 
 	if (APPLY_DAMAGE) {
+		ScreenPtr screen = pixmap->drawable.pScreen;
+		SourceValidateProcPtr SourceValidate;
 		RegionRec region;
+
 		/* Post damage on the new front buffer so that listeners, such
 		 * as DisplayLink know take a copy and shove it over the USB,
 		 * also for software cursors and the like.
@@ -827,7 +830,19 @@ static void set_bo(PixmapPtr pixmap, struct kgem_bo *bo)
 		region.extents.x2 = pixmap->drawable.width;
 		region.extents.y2 = pixmap->drawable.height;
 		region.data = NULL;
+
+		/*
+		 * SourceValidate is used by the software cursor code
+		 * to copy the original contents back before the drawing
+		 * operation causing us to instantiate the shadow buffer
+		 * just as we are in the process of swapping it away.
+		 */
+		SourceValidate = screen->SourceValidate;
+		screen->SourceValidate = NULL;
+
 		DamageRegionAppend(&pixmap->drawable, &region);
+
+		screen->SourceValidate = SourceValidate;
 	}
 
 	damage(pixmap, priv, NULL);


More information about the xorg-commit mailing list