xf86-video-intel: 10 commits - src/sna/gen4_render.c src/sna/gen5_render.c src/sna/gen6_render.c src/sna/gen7_render.c src/sna/kgem.c src/sna/kgem.h src/sna/sna_accel.c src/sna/sna_dri.c src/sna/sna_glyphs.c src/sna/sna_render.c src/sna/sna_video.c

Chris Wilson ickle at kemper.freedesktop.org
Thu Nov 28 16:56:38 PST 2013


 src/sna/gen4_render.c |   11 --
 src/sna/gen5_render.c |   11 --
 src/sna/gen6_render.c |   10 -
 src/sna/gen7_render.c |   16 ---
 src/sna/kgem.c        |   20 ++-
 src/sna/kgem.h        |   10 +
 src/sna/sna_accel.c   |  263 ++++++++++++++++++++++++++++----------------------
 src/sna/sna_dri.c     |    2 
 src/sna/sna_glyphs.c  |   13 ++
 src/sna/sna_render.c  |   66 ++++++------
 src/sna/sna_video.c   |   24 +++-
 11 files changed, 247 insertions(+), 199 deletions(-)

New commits:
commit 2497fc332eafe31a0156ac5f66ec98f77ce0f647
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Nov 28 22:03:39 2013 +0000

    sna: Fix typo inside DBG message
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/sna_dri.c b/src/sna/sna_dri.c
index 99f95ae..759b602 100644
--- a/src/sna/sna_dri.c
+++ b/src/sna/sna_dri.c
@@ -1215,7 +1215,7 @@ can_flip(struct sna * sna,
 
 	if (sna_pixmap(pixmap)->pinned & ~(PIN_DRI2 | PIN_SCANOUT)) {
 		DBG(("%s -- no, pinned: front %x\n",
-		     __FUNCTION__, get_private(front)->pinned));
+		     __FUNCTION__, sna_pixmap(pixmap)->pinned));
 		return false;
 	}
 
commit fd007d9d465b9b3ddbbaf769931ec921a6f5ecb8
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Nov 28 21:13:33 2013 +0000

    sna/video: Correct handling of cropped images along packed fast path
    
    In particular, it was offseting the read from the source image, but not
    correcting the length to read - causing a read from beyond the end of
    the source and a segfault.
    
    Reported-by: Jan Engelhardt <jengelh at inai.de>
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/sna_video.c b/src/sna/sna_video.c
index 7f1eeb2..e4d3315 100644
--- a/src/sna/sna_video.c
+++ b/src/sna/sna_video.c
@@ -520,11 +520,25 @@ sna_video_copy_data(struct sna_video *video,
 				return true;
 			}
 		} else {
-			if (frame->width*2 == frame->pitch[0]) {
+			int x, y, w, h;
+
+			if (video->textured) {
+				/* XXX support copying cropped extents */
+				x = y = 0;
+				w = frame->width;
+				h = frame->height;
+			} else {
+				x = frame->image.x1;
+				y = frame->image.y1;
+				w = frame->image.x2 - frame->image.x1;
+				h = frame->image.y2 - frame->image.y1;
+			}
+
+			if (w*2 == frame->pitch[0]) {
+				buf += (2U*y * frame->width) + (x << 1);
 				if (frame->bo) {
 					kgem_bo_write(&video->sna->kgem, frame->bo,
-						      buf + (2U*frame->image.y1 * frame->width) + (frame->image.x1 << 1),
-						      2U*(frame->image.y2-frame->image.y1)*frame->width);
+						      buf, 2U*h*frame->width);
 				} else {
 					frame->bo = kgem_create_buffer(&video->sna->kgem, frame->size,
 								       KGEM_BUFFER_WRITE | KGEM_BUFFER_WRITE_INPLACE,
@@ -532,9 +546,7 @@ sna_video_copy_data(struct sna_video *video,
 					if (frame->bo == NULL)
 						return false;
 
-					memcpy(dst,
-					       buf + (frame->image.y1 * frame->width*2) + (frame->image.x1 << 1),
-					       2U*(frame->image.y2-frame->image.y1)*frame->width);
+					memcpy(dst, buf, 2U*h*frame->width);
 				}
 				return true;
 			}
commit b85051ae480499dd8a6a6d07d5ce0feca7b844b4
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Nov 28 16:25:52 2013 +0000

    sna: Fallback from partial to full move-to-cpu
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c
index 328e144..e1487ee 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -1836,7 +1836,7 @@ static inline bool operate_inplace(struct sna_pixmap *priv, unsigned flags)
 		return false;
 	}
 
-	assert((flags & MOVE_ASYNC_HINT) == 0);
+	assert((flags & MOVE_ASYNC_HINT) == 0 || (priv->create & KGEM_CAN_CREATE_LARGE));
 
 	if (priv->move_to_gpu && flags & MOVE_WRITE) {
 		DBG(("%s: no, has pending move-to-gpu\n", __FUNCTION__));
@@ -2561,7 +2561,8 @@ contains_damage:
 				  flags & MOVE_READ ? priv->gpu_damage && !priv->clear : 0)) {
 		if (dx | dy)
 			RegionTranslate(region, -dx, -dy);
-		return false;
+		DBG(("%s: CPU bo allocation failed, trying full move-to-cpu\n", __FUNCTION__));
+		return _sna_pixmap_move_to_cpu(pixmap, flags | MOVE_READ);
 	}
 	assert(pixmap->devPrivate.ptr);
 
commit faedf266d7b476954574db2cb1274e677cf42bf4
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Nov 28 14:12:56 2013 +0000

    sna: Tidy up an assertion on an uninitialised variable
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/gen4_render.c b/src/sna/gen4_render.c
index 2da0137..a87af39 100644
--- a/src/sna/gen4_render.c
+++ b/src/sna/gen4_render.c
@@ -2424,12 +2424,8 @@ fallback_blt:
 		kgem_submit(&sna->kgem);
 		if (!kgem_check_bo(&sna->kgem, dst_bo, src_bo, NULL)) {
 			kgem_bo_destroy(&sna->kgem, tmp.src.bo);
-			tmp.src.bo = NULL;
-
-			if (tmp.redirect.real_bo) {
+			if (tmp.redirect.real_bo)
 				kgem_bo_destroy(&sna->kgem, tmp.dst.bo);
-				tmp.redirect.real_bo = NULL;
-			}
 
 			goto fallback_blt;
 		}
@@ -2459,12 +2455,9 @@ fallback_blt:
 	return true;
 
 fallback_tiled_dst:
-	if (tmp.redirect.real_bo) {
+	if (tmp.redirect.real_bo)
 		kgem_bo_destroy(&sna->kgem, tmp.dst.bo);
-		tmp.redirect.real_bo = NULL;
-	}
 fallback_tiled:
-	assert(tmp.src.bo == NULL);
 	if (sna_blt_compare_depth(&src->drawable, &dst->drawable) &&
 	    sna_blt_copy_boxes(sna, alu,
 			       src_bo, src_dx, src_dy,
diff --git a/src/sna/gen5_render.c b/src/sna/gen5_render.c
index 247dc97..9266f90 100644
--- a/src/sna/gen5_render.c
+++ b/src/sna/gen5_render.c
@@ -2384,12 +2384,8 @@ fallback_blt:
 		if (!kgem_check_bo(&sna->kgem, dst_bo, src_bo, NULL)) {
 			DBG(("%s: aperture check failed\n", __FUNCTION__));
 			kgem_bo_destroy(&sna->kgem, tmp.src.bo);
-			tmp.src.bo = NULL;
-
-			if (tmp.redirect.real_bo) {
+			if (tmp.redirect.real_bo)
 				kgem_bo_destroy(&sna->kgem, tmp.dst.bo);
-				tmp.redirect.real_bo = NULL;
-			}
 
 			goto fallback_blt;
 		}
@@ -2439,12 +2435,9 @@ fallback_blt:
 	return true;
 
 fallback_tiled_dst:
-	if (tmp.redirect.real_bo) {
+	if (tmp.redirect.real_bo)
 		kgem_bo_destroy(&sna->kgem, tmp.dst.bo);
-		tmp.redirect.real_bo = NULL;
-	}
 fallback_tiled:
-	assert(tmp.src.bo == NULL);
 	if (sna_blt_compare_depth(&src->drawable, &dst->drawable) &&
 	    sna_blt_copy_boxes(sna, alu,
 			       src_bo, src_dx, src_dy,
diff --git a/src/sna/gen6_render.c b/src/sna/gen6_render.c
index 103b959..a82284d 100644
--- a/src/sna/gen6_render.c
+++ b/src/sna/gen6_render.c
@@ -2792,11 +2792,8 @@ fallback_blt:
 			     __FUNCTION__));
 			if (tmp.src.bo != src_bo)
 				kgem_bo_destroy(&sna->kgem, tmp.src.bo);
-			tmp.src.bo = NULL;
-			if (tmp.redirect.real_bo) {
+			if (tmp.redirect.real_bo)
 				kgem_bo_destroy(&sna->kgem, tmp.dst.bo);
-				tmp.redirect.real_bo = NULL;
-			}
 			goto fallback_blt;
 		}
 		_kgem_set_mode(&sna->kgem, KGEM_RENDER);
@@ -2841,12 +2838,9 @@ fallback_blt:
 	return true;
 
 fallback_tiled_dst:
-	if (tmp.redirect.real_bo) {
+	if (tmp.redirect.real_bo)
 		kgem_bo_destroy(&sna->kgem, tmp.dst.bo);
-		tmp.redirect.real_bo = NULL;
-	}
 fallback_tiled:
-	assert(tmp.src.bo == NULL);
 	if (sna_blt_compare_depth(&src->drawable, &dst->drawable) &&
 	    sna_blt_copy_boxes(sna, alu,
 			       src_bo, src_dx, src_dy,
diff --git a/src/sna/gen7_render.c b/src/sna/gen7_render.c
index 65c7134..572e3e3 100644
--- a/src/sna/gen7_render.c
+++ b/src/sna/gen7_render.c
@@ -3050,11 +3050,8 @@ fallback_blt:
 		if (!kgem_check_bo(&sna->kgem, tmp.dst.bo, tmp.src.bo, NULL)) {
 			if (tmp.src.bo != src_bo)
 				kgem_bo_destroy(&sna->kgem, tmp.src.bo);
-			tmp.src.bo = NULL;
-			if (tmp.redirect.real_bo) {
+			if (tmp.redirect.real_bo)
 				kgem_bo_destroy(&sna->kgem, tmp.dst.bo);
-				tmp.redirect.real_bo = NULL;
-			}
 			goto fallback_blt;
 		}
 		_kgem_set_mode(&sna->kgem, KGEM_RENDER);
@@ -3099,13 +3096,10 @@ fallback_blt:
 	return true;
 
 fallback_tiled_dst:
-	if (tmp.redirect.real_bo) {
+	if (tmp.redirect.real_bo)
 		kgem_bo_destroy(&sna->kgem, tmp.dst.bo);
-		tmp.redirect.real_bo = NULL;
-	}
 fallback_tiled:
 	DBG(("%s: fallback tiled\n", __FUNCTION__));
-	assert(tmp.src.bo == NULL);
 	if (sna_blt_compare_depth(&src->drawable, &dst->drawable) &&
 	    sna_blt_copy_boxes(sna, alu,
 			       src_bo, src_dx, src_dy,
@@ -3367,12 +3361,8 @@ gen7_render_fill_boxes(struct sna *sna,
 		kgem_submit(&sna->kgem);
 		if (!kgem_check_bo(&sna->kgem, dst_bo, NULL)) {
 			kgem_bo_destroy(&sna->kgem, tmp.src.bo);
-			tmp.src.bo = NULL;
-
-			if (tmp.redirect.real_bo) {
+			if (tmp.redirect.real_bo)
 				kgem_bo_destroy(&sna->kgem, tmp.dst.bo);
-				tmp.redirect.real_bo = NULL;
-			}
 
 			return false;
 		}
commit 1e382c6ece84f3040b21980a303fe00be667c4e2
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Nov 28 14:02:18 2013 +0000

    sna: Harden GetImage for use with very large buffers
    
    That risk causing SIGBUS due to oom.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c
index 9b54c5e..328e144 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -15712,104 +15712,11 @@ static int sna_create_gc(GCPtr gc)
 }
 
 static bool
-sna_get_image__blt(PixmapPtr pixmap,
-		   RegionPtr region,
-		   char *dst,
-		   unsigned flags)
-{
-	struct sna_pixmap *priv = sna_pixmap(pixmap);
-	struct sna *sna = to_sna_from_pixmap(pixmap);
-	struct kgem_bo *dst_bo;
-	bool ok = false;
-	int pitch;
-
-	if (priv == NULL)
-		return false;
-
-	if (priv->clear) {
-		int w = region->extents.x2 - region->extents.x1;
-		int h = region->extents.y2 - region->extents.y1;
-
-		DBG(("%s: applying clear [%08x]\n",
-		     __FUNCTION__, priv->clear_color));
-		assert(DAMAGE_IS_ALL(priv->gpu_damage));
-		assert(priv->cpu_damage == NULL);
-
-		pitch = PixmapBytePad(w, pixmap->drawable.depth);
-		if (priv->clear_color == 0 ||
-		    pixmap->drawable.bitsPerPixel == 8 ||
-		    priv->clear_color == (1U << pixmap->drawable.depth) - 1) {
-			DBG(("%s: memset clear [%02x]\n",
-			     __FUNCTION__, priv->clear_color & 0xff));
-			memset(dst, priv->clear_color, pitch * h);
-		} else {
-			pixman_fill((uint32_t *)dst,
-				    pitch/sizeof(uint32_t),
-				    pixmap->drawable.bitsPerPixel,
-				    0, 0,
-				    w, h,
-				    priv->clear_color);
-		}
-
-		return true;
-	}
-
-	if (!sna->kgem.has_userptr || !USE_USERPTR_DOWNLOADS)
-		return false;
-
-	if (!sna->kgem.can_blt_cpu)
-		return false;
-
-	if (flags & (MOVE_WHOLE_HINT | MOVE_INPLACE_HINT))
-		return false;
-
-	if (priv->gpu_damage == NULL)
-		return false;
-
-	assert(priv->gpu_bo);
-	if (!__kgem_bo_is_busy(&sna->kgem, priv->gpu_bo))
-		return false;
-
-	if (!DAMAGE_IS_ALL(priv->gpu_damage) &&
-	    !sna_damage_contains_box__no_reduce(priv->gpu_damage,
-						&region->extents))
-		return false;
-
-	DBG(("%s: download through a temporary map\n", __FUNCTION__));
-
-	assert(sna_damage_contains_box(priv->gpu_damage, &region->extents) == PIXMAN_REGION_IN);
-	assert(sna_damage_contains_box(priv->cpu_damage, &region->extents) == PIXMAN_REGION_OUT);
-
-	pitch = PixmapBytePad(region->extents.x2 - region->extents.x1,
-			      pixmap->drawable.depth);
-	dst_bo = kgem_create_map(&sna->kgem, dst,
-				 pitch * (region->extents.y2 - region->extents.y1),
-				 false);
-	if (dst_bo) {
-		dst_bo->pitch = pitch;
-		kgem_bo_mark_unreusable(dst_bo);
-
-		ok = sna->render.copy_boxes(sna, GXcopy,
-					    pixmap, priv->gpu_bo, 0, 0,
-					    pixmap, dst_bo,
-					    -region->extents.x1,
-					    -region->extents.y1,
-					    &region->extents, 1,
-					    COPY_LAST);
-
-		kgem_bo_sync__cpu(&sna->kgem, dst_bo);
-		assert(dst_bo->rq == NULL);
-		kgem_bo_destroy(&sna->kgem, dst_bo);
-	}
-
-	return ok;
-}
-
-static bool
 sna_get_image__inplace(PixmapPtr pixmap,
 		       RegionPtr region,
 		       char *dst,
-		       unsigned flags)
+		       unsigned flags,
+		       bool idle)
 {
 	struct sna_pixmap *priv = sna_pixmap(pixmap);
 	struct sna *sna = to_sna_from_pixmap(pixmap);
@@ -15818,8 +15725,7 @@ sna_get_image__inplace(PixmapPtr pixmap,
 	if (!USE_INPLACE)
 		return false;
 
-	if (priv == NULL || priv->gpu_bo == NULL)
-		return false;
+	assert(priv && priv->gpu_bo);
 
 	switch (priv->gpu_bo->tiling) {
 	case I915_TILING_Y:
@@ -15831,16 +15737,13 @@ sna_get_image__inplace(PixmapPtr pixmap,
 		break;
 	}
 
-	if (priv->move_to_gpu && !priv->move_to_gpu(sna, priv, MOVE_READ))
+	if (!kgem_bo_can_map__cpu(&sna->kgem, priv->gpu_bo, FORCE_FULL_SYNC))
 		return false;
 
-	if (!kgem_bo_can_map__cpu(&sna->kgem, priv->gpu_bo, FORCE_FULL_SYNC))
+	if (idle && __kgem_bo_is_busy(&sna->kgem, priv->gpu_bo))
 		return false;
 
-	if (priv->gpu_damage == NULL ||
-	    !(DAMAGE_IS_ALL(priv->gpu_damage) ||
-	      sna_damage_contains_box__no_reduce(priv->gpu_damage,
-						 &region->extents)))
+	if (priv->move_to_gpu && !priv->move_to_gpu(sna, priv, MOVE_READ))
 		return false;
 
 	assert(sna_damage_contains_box(priv->gpu_damage, &region->extents) == PIXMAN_REGION_IN);
@@ -15852,6 +15755,9 @@ sna_get_image__inplace(PixmapPtr pixmap,
 
 	kgem_bo_sync__cpu_full(&sna->kgem, priv->gpu_bo, FORCE_FULL_SYNC);
 
+	if (sigtrap_get())
+		return false;
+
 	if (priv->gpu_bo->tiling) {
 		DBG(("%s: download through a tiled CPU map\n", __FUNCTION__));
 		memcpy_from_tiled_x(&sna->kgem, src, dst,
@@ -15883,9 +15789,137 @@ sna_get_image__inplace(PixmapPtr pixmap,
 		}
 	}
 
+	sigtrap_put();
 	return true;
 }
 
+static bool
+sna_get_image__blt(PixmapPtr pixmap,
+		   RegionPtr region,
+		   char *dst,
+		   unsigned flags)
+{
+	struct sna_pixmap *priv = sna_pixmap(pixmap);
+	struct sna *sna = to_sna_from_pixmap(pixmap);
+	struct kgem_bo *dst_bo;
+	bool ok = false;
+	int pitch;
+
+	assert(priv && priv->gpu_bo);
+
+	if (!sna->kgem.has_userptr || !USE_USERPTR_DOWNLOADS)
+		return false;
+
+	if (!sna->kgem.can_blt_cpu)
+		return false;
+
+	if ((priv->create & (KGEM_CAN_CREATE_GTT | KGEM_CAN_CREATE_LARGE)) == KGEM_CAN_CREATE_GTT &&
+	    kgem_bo_can_map(&sna->kgem, priv->gpu_bo)) {
+		if (flags & (MOVE_WHOLE_HINT | MOVE_INPLACE_HINT))
+			return false;
+
+		if (priv->gpu_damage == NULL)
+			return false;
+
+		assert(priv->gpu_bo);
+		if (!__kgem_bo_is_busy(&sna->kgem, priv->gpu_bo))
+			return false;
+	} else {
+		if (priv->gpu_damage == NULL)
+			return false;
+
+		assert(priv->gpu_bo);
+	}
+
+	if (priv->move_to_gpu && !priv->move_to_gpu(sna, priv, MOVE_READ))
+		return false;
+
+	DBG(("%s: download through a temporary map\n", __FUNCTION__));
+
+	assert(sna_damage_contains_box(priv->gpu_damage, &region->extents) == PIXMAN_REGION_IN);
+	assert(sna_damage_contains_box(priv->cpu_damage, &region->extents) == PIXMAN_REGION_OUT);
+
+	pitch = PixmapBytePad(region->extents.x2 - region->extents.x1,
+			      pixmap->drawable.depth);
+	dst_bo = kgem_create_map(&sna->kgem, dst,
+				 pitch * (region->extents.y2 - region->extents.y1),
+				 false);
+	if (dst_bo) {
+		dst_bo->pitch = pitch;
+		kgem_bo_mark_unreusable(dst_bo);
+
+		ok = sna->render.copy_boxes(sna, GXcopy,
+					    pixmap, priv->gpu_bo, 0, 0,
+					    pixmap, dst_bo,
+					    -region->extents.x1,
+					    -region->extents.y1,
+					    &region->extents, 1,
+					    COPY_LAST);
+
+		kgem_bo_sync__cpu(&sna->kgem, dst_bo);
+		assert(dst_bo->rq == NULL);
+		kgem_bo_destroy(&sna->kgem, dst_bo);
+	}
+
+	return ok;
+}
+
+static bool
+sna_get_image__fast(PixmapPtr pixmap,
+		   RegionPtr region,
+		   char *dst,
+		   unsigned flags)
+{
+	struct sna_pixmap *priv = sna_pixmap(pixmap);
+
+	if (priv == NULL || priv->gpu_damage == NULL)
+		return false;
+
+	if (priv->clear) {
+		int w = region->extents.x2 - region->extents.x1;
+		int h = region->extents.y2 - region->extents.y1;
+		int pitch = PixmapBytePad(w, pixmap->drawable.depth);
+
+		DBG(("%s: applying clear [%08x]\n",
+		     __FUNCTION__, priv->clear_color));
+		assert(DAMAGE_IS_ALL(priv->gpu_damage));
+		assert(priv->cpu_damage == NULL);
+
+		if (priv->clear_color == 0 ||
+		    pixmap->drawable.bitsPerPixel == 8 ||
+		    priv->clear_color == (1U << pixmap->drawable.depth) - 1) {
+			DBG(("%s: memset clear [%02x]\n",
+			     __FUNCTION__, priv->clear_color & 0xff));
+			memset(dst, priv->clear_color, pitch * h);
+		} else {
+			pixman_fill((uint32_t *)dst,
+				    pitch/sizeof(uint32_t),
+				    pixmap->drawable.bitsPerPixel,
+				    0, 0,
+				    w, h,
+				    priv->clear_color);
+		}
+
+		return true;
+	}
+
+	if (!DAMAGE_IS_ALL(priv->gpu_damage) &&
+	    !sna_damage_contains_box__no_reduce(priv->gpu_damage,
+						&region->extents))
+		return false;
+
+	if (sna_get_image__inplace(pixmap, region, dst, flags, true))
+		return true;
+
+	if (sna_get_image__blt(pixmap, region, dst, flags))
+		return true;
+
+	if (sna_get_image__inplace(pixmap, region, dst, flags, false))
+		return true;
+
+	return false;
+}
+
 static void
 sna_get_image(DrawablePtr drawable,
 	      int x, int y, int w, int h,
@@ -15924,10 +15958,7 @@ sna_get_image(DrawablePtr drawable,
 		region.extents.y2 = region.extents.y1 + h;
 		region.data = NULL;
 
-		if (sna_get_image__blt(pixmap, &region, dst, flags))
-			return;
-
-		if (sna_get_image__inplace(pixmap, &region, dst, flags))
+		if (sna_get_image__fast(pixmap, &region, dst, flags))
 			return;
 
 		if (!sna_drawable_move_region_to_cpu(&pixmap->drawable,
@@ -15939,9 +15970,12 @@ sna_get_image(DrawablePtr drawable,
 		     region.extents.x1, region.extents.y1,
 		     region.extents.x2, region.extents.y2));
 		assert(has_coherent_ptr(to_sna_from_pixmap(pixmap), sna_pixmap(pixmap), MOVE_READ));
-		memcpy_blt(pixmap->devPrivate.ptr, dst, drawable->bitsPerPixel,
-			   pixmap->devKind, PixmapBytePad(w, drawable->depth),
-			   region.extents.x1, region.extents.y1, 0, 0, w, h);
+		if (sigtrap_get() == 0) {
+			memcpy_blt(pixmap->devPrivate.ptr, dst, drawable->bitsPerPixel,
+				   pixmap->devKind, PixmapBytePad(w, drawable->depth),
+				   region.extents.x1, region.extents.y1, 0, 0, w, h);
+			sigtrap_put();
+		}
 	} else {
 		region.extents.x1 = x + drawable->x;
 		region.extents.y1 = y + drawable->y;
commit 569b06abeae9b3dcaa611facdd3ec30c67de765b
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Nov 28 13:14:27 2013 +0000

    sna: Wrap glyph composition with sigtrap handling
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/sna_glyphs.c b/src/sna/sna_glyphs.c
index 9b272ef..caa4649 100644
--- a/src/sna/sna_glyphs.c
+++ b/src/sna/sna_glyphs.c
@@ -1140,6 +1140,11 @@ glyphs_via_mask(struct sna *sna,
 		if (mask_image == NULL)
 			goto err_pixmap;
 
+		if (sigtrap_get()) {
+			pixman_image_unref(mask_image);
+			goto err_pixmap;
+		}
+
 		memset(pixmap->devPrivate.ptr, 0, pixmap->devKind*height);
 #if HAS_PIXMAN_GLYPHS
 		if (sna->render.glyph_cache) {
@@ -1276,6 +1281,8 @@ next_image:
 		} while (--nlist);
 		pixman_image_unref(mask_image);
 
+		sigtrap_put();
+
 		mask = CreatePicture(0, &pixmap->drawable,
 				     format, CPComponentAlpha,
 				     &component_alpha, serverClient, &error);
@@ -2038,6 +2045,11 @@ glyphs_via_image(struct sna *sna,
 	if (mask_image == NULL)
 		goto err_pixmap;
 
+	if (sigtrap_get()) {
+		pixman_image_unref(mask_image);
+		goto err_pixmap;
+	}
+
 	memset(pixmap->devPrivate.ptr, 0, pixmap->devKind*height);
 #if HAS_PIXMAN_GLYPHS
 	if (sna->render.glyph_cache) {
@@ -2173,6 +2185,7 @@ next_image:
 			list++;
 		} while (--nlist);
 	pixman_image_unref(mask_image);
+	sigtrap_put();
 
 	component_alpha = NeedsComponent(format->format);
 
commit 974abd0c3acca7d3b782251d562bf00fd34b395d
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Nov 28 13:03:54 2013 +0000

    sna: Prefer using userptr for PutImage into large GPU bo
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c
index 8abdf84..9b54c5e 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -4209,7 +4209,9 @@ try_upload_blt(PixmapPtr pixmap, RegionRec *region,
 	assert(priv->gpu_bo);
 	assert(priv->gpu_bo->proxy == NULL);
 
-	if (!__kgem_bo_is_busy(&sna->kgem, priv->gpu_bo)) {
+	if ((priv->create & (KGEM_CAN_CREATE_GTT | KGEM_CAN_CREATE_LARGE)) == KGEM_CAN_CREATE_GTT &&
+	    kgem_bo_can_map(&sna->kgem, priv->gpu_bo) &&
+	    !__kgem_bo_is_busy(&sna->kgem, priv->gpu_bo)) {
 		DBG(("%s: no, target is idle\n", __FUNCTION__));
 		return false;
 	}
commit 64f1fbb465bdd092c4ea4aafe10382ebe7b84ecb
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Nov 28 13:03:29 2013 +0000

    sna: Tidy a split conditional in an picture upload
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/sna_render.c b/src/sna/sna_render.c
index 6f13c21..c183b28 100644
--- a/src/sna/sna_render.c
+++ b/src/sna/sna_render.c
@@ -1203,41 +1203,8 @@ sna_render_picture_extract(struct sna *sna,
 	}
 
 	src_bo = use_cpu_bo(sna, pixmap, &box, true);
-	if (src_bo == NULL) {
+	if (src_bo == NULL)
 		src_bo = move_to_gpu(pixmap, &box, false);
-		if (src_bo == NULL) {
-			struct sna_pixmap *priv = sna_pixmap(pixmap);
-			if (priv) {
-				RegionRec region;
-
-				region.extents = box;
-				region.data = NULL;
-				if (!sna_drawable_move_region_to_cpu(&pixmap->drawable,
-								     &region, MOVE_READ))
-					return 0;
-
-				assert(!priv->mapped);
-				if (pixmap->devPrivate.ptr == NULL)
-					return 0; /* uninitialised */
-			}
-
-			bo = kgem_upload_source_image(&sna->kgem,
-						      pixmap->devPrivate.ptr,
-						      &box,
-						      pixmap->devKind,
-						      pixmap->drawable.bitsPerPixel);
-			if (priv != NULL && bo != NULL &&
-			    box.x2 - box.x1 == pixmap->drawable.width &&
-			    box.y2 - box.y1 == pixmap->drawable.height) {
-				DBG(("%s: adding upload cache to pixmap=%ld\n",
-				     __FUNCTION__, pixmap->drawable.serialNumber));
-				assert(priv->gpu_damage == NULL);
-				assert(priv->gpu_bo == NULL);
-				assert(bo->proxy != NULL);
-				kgem_proxy_bo_attach(bo, &priv->gpu_bo);
-			}
-		}
-	}
 	if (src_bo) {
 		bo = kgem_create_2d(&sna->kgem, w, h,
 				    pixmap->drawable.bitsPerPixel,
@@ -1265,6 +1232,37 @@ sna_render_picture_extract(struct sna *sna,
 				bo = NULL;
 			}
 		}
+	} else {
+		struct sna_pixmap *priv = sna_pixmap(pixmap);
+		if (priv) {
+			RegionRec region;
+
+			region.extents = box;
+			region.data = NULL;
+			if (!sna_drawable_move_region_to_cpu(&pixmap->drawable,
+							     &region, MOVE_READ))
+				return 0;
+
+			assert(!priv->mapped);
+			if (pixmap->devPrivate.ptr == NULL)
+				return 0; /* uninitialised */
+		}
+
+		bo = kgem_upload_source_image(&sna->kgem,
+					      pixmap->devPrivate.ptr,
+					      &box,
+					      pixmap->devKind,
+					      pixmap->drawable.bitsPerPixel);
+		if (priv != NULL && bo != NULL &&
+		    box.x2 - box.x1 == pixmap->drawable.width &&
+		    box.y2 - box.y1 == pixmap->drawable.height) {
+			DBG(("%s: adding upload cache to pixmap=%ld\n",
+			     __FUNCTION__, pixmap->drawable.serialNumber));
+			assert(priv->gpu_damage == NULL);
+			assert(priv->gpu_bo == NULL);
+			assert(bo->proxy != NULL);
+			kgem_proxy_bo_attach(bo, &priv->gpu_bo);
+		}
 	}
 
 	if (bo == NULL) {
commit 1200aae4815cdbc6a4f242c264b2736e6fe0fa12
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Nov 28 13:03:06 2013 +0000

    sna: Wrap image upload with sigtrap
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/kgem.c b/src/sna/kgem.c
index 7e36554..f68f5f4 100644
--- a/src/sna/kgem.c
+++ b/src/sna/kgem.c
@@ -6354,13 +6354,21 @@ struct kgem_bo *kgem_upload_source_image(struct kgem *kgem,
 	bo = kgem_create_buffer_2d(kgem,
 				   width, height, bpp,
 				   KGEM_BUFFER_WRITE_INPLACE, &dst);
-	if (bo)
-		memcpy_blt(data, dst, bpp,
-			   stride, bo->pitch,
-			   box->x1, box->y1,
-			   0, 0,
-			   width, height);
+	if (bo == NULL)
+		return NULL;
+
+	if (sigtrap_get()) {
+		kgem_bo_destroy(kgem, bo);
+		return NULL;
+	}
+
+	memcpy_blt(data, dst, bpp,
+		   stride, bo->pitch,
+		   box->x1, box->y1,
+		   0, 0,
+		   width, height);
 
+	sigtrap_put();
 	return bo;
 }
 
commit 0fb7c366a58ec9b9cdc0b330e53716ab04b24c96
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Nov 27 22:06:27 2013 +0000

    sna: Add a few more refcnt asserts
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/kgem.h b/src/sna/kgem.h
index 13c5b42..d847f3f 100644
--- a/src/sna/kgem.h
+++ b/src/sna/kgem.h
@@ -339,6 +339,7 @@ static inline void kgem_submit(struct kgem *kgem)
 
 static inline void kgem_bo_submit(struct kgem *kgem, struct kgem_bo *bo)
 {
+	assert(bo->refcnt);
 	if (bo->exec)
 		_kgem_submit(kgem);
 }
@@ -515,6 +516,8 @@ static inline bool kgem_bo_blt_pitch_is_ok(struct kgem *kgem,
 static inline bool kgem_bo_can_blt(struct kgem *kgem,
 				   struct kgem_bo *bo)
 {
+	assert(bo->refcnt);
+
 	if (bo->tiling == I915_TILING_Y) {
 		DBG(("%s: can not blt to handle=%d, tiling=Y\n",
 		     __FUNCTION__, bo->handle));
@@ -538,6 +541,7 @@ bool __kgem_busy(struct kgem *kgem, int handle);
 
 static inline void kgem_bo_mark_busy(struct kgem_bo *bo, int ring)
 {
+	assert(bo->refcnt);
 	bo->rq = (struct kgem_request *)((uintptr_t)bo->rq | ring);
 }
 
@@ -584,9 +588,11 @@ static inline bool kgem_bo_is_render(struct kgem_bo *bo)
 
 static inline void kgem_bo_mark_unreusable(struct kgem_bo *bo)
 {
+	assert(bo->refcnt);
 	while (bo->proxy) {
 		bo->flush = true;
 		bo = bo->proxy;
+		assert(bo->refcnt);
 	}
 	bo->flush = true;
 	bo->reusable = false;
@@ -617,6 +623,8 @@ static inline void __kgem_bo_mark_dirty(struct kgem_bo *bo)
 	DBG(("%s: handle=%d (proxy? %d)\n", __FUNCTION__,
 	     bo->handle, bo->proxy != NULL));
 
+	assert(bo->refcnt);
+
 	bo->exec->flags |= LOCAL_EXEC_OBJECT_WRITE;
 	bo->needs_flush = bo->gpu_dirty = true;
 	list_move(&bo->request, &RQ(bo->rq)->buffers);
@@ -671,6 +679,8 @@ static inline bool kgem_bo_can_map__cpu(struct kgem *kgem,
 					struct kgem_bo *bo,
 					bool write)
 {
+	assert(bo->refcnt);
+
 	if (bo->purged || (bo->scanout && write))
 		return false;
 


More information about the xorg-commit mailing list