[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

xserver-xorg-video-intel: Changes to 'upstream-experimental'



 NEWS                  |   25 ++++
 configure.ac          |    2 
 src/sna/gen4_render.c |   13 +-
 src/sna/gen4_render.h |    2 
 src/sna/gen5_render.c |    6 
 src/sna/gen6_render.c |   11 +
 src/sna/gen7_render.c |    2 
 src/sna/gen8_render.c |    2 
 src/sna/kgem.c        |   14 +-
 src/sna/kgem.h        |   10 +
 src/sna/sna_accel.c   |  301 ++++++++++++++++++++++++++++++--------------------
 src/sna/sna_glyphs.c  |    3 
 src/uxa/intel_video.c |    3 
 13 files changed, 253 insertions(+), 141 deletions(-)

New commits:
commit 2fb2cd092dadba40b5ad2da57943c660a0c9bc14
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Mon Feb 10 09:35:11 2014 +0000

    2.99.910 snapshot

diff --git a/NEWS b/NEWS
index 63655d3..5700d34 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,28 @@
+Snapshot 2.99.910 (2013-02-10)
+==============================
+Another latent bug exposed by recent changes merit another snapshot for
+final testing.
+
+  * Only discard damage when overwriting the dirty CPU bo, instead
+    of discarding damage that will be shown!
+
+  * Reset operation state when switching between glyph caches.
+    https://bugs.freedesktop.org/show_bug.cgi?id=74494
+
+  * Fully reinitialise pixmaps allocated from the freed cache. Fixes
+    a potential issue (crash or misrendering) when using some compositors.
+    https://bugs.freedesktop.org/show_bug.cgi?id=74550
+
+  * Do not expose the TexturedVideo adaptor in UXA when it is disabled
+    either due to a hung GPU or explicitly disabled by the user.
+
+  * Restore the pipe stall when changing CC state on gen6, otherwise
+    the GPU may not flush intermediate results from all EU resulting
+    in render corruption (usually the occasional black box).
+    Regression from 2.99.906
+    https://bugs.freedesktop.org/show_bug.cgi?id=7237
+
+
 Snapshot 2.99.909 (2013-02-01)
 ==============================
 Pass the brown paper bag. Ridiculously stupid bug in last minute coding.
diff --git a/configure.ac b/configure.ac
index f7a6d32..a3114af 100644
--- a/configure.ac
+++ b/configure.ac
@@ -23,7 +23,7 @@
 # Initialize Autoconf
 AC_PREREQ([2.60])
 AC_INIT([xf86-video-intel],
-        [2.99.909],
+        [2.99.910],
         [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
         [xf86-video-intel])
 AC_CONFIG_SRCDIR([Makefile.am])

commit 37d8566ee78c67647b159a96ddb2675d1506b967
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Sun Feb 9 12:28:27 2014 +0000

    sna/gen6: Restore stall dropped when not flushing instead
    
    commit 82e6d41c2f4f343bd1854d3d8ee4b624b5d68971
    Author: Chris Wilson <chris@chris-wilson.co.uk>
    Date:   Thu Oct 31 13:35:59 2013 +0000
    
        sna/gen6: Tweak flush around CC state changes
    
    Replaced the pipeline stall with a flush - but only when the target was
    dirty. The missing stall however seems to be required as well.
    
    v2: Actually emit the stall for all CC state changes [Ilia Mirkin]
    
    Reported-by: Ilia Mirkin <imirkin@alum.mit.edu>
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=72375
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

diff --git a/src/sna/gen6_render.c b/src/sna/gen6_render.c
index aadc6f7..f36bf79 100644
--- a/src/sna/gen6_render.c
+++ b/src/sna/gen6_render.c
@@ -870,15 +870,16 @@ gen6_emit_state(struct sna *sna,
 
 	assert(op->dst.bo->exec);
 
-	need_flush =
-		gen6_emit_cc(sna, GEN6_BLEND(op->u.gen6.flags)) &&
-		wm_binding_table & 1;
+	need_stall = wm_binding_table & 1;
+	need_flush = false;
+	if (gen6_emit_cc(sna, GEN6_BLEND(op->u.gen6.flags)))
+		need_flush = need_stall;
 	gen6_emit_sampler(sna, GEN6_SAMPLER(op->u.gen6.flags));
 	gen6_emit_sf(sna, GEN6_VERTEX(op->u.gen6.flags) >> 2);
 	gen6_emit_wm(sna, GEN6_KERNEL(op->u.gen6.flags), GEN6_VERTEX(op->u.gen6.flags) >> 2);
 	gen6_emit_vertex_elements(sna, op);
 
-	need_stall = gen6_emit_binding_table(sna, wm_binding_table & ~1);
+	need_stall |= gen6_emit_binding_table(sna, wm_binding_table & ~1);
 	if (gen6_emit_drawing_rectangle(sna, op))
 		need_stall = false;
 	if (need_flush || kgem_bo_is_dirty(op->src.bo) || kgem_bo_is_dirty(op->mask.bo)) {

commit 823382d28944a319c207f20ecef25ce1707a8021
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Thu Feb 6 10:13:41 2014 +0000

    sna: And clear drawable->id on reused pixmaps
    
    References: https://bugs.freedesktop.org/show_bug.cgi?id=74550
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c
index 457cc41..3919997 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -870,10 +870,11 @@ create_pixmap_hdr(struct sna *sna, ScreenPtr screen,
 		assert(pixmap->drawable.type == DRAWABLE_PIXMAP);
 		assert(pixmap->drawable.class == 0);
 		assert(pixmap->drawable.pScreen == screen);
-		assert(pixmap->drawable.id == 0);
 		assert(pixmap->drawable.x == 0);
 		assert(pixmap->drawable.y == 0);
 
+		pixmap->drawable.id = 0;
+
 		pixmap->drawable.depth = depth;
 		pixmap->drawable.bitsPerPixel = bits_per_pixel(depth);
 		pixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;

commit 6fc46adb18a8410074c12d6e8979ef01813ebdf2
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Thu Feb 6 09:24:17 2014 +0000

    uxa: Do not expose TextureVideo Xv adapters when acceleration is disabled
    
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

diff --git a/src/uxa/intel_video.c b/src/uxa/intel_video.c
index d1b98d4..01919e3 100644
--- a/src/uxa/intel_video.c
+++ b/src/uxa/intel_video.c
@@ -354,7 +354,8 @@ void I830InitVideo(ScreenPtr screen)
 	/* Set up textured video if we can do it at this depth and we are on
 	 * supported hardware.
 	 */
-	if (scrn->bitsPerPixel >= 16 &&
+	if (!intel->force_fallback &&
+	    scrn->bitsPerPixel >= 16 &&
 	    INTEL_INFO(intel)->gen >= 030) {
 		texturedAdaptor = I830SetupImageVideoTextured(screen);
 		if (texturedAdaptor != NULL) {

commit 1eadd1d0b1c8bcbf11eb7c0e112d1e424b63c25e
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Thu Feb 6 09:04:30 2014 +0000

    sna: Add some DBG to clarify the source pixmap (for tiles)
    
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c
index 14a669d..457cc41 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -11389,6 +11389,8 @@ sna_pixmap_get_source_bo(PixmapPtr pixmap)
 {
 	struct sna_pixmap *priv = sna_pixmap(pixmap);
 
+	DBG(("%s(pixmap=%ld)\n", __FUNCTION__, pixmap->drawable.serialNumber));
+
 	if (priv == NULL) {
 		struct kgem_bo *upload;
 		struct sna *sna = to_sna_from_pixmap(pixmap);
@@ -11988,7 +11990,8 @@ sna_poly_fill_rect_tiled_blt(DrawablePtr drawable,
 	}
 
 	get_drawable_deltas(drawable, pixmap, &dx, &dy);
-	DBG(("%s: drawable offset into pixmap = (%d, %d)\n", __FUNCTION__, dx, dy));
+	DBG(("%s: drawable offset into pixmap(%ld) = (%d, %d)\n",
+	     __FUNCTION__, pixmap->drawable.serialNumber, dx, dy));
 	if (!clipped) {
 		dx += drawable->x;
 		dy += drawable->y;

commit 4d1a2ef9553c663bb97b56adde6f6b41241ff528
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Thu Feb 6 08:29:20 2014 +0000

    sna: Reset composite offsets when reusing freed pixmaps
    
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=74550
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c
index e57cb17..14a669d 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -846,19 +846,57 @@ __pop_freed_pixmap(struct sna *sna)
 	return pixmap;
 }
 
-static PixmapPtr
-create_pixmap_hdr(struct sna *sna, int usage)
+inline static PixmapPtr
+create_pixmap_hdr(struct sna *sna, ScreenPtr screen,
+		  int width, int height, int depth, int usage,
+		  struct sna_pixmap **priv)
 {
-	PixmapPtr pixmap = __pop_freed_pixmap(sna);
+	PixmapPtr pixmap;
 
-	pixmap->usage_hint = usage;
-	pixmap->refcnt = 1;
-	pixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+	if (sna->freed_pixmap == NULL) {
+		pixmap = create_pixmap(sna, screen, 0, 0, depth, usage);
+		if (pixmap == NullPixmap)
+			return NullPixmap;
+
+		*priv = sna_pixmap_attach(pixmap);
+		if (!*priv) {
+			FreePixmap(pixmap);
+			return NullPixmap;
+		}
+	} else {
+		pixmap = __pop_freed_pixmap(sna);
+		*priv = _sna_pixmap_reset(pixmap);
+
+		assert(pixmap->drawable.type == DRAWABLE_PIXMAP);
+		assert(pixmap->drawable.class == 0);
+		assert(pixmap->drawable.pScreen == screen);
+		assert(pixmap->drawable.id == 0);
+		assert(pixmap->drawable.x == 0);
+		assert(pixmap->drawable.y == 0);
+
+		pixmap->drawable.depth = depth;
+		pixmap->drawable.bitsPerPixel = bits_per_pixel(depth);
+		pixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+
+		pixmap->devKind = 0;
+		pixmap->devPrivate.ptr = NULL;
+
+#ifdef COMPOSITE
+		pixmap->screen_x = 0;
+		pixmap->screen_y = 0;
+#endif
 
 #if DEBUG_MEMORY
-	sna->debug_memory.pixmap_allocs++;
+		sna->debug_memory.pixmap_allocs++;
 #endif
 
+		pixmap->refcnt = 1;
+	}
+
+	pixmap->drawable.width = width;
+	pixmap->drawable.height = height;
+	pixmap->usage_hint = usage;
+
 	return pixmap;
 }
 
@@ -891,31 +929,9 @@ fallback:
 		return pixmap;
 	}
 
-	if (sna->freed_pixmap) {
-		pixmap = create_pixmap_hdr(sna, 0);
-		priv = _sna_pixmap_reset(pixmap);
-	} else {
-		pixmap = create_pixmap(sna, screen, 0, 0, depth, 0);
-		if (pixmap == NullPixmap)
-			return NullPixmap;
-
-		priv = sna_pixmap_attach(pixmap);
-		if (!priv) {
-			FreePixmap(pixmap);
-			return NullPixmap;
-		}
-	}
-
-	pixmap->drawable.width = width;
-	pixmap->drawable.height = height;
-	pixmap->drawable.depth = depth;
-	pixmap->drawable.bitsPerPixel = bpp;
-
-	DBG(("%s: serial=%ld, %dx%d\n",
-	     __FUNCTION__,
-	     pixmap->drawable.serialNumber,
-	     pixmap->drawable.width,
-	     pixmap->drawable.height));
+	pixmap = create_pixmap_hdr(sna, screen, width, height, depth, 0, &priv);
+	if (pixmap == NullPixmap)
+		goto fallback;
 
 	priv->cpu_bo = kgem_create_map(&sna->kgem, addr, pitch*height, false);
 	if (priv->cpu_bo == NULL) {
@@ -940,6 +956,13 @@ fallback:
 
 	pixmap->devKind = pitch;
 	pixmap->devPrivate.ptr = addr;
+
+	DBG(("%s: serial=%ld, %dx%d, usage=%d\n",
+	     __FUNCTION__,
+	     pixmap->drawable.serialNumber,
+	     pixmap->drawable.width,
+	     pixmap->drawable.height,
+	     pixmap->usage_hint));
 	return pixmap;
 }
 
@@ -978,34 +1001,9 @@ sna_pixmap_create_scratch(ScreenPtr screen,
 	tiling = kgem_choose_tiling(&sna->kgem, tiling, width, height, bpp);
 
 	/* you promise never to access this via the cpu... */
-	if (sna->freed_pixmap) {
-		pixmap = create_pixmap_hdr(sna, CREATE_PIXMAP_USAGE_SCRATCH);
-		priv = _sna_pixmap_reset(pixmap);
-	} else {
-		pixmap = create_pixmap(sna, screen, 0, 0, depth,
-				       CREATE_PIXMAP_USAGE_SCRATCH);
-		if (pixmap == NullPixmap)
-			return NullPixmap;
-
-		priv = sna_pixmap_attach(pixmap);
-		if (!priv) {
-			FreePixmap(pixmap);
-			return NullPixmap;
-		}
-	}
-
-	pixmap->drawable.width = width;
-	pixmap->drawable.height = height;
-	pixmap->drawable.depth = depth;
-	pixmap->drawable.bitsPerPixel = bpp;
-	pixmap->devPrivate.ptr = NULL;
-
-	DBG(("%s: serial=%ld, usage=%d, %dx%d\n",
-	     __FUNCTION__,
-	     pixmap->drawable.serialNumber,
-	     pixmap->usage_hint,
-	     pixmap->drawable.width,
-	     pixmap->drawable.height));
+	pixmap = create_pixmap_hdr(sna, screen, width, height, depth, CREATE_PIXMAP_USAGE_SCRATCH, &priv);
+	if (pixmap == NullPixmap)
+		return NullPixmap;
 
 	priv->stride = PixmapBytePad(width, depth);
 	priv->header = true;
@@ -1023,7 +1021,14 @@ sna_pixmap_create_scratch(ScreenPtr screen,
 
 	assert(to_sna_from_pixmap(pixmap) == sna);
 	assert(pixmap->drawable.pScreen == screen);
+	assert(pixmap->refcnt == 1);
 
+	DBG(("%s: serial=%ld, %dx%d, usage=%d\n",
+	     __FUNCTION__,
+	     pixmap->drawable.serialNumber,
+	     pixmap->drawable.width,
+	     pixmap->drawable.height,
+	     pixmap->usage_hint));
 	return pixmap;
 }
 
@@ -1316,34 +1321,9 @@ static PixmapPtr sna_create_pixmap(ScreenPtr screen,
 		DBG(("%s: creating GPU pixmap %dx%d, stride=%d, flags=%x\n",
 		     __FUNCTION__, width, height, pad, flags));
 
-		if (sna->freed_pixmap) {
-			pixmap = create_pixmap_hdr(sna, CREATE_PIXMAP_USAGE_SCRATCH);
-			priv = _sna_pixmap_reset(pixmap);
-		} else {
-			pixmap = create_pixmap(sna, screen, 0, 0, depth, usage);
-			if (pixmap == NullPixmap)
-				return NullPixmap;
-
-			priv = sna_pixmap_attach(pixmap);
-			if (priv == NULL) {
-				free(pixmap);
-				goto fallback;
-			}
-		}
-
-		DBG(("%s: serial=%ld, usage=%d, %dx%d\n",
-		     __FUNCTION__,
-		     pixmap->drawable.serialNumber,
-		     pixmap->usage_hint,
-		     pixmap->drawable.width,
-		     pixmap->drawable.height));
-
-		pixmap->drawable.width = width;
-		pixmap->drawable.height = height;
-		pixmap->drawable.depth = depth;
-		pixmap->drawable.bitsPerPixel = bits_per_pixel(depth);
-		pixmap->devKind = pad;
-		pixmap->devPrivate.ptr = NULL;
+		pixmap = create_pixmap_hdr(sna, screen, width, height, depth, usage, &priv);
+		if (pixmap == NullPixmap)
+			return NullPixmap;
 
 		priv->header = true;
 		ptr = NULL;
@@ -1355,7 +1335,14 @@ static PixmapPtr sna_create_pixmap(ScreenPtr screen,
 
 	assert(to_sna_from_pixmap(pixmap) == sna);
 	assert(pixmap->drawable.pScreen == screen);
+	assert(pixmap->refcnt == 1);
 
+	DBG(("%s: serial=%ld, %dx%d, usage=%d\n",
+	     __FUNCTION__,
+	     pixmap->drawable.serialNumber,
+	     pixmap->drawable.width,
+	     pixmap->drawable.height,
+	     pixmap->usage_hint));
 	return pixmap;
 
 fallback:
@@ -3759,26 +3746,11 @@ sna_pixmap_create_upload(ScreenPtr screen,
 		return create_pixmap(sna, screen, width, height, depth,
 				     CREATE_PIXMAP_USAGE_SCRATCH);
 
-	if (sna->freed_pixmap) {
-		pixmap = create_pixmap_hdr(sna, CREATE_PIXMAP_USAGE_SCRATCH);
-		priv = _sna_pixmap_reset(pixmap);
-	} else {
-		pixmap = create_pixmap(sna, screen, 0, 0, depth,
-				       CREATE_PIXMAP_USAGE_SCRATCH);
-		if (!pixmap)
-			return NullPixmap;
-
-		priv = sna_pixmap_attach(pixmap);
-		if (!priv) {
-			FreePixmap(pixmap);
-			return NullPixmap;
-		}
-	}
-
-	pixmap->drawable.width = width;
-	pixmap->drawable.height = height;
-	pixmap->drawable.depth = depth;
-	pixmap->drawable.bitsPerPixel = bits_per_pixel(depth);
+	pixmap = create_pixmap_hdr(sna, screen,
+				   width, height, depth, CREATE_PIXMAP_USAGE_SCRATCH,
+				   &priv);
+	if (!pixmap)
+		return NullPixmap;
 
 	priv->gpu_bo = kgem_create_buffer_2d(&sna->kgem,
 					     width, height,
@@ -3807,11 +3779,12 @@ sna_pixmap_create_upload(ScreenPtr screen,
 	if (!kgem_buffer_is_inplace(priv->gpu_bo))
 		pixmap->usage_hint = 1;
 
-	DBG(("%s: serial=%ld, usage=%d\n",
+	DBG(("%s: serial=%ld, %dx%d, usage=%d\n",
 	     __FUNCTION__,
 	     pixmap->drawable.serialNumber,
+	     pixmap->drawable.width,
+	     pixmap->drawable.height,
 	     pixmap->usage_hint));
-
 	return pixmap;
 }
 

commit 79d2f96bdfa0d7ae1567bf4b57b4f86aae424f50
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Wed Feb 5 15:30:30 2014 +0000

    sna: Add some DBG around tiled blts
    
    References: https://bugs.freedesktop.org/show_bug.cgi?id=74550
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c
index 758bf88..e57cb17 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -11955,8 +11955,9 @@ sna_poly_fill_rect_tiled_blt(DrawablePtr drawable,
 	int tile_width, tile_height;
 	int16_t dx, dy;
 
-	DBG(("%s x %d [(%d, %d)x(%d, %d)...]\n",
-	     __FUNCTION__, n, rect->x, rect->y, rect->width, rect->height));
+	DBG(("%s x %d [(%d, %d)x(%d, %d)...], clipped? %d\n",
+	     __FUNCTION__, n, rect->x, rect->y, rect->width, rect->height,
+	     clipped));
 
 	tile_width = tile->drawable.width;
 	tile_height = tile->drawable.height;
@@ -12014,6 +12015,7 @@ sna_poly_fill_rect_tiled_blt(DrawablePtr drawable,
 	}
 
 	get_drawable_deltas(drawable, pixmap, &dx, &dy);
+	DBG(("%s: drawable offset into pixmap = (%d, %d)\n", __FUNCTION__, dx, dy));
 	if (!clipped) {
 		dx += drawable->x;
 		dy += drawable->y;
@@ -12070,6 +12072,8 @@ sna_poly_fill_rect_tiled_blt(DrawablePtr drawable,
 
 		if (clip.data == NULL) {
 			const BoxRec *box = &clip.extents;
+			DBG(("%s: single clip box [(%d, %d), (%d, %d)]",
+			     __FUNCTION__, box->x1, box->y1, box->x2, box->y2));
 			while (n--) {
 				BoxRec r;
 
@@ -12079,6 +12083,13 @@ sna_poly_fill_rect_tiled_blt(DrawablePtr drawable,
 				r.y2 = bound(r.y1, rect->height);
 				rect++;
 
+				DBG(("%s: rectangle [(%d, %d), (%d, %d)]\n",
+				     __FUNCTION__, r.x1, r.y1, r.x2, r.y2));
+				assert(r.x1 + dx >= 0);
+				assert(r.y1 + dy >= 0);
+				assert(r.x2 + dx <= pixmap->drawable.width);
+				assert(r.y2 + dy <= pixmap->drawable.height);
+
 				if (box_intersect(&r, box)) {
 					int height = r.y2 - r.y1;
 					int dst_y = r.y1;
@@ -12140,11 +12151,23 @@ sna_poly_fill_rect_tiled_blt(DrawablePtr drawable,
 				region.extents.y2 = bound(region.extents.y1, rect->height);
 				rect++;
 
+				DBG(("%s: rectangle [(%d, %d), (%d, %d)]\n",
+				     __FUNCTION__,
+				     region.extents.x1,
+				     region.extents.y1,
+				     region.extents.x2,
+				     region.extents.y2));
+				assert(region.extents.x1 + dx >= 0);
+				assert(region.extents.y1 + dy >= 0);
+				assert(region.extents.x2 + dx <= pixmap->drawable.width);
+				assert(region.extents.y2 + dy <= pixmap->drawable.height);
+
 				region.data = NULL;
 				RegionIntersect(&region, &region, &clip);
 
 				nbox = RegionNumRects(&region);
 				box = RegionRects(&region);
+				DBG(("%s: split into %d boxes after clipping\n", __FUNCTION__, nbox));
 				while (nbox--) {
 					int height = box->y2 - box->y1;
 					int dst_y = box->y1;

commit 02eceefa2909075aca0ba3df7fdba835079aeb78
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Wed Feb 5 11:41:42 2014 +0000

    sna: Pass read hints from move-to-cpu to wait_for_shadow
    
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c
index d31fa22..758bf88 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -1975,7 +1975,7 @@ _sna_pixmap_move_to_cpu(PixmapPtr pixmap, unsigned int flags)
 		goto done;
 	}
 
-	if (priv->move_to_gpu && !priv->move_to_gpu(sna, priv, MOVE_READ)) {
+	if (priv->move_to_gpu && !priv->move_to_gpu(sna, priv, priv->gpu_damage ? flags & MOVE_READ: 0)) {
 		DBG(("%s: move-to-gpu override failed\n", __FUNCTION__));
 		return false;
 	}

commit de73c5fd1cd4f948b8bd3582ae788f6f855c5b16
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Tue Feb 4 20:57:24 2014 +0000

    sna: Tweak assert_bo_retired() to be callable on cached bo
    
    References: https://bugs.freedesktop.org/show_bug.cgi?id=73406
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

diff --git a/src/sna/kgem.c b/src/sna/kgem.c
index 788b710..cb64cac 100644
--- a/src/sna/kgem.c
+++ b/src/sna/kgem.c
@@ -506,12 +506,13 @@ static void kgem_bo_retire(struct kgem *kgem, struct kgem_bo *bo)
 	if (bo->rq) {
 		__kgem_bo_clear_busy(bo);
 		kgem_retire(kgem);
+		assert_bo_retired(bo);
 	} else {
+		assert(bo->exec == NULL);
+		assert(list_is_empty(&bo->request));
 		assert(!bo->needs_flush);
 		ASSERT_IDLE(kgem, bo->handle);
 	}
-
-	assert_bo_retired(bo);
 }
 
 static void kgem_bo_maybe_retire(struct kgem *kgem, struct kgem_bo *bo)

commit 0906769c1b92520351729c4d8f2ab684d3ddf2eb
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Tue Feb 4 17:51:51 2014 +0000

    sna: Rearrange assertion to ease use of substitute cached bo
    
    Since we call kgem_bo_submit() along one path when synchronising a
    cached bo (which is known to be inactive) but still want to keep the
    assertion on the refcnt, simply rearrange the code to only assert on the
    active path.
    
    References: https://bugs.freedesktop.org/show_bug.cgi?id=73406
    Reported-by: Matti Hamalainen <ccr@tnsp.org>
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

diff --git a/src/sna/kgem.h b/src/sna/kgem.h
index 4c4996f..fdabd50 100644
--- a/src/sna/kgem.h
+++ b/src/sna/kgem.h
@@ -343,9 +343,11 @@ static inline void kgem_submit(struct kgem *kgem)
 
 static inline void kgem_bo_submit(struct kgem *kgem, struct kgem_bo *bo)
 {
+	if (bo->exec == NULL)
+		return;
+
 	assert(bo->refcnt);
-	if (bo->exec)
-		_kgem_submit(kgem);
+	_kgem_submit(kgem);
 }
 
 void kgem_scanout_flush(struct kgem *kgem, struct kgem_bo *bo);

commit fc001615ff78df4dab6ee0d5dd966b723326c358
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Tue Feb 4 10:36:21 2014 +0000

    sna/gen4: Disable use of pipecontrol invalidates again
    
    One day, just not today, we may make gen4 work correctly, efficiently and
    fast. Today, we can barely pick one.
    
    References: https://bugs.freedesktop.org/show_bug.cgi?id=55500
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

diff --git a/src/sna/gen4_render.c b/src/sna/gen4_render.c
index 1580707..ba9c9bc 100644
--- a/src/sna/gen4_render.c
+++ b/src/sna/gen4_render.c
@@ -602,6 +602,7 @@ gen4_emit_pipe_break(struct sna *sna)
 inline static void
 gen4_emit_pipe_invalidate(struct sna *sna)
 {
+#if 0
 	OUT_BATCH(GEN4_PIPE_CONTROL |
 		  GEN4_PIPE_CONTROL_WC_FLUSH |
 		  (sna->kgem.gen >= 045 ? GEN4_PIPE_CONTROL_TC_FLUSH : 0) |
@@ -609,6 +610,9 @@ gen4_emit_pipe_invalidate(struct sna *sna)
 	OUT_BATCH(0);
 	OUT_BATCH(0);
 	OUT_BATCH(0);
+#else
+	OUT_BATCH(MI_FLUSH);
+#endif
 }
 
 static void gen4_emit_primitive(struct sna *sna)

commit c6a21f0355447d398a8b857ad046cd27141d4744
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Tue Feb 4 08:51:17 2014 +0000

    sna/glyphs: Reset composite state between switching glyph formats
    
    One path uses the mask channel, the other does not. We cannot rely on
    overwriting all reused state in this case, and so we must clear the
    composite state prior to use each time.
    
    Reported-by: Arkadiusz Miskiewicz <arekm@maven.pl>
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=74494
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
    Tested-by: Arkadiusz Miskiewicz <arekm@maven.pl>

diff --git a/src/sna/sna_glyphs.c b/src/sna/sna_glyphs.c
index d06d52a..c72c5e5 100644
--- a/src/sna/sna_glyphs.c
+++ b/src/sna/sna_glyphs.c
@@ -1306,7 +1306,6 @@ next_image:
 		if (!clear_pixmap(sna, pixmap))
 			goto err_mask;
 
-		memset(&tmp, 0, sizeof(tmp));
 		glyph_atlas = NULL;
 		do {
 			int n = list->len;
@@ -1346,6 +1345,8 @@ next_image:
 					     __FUNCTION__,
 					     (int)p->atlas->format,
 					     (int)(format->depth << 24 | format->format)));
+
+					memset(&tmp, 0, sizeof(tmp));
 					if (p->atlas->format == (format->depth << 24 | format->format)) {
 						ok = sna->render.composite(sna, PictOpAdd,
 									   p->atlas, NULL, mask,

commit 1cbc59a917e7352fc68aa0e26b1575cbd0ceab0d
Author: Edward Sheldrake <ejsheldrake@gmail.com>
Date:   Mon Feb 3 09:34:33 2014 +0000

    sna/gen4,5: Fix setting pipe control cache flush bits
    
    Cache flush bits are on dword 0, not 1, on gen4 and gen5. Also texture
    cache invalidate is only available from Cantiga onwards.

diff --git a/src/sna/gen4_render.c b/src/sna/gen4_render.c
index 1d164b6..1580707 100644
--- a/src/sna/gen4_render.c
+++ b/src/sna/gen4_render.c
@@ -575,8 +575,10 @@ inline static void
 gen4_emit_pipe_flush(struct sna *sna)
 {
 #if 1
-	OUT_BATCH(GEN4_PIPE_CONTROL | (4 - 2));
-	OUT_BATCH(GEN4_PIPE_CONTROL_WC_FLUSH);
+	OUT_BATCH(GEN4_PIPE_CONTROL |
+		  GEN4_PIPE_CONTROL_WC_FLUSH |
+		  (4 - 2));
+	OUT_BATCH(0);
 	OUT_BATCH(0);
 	OUT_BATCH(0);
 #else
@@ -600,14 +602,13 @@ gen4_emit_pipe_break(struct sna *sna)
 inline static void
 gen4_emit_pipe_invalidate(struct sna *sna)
 {
-#if 0
-	OUT_BATCH(GEN4_PIPE_CONTROL | (4 - 2));
-	OUT_BATCH(GEN4_PIPE_CONTROL_WC_FLUSH | GEN4_PIPE_CONTROL_TC_FLUSH);
+	OUT_BATCH(GEN4_PIPE_CONTROL |
+		  GEN4_PIPE_CONTROL_WC_FLUSH |
+		  (sna->kgem.gen >= 045 ? GEN4_PIPE_CONTROL_TC_FLUSH : 0) |
+		  (4 - 2));
+	OUT_BATCH(0);
 	OUT_BATCH(0);
 	OUT_BATCH(0);
-#else
-	OUT_BATCH(MI_FLUSH);
-#endif
 }
 
 static void gen4_emit_primitive(struct sna *sna)
diff --git a/src/sna/gen4_render.h b/src/sna/gen4_render.h
index 53c7fc2..64d11e6 100644
--- a/src/sna/gen4_render.h
+++ b/src/sna/gen4_render.h
@@ -112,7 +112,7 @@
 #define GEN4_PIPE_CONTROL_DEPTH_STALL   (1 << 13)
 #define GEN4_PIPE_CONTROL_WC_FLUSH      (1 << 12)
 #define GEN4_PIPE_CONTROL_IS_FLUSH      (1 << 11)
-#define GEN4_PIPE_CONTROL_TC_FLUSH      (1 << 10)
+#define GEN4_PIPE_CONTROL_TC_FLUSH      (1 << 10) /* ctg+ */
 #define GEN4_PIPE_CONTROL_NOTIFY_ENABLE (1 << 8)
 #define GEN4_PIPE_CONTROL_GLOBAL_GTT    (1 << 2)
 #define GEN4_PIPE_CONTROL_LOCAL_PGTT    (0 << 2)
diff --git a/src/sna/gen5_render.c b/src/sna/gen5_render.c
index 8fb47cb..25555e0 100644
--- a/src/sna/gen5_render.c
+++ b/src/sna/gen5_render.c
@@ -1016,8 +1016,10 @@ inline static void
 gen5_emit_pipe_flush(struct sna *sna)
 {
 #if 0
-	OUT_BATCH(GEN5_PIPE_CONTROL | (4 - 2));
-	OUT_BATCH(GEN5_PIPE_CONTROL_WC_FLUSH);
+	OUT_BATCH(GEN5_PIPE_CONTROL |
+		  GEN5_PIPE_CONTROL_WC_FLUSH |
+		  (4 - 2));
+	OUT_BATCH(0);
 	OUT_BATCH(0);
 	OUT_BATCH(0);
 #else

commit 7f08250a8960f90f6bd34de8c4a17870703bfa60
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Sun Feb 2 03:52:11 2014 +0000

    sna: Reconstruct damage for the partially replaced discarded CPU bo
    
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c
index acf4849..d31fa22 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -2432,7 +2432,7 @@ sna_drawable_move_region_to_cpu(DrawablePtr drawable,
 				if (get_drawable_deltas(drawable, pixmap, &dx, &dy))
 					RegionTranslate(region, dx, dy);
 
-				if (sna->kgem.has_llc &&
+				if (sna->kgem.has_llc && !priv->pinned &&
 				    sna_pixmap_choose_tiling(pixmap,
 							     DEFAULT_TILING) == I915_TILING_NONE) {
 #ifdef DEBUG_MEMORY
@@ -2440,13 +2440,17 @@ sna_drawable_move_region_to_cpu(DrawablePtr drawable,
 					sna->debug_memory.cpu_bo_bytes -= kgem_bo_size(priv->cpu_bo);
 #endif
 					DBG(("%s: promoting CPU bo to GPU bo\n", __FUNCTION__));
-					sna_pixmap_free_gpu(sna, priv);
+					if (priv->gpu_bo)
+						sna_pixmap_free_gpu(sna, priv);
 					priv->gpu_bo = priv->cpu_bo;
 					priv->cpu_bo = NULL;
 					priv->ptr = NULL;
 					pixmap->devPrivate.ptr = NULL;
 
-					sna_damage_destroy(&priv->cpu_damage);
+					priv->gpu_damage = priv->cpu_damage;
+					priv->cpu_damage = NULL;
+
+					discard_gpu = false;
 				} else {
 					DBG(("%s: pushing surrounding damage to GPU bo\n", __FUNCTION__));
 					sna_damage_subtract(&priv->cpu_damage, region);
@@ -2456,6 +2460,12 @@ sna_drawable_move_region_to_cpu(DrawablePtr drawable,
 						if (priv->flush)
 							sna_add_flush_pixmap(sna, priv, priv->gpu_bo);
 						discard_gpu = false;
+
+						assert(priv->cpu_damage == NULL);
+						sna_damage_all(&priv->gpu_damage,
+							       pixmap->drawable.width,
+							       pixmap->drawable.height);
+						sna_damage_subtract(&priv->gpu_damage, region);
 					}
 				}
 				sna_damage_add(&priv->cpu_damage, region);
@@ -3959,9 +3969,9 @@ sna_pixmap_move_to_gpu(PixmapPtr pixmap, unsigned flags)
 	if (priv->cpu_damage == NULL)
 		goto done;
 
-	if (DAMAGE_IS_ALL(priv->cpu_damage) &&
+	if (DAMAGE_IS_ALL(priv->cpu_damage) && priv->cpu_bo &&
+	    !priv->pinned && !priv->shm &&
 	    priv->gpu_bo->tiling == I915_TILING_NONE &&
-	    priv->cpu_bo && !priv->shm &&
 	    kgem_bo_convert_to_gpu(&sna->kgem, priv->cpu_bo, flags)) {
 		assert(!priv->mapped);
 		assert(!IS_STATIC_PTR(priv->ptr));

commit 853588ad5be9407d2123f6055458ca84e72b8eb9
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Sat Feb 1 21:55:09 2014 +0000

    sna: If IGNORE_CPU is not set we must mark the move as MOVE_READ
    
    Logic reversal in discarding CPU damage. An old bug revealed by the more
    aggressive attempts to discard CPU damage.
    
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c
index 4221a55..acf4849 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -3689,7 +3689,7 @@ cpu_fail:
 		goto cpu_fail;
 
 	if (!sna_drawable_move_region_to_cpu(&pixmap->drawable, &region,
-					     (flags & IGNORE_CPU ? MOVE_READ : 0) | MOVE_WRITE | MOVE_ASYNC_HINT)) {
+					     (flags & IGNORE_CPU ? 0 : MOVE_READ) | MOVE_WRITE | MOVE_ASYNC_HINT)) {
 		DBG(("%s: failed to move-to-cpu, fallback\n", __FUNCTION__));
 		goto cpu_fail;
 	}

commit 8b0748c57ee4c38ea98c4b6ca18cb2b99f8f9ed4
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Sat Feb 1 21:54:43 2014 +0000

    sna: Add some more DBG for choosing render targets
    
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

diff --git a/src/sna/gen6_render.c b/src/sna/gen6_render.c
index 08c9f78..aadc6f7 100644
--- a/src/sna/gen6_render.c
+++ b/src/sna/gen6_render.c
@@ -1831,6 +1831,8 @@ gen6_composite_set_target(struct sna *sna,
 	BoxRec box;
 	unsigned int hint;
 
+	DBG(("%s: (%d, %d)x(%d, %d), partial?=%d\n", __FUNCTION__, x, y, w, h));
+
 	op->dst.pixmap = get_drawable_pixmap(dst->pDrawable);
 	op->dst.format = dst->format;
 	op->dst.width = op->dst.pixmap->drawable.width;
diff --git a/src/sna/gen7_render.c b/src/sna/gen7_render.c
index 1574813..a90bd15 100644
--- a/src/sna/gen7_render.c
+++ b/src/sna/gen7_render.c
@@ -2111,6 +2111,8 @@ gen7_composite_set_target(struct sna *sna,
 	BoxRec box;
 	unsigned int hint;
 
+	DBG(("%s: (%d, %d)x(%d, %d), partial?=%d\n", __FUNCTION__, x, y, w, h));
+
 	op->dst.pixmap = get_drawable_pixmap(dst->pDrawable);
 	op->dst.format = dst->format;
 	op->dst.width  = op->dst.pixmap->drawable.width;
diff --git a/src/sna/gen8_render.c b/src/sna/gen8_render.c
index 5c718bc..c096db1 100644
--- a/src/sna/gen8_render.c
+++ b/src/sna/gen8_render.c
@@ -1862,6 +1862,8 @@ gen8_composite_set_target(struct sna *sna,
 	BoxRec box;
 	unsigned int hint;
 
+	DBG(("%s: (%d, %d)x(%d, %d), partial?=%d\n", __FUNCTION__, x, y, w, h));
+
 	op->dst.pixmap = get_drawable_pixmap(dst->pDrawable);
 	op->dst.format = dst->format;
 	op->dst.width  = op->dst.pixmap->drawable.width;

commit ed8d4f0ce3bff662d02063528df64d478ac0dc00
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Sat Feb 1 21:38:47 2014 +0000

    sna: Skip discarding CPU bo when using as a render target
    
    The issue with unwanted serialisation does not affect the async
    move-to-cpu of a render target.
    
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c
index 9d7dec4..4221a55 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -2420,19 +2420,45 @@ sna_drawable_move_region_to_cpu(DrawablePtr drawable,
 
 		sna_damage_destroy(&priv->gpu_damage);
 
-		if ((flags & MOVE_READ) == 0 &&
+		if ((flags & (MOVE_READ | MOVE_ASYNC_HINT)) == 0 &&
 		    priv->cpu_bo && !priv->cpu_bo->flush &&
 		    __kgem_bo_is_busy(&sna->kgem, priv->cpu_bo)) {
+			DBG(("%s: active CPU bo replacing\n", __FUNCTION__));
+			assert(!priv->shm);
+			assert(!IS_STATIC_PTR(priv->ptr));
+
 			if (!region_subsumes_pixmap(region, pixmap)) {
+				DBG(("%s: partial replacement\n", __FUNCTION__));
 				if (get_drawable_deltas(drawable, pixmap, &dx, &dy))
 					RegionTranslate(region, dx, dy);
 
-				sna_damage_subtract(&priv->cpu_damage, region);
-				if (sna_pixmap_move_to_gpu(pixmap, MOVE_READ | MOVE_ASYNC_HINT)) {
-					sna_pixmap_free_cpu(sna, priv, false);
-					sna_damage_add(&priv->cpu_damage, region);
-					discard_gpu = false;
+				if (sna->kgem.has_llc &&
+				    sna_pixmap_choose_tiling(pixmap,
+							     DEFAULT_TILING) == I915_TILING_NONE) {
+#ifdef DEBUG_MEMORY
+					sna->debug_memory.cpu_bo_allocs--;
+					sna->debug_memory.cpu_bo_bytes -= kgem_bo_size(priv->cpu_bo);
+#endif
+					DBG(("%s: promoting CPU bo to GPU bo\n", __FUNCTION__));
+					sna_pixmap_free_gpu(sna, priv);
+					priv->gpu_bo = priv->cpu_bo;
+					priv->cpu_bo = NULL;
+					priv->ptr = NULL;
+					pixmap->devPrivate.ptr = NULL;
+
+					sna_damage_destroy(&priv->cpu_damage);
+				} else {
+					DBG(("%s: pushing surrounding damage to GPU bo\n", __FUNCTION__));
+					sna_damage_subtract(&priv->cpu_damage, region);
+					assert(priv->cpu_damage);
+					if (sna_pixmap_move_to_gpu(pixmap, MOVE_READ | MOVE_ASYNC_HINT)) {
+						sna_pixmap_free_cpu(sna, priv, false);
+						if (priv->flush)
+							sna_add_flush_pixmap(sna, priv, priv->gpu_bo);
+						discard_gpu = false;
+					}
 				}
+				sna_damage_add(&priv->cpu_damage, region);
 


Reply to: