xf86-video-intel: 5 commits - src/sna/kgem.c src/sna/sna_accel.c src/sna/sna_render.c

Chris Wilson ickle at kemper.freedesktop.org
Wed Dec 14 11:42:24 PST 2011


 src/sna/kgem.c       |   12 +++++++++++-
 src/sna/sna_accel.c  |   40 ++++++++++++++++++++++++++++------------
 src/sna/sna_render.c |   18 +++++++++++-------
 3 files changed, 50 insertions(+), 20 deletions(-)

New commits:
commit 95cceb5ae5503af0ac50a923fa47e134f0da8743
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Dec 14 19:27:53 2011 +0000

    sna: Fix DBG crash whilst pruning inactive GPU buffers
    
    Don't attempt to dereference the NULL gpu_bo after having just freed it.
    Here in lies the folly of trying to blindly silence the compiler.
    
    Instead we should heed the error return as it means that we didn't
    decouple the pixmap from the inactive list and so we choose to place it
    back on the active list to purge again in the near future.
    
    Reported-by: Paul Neumann <paul104x at yahoo.de
    References: https://bugs.freedesktop.org/show_bug.cgi?id=43716
    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 c4256b3..6789c34 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -8746,7 +8746,8 @@ static void sna_accel_inactive(struct sna *sna)
 
 		count = bytes = 0;
 		list_for_each_entry(priv, &sna->inactive_clock[1], inactive)
-			count++, bytes += priv->gpu_bo->size;
+			if (!priv->pinned)
+				count++, bytes += priv->gpu_bo->size;
 
 		DBG(("%s: trimming %d inactive GPU buffers, %d bytes\n",
 		    __FUNCTION__, count, bytes));
@@ -8782,19 +8783,17 @@ static void sna_accel_inactive(struct sna *sna)
 		priv = list_first_entry(&sna->inactive_clock[1],
 					struct sna_pixmap,
 					inactive);
-		if (priv->pinned) {
-			list_del(&priv->inactive);
-		} else {
-			bool ret = sna_pixmap_move_to_cpu(priv->pixmap, true);
-			DBG(("%s: discarding GPU bo handle=%d (success? %d)\n",
-			     __FUNCTION__, priv->gpu_bo->handle, ret));
-			(void)ret;
-		}
-
 		/* XXX Rather than discarding the GPU buffer here, we
 		 * could mark it purgeable and allow the shrinker to
 		 * reap its storage only under memory pressure.
 		 */
+		list_del(&priv->inactive);
+		if (!priv->pinned) {
+			DBG(("%s: discarding inactive GPU bo handle=%d\n",
+			     __FUNCTION__, priv->gpu_bo->handle));
+			if (!sna_pixmap_move_to_cpu(priv->pixmap, true))
+				list_add(&priv->inactive, &preserve);
+		}
 	}
 
 	/* Age the current inactive pixmaps */
commit e7f4b7fd91a41cac77e5eb1cb4f185141b09a09e
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Dec 14 18:21:22 2011 +0000

    sna: Add some DBG() around Y-to-X fallbacks
    
    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 64bdd05..c4256b3 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -313,16 +313,24 @@ static bool sna_pixmap_change_tiling(PixmapPtr pixmap, uint32_t tiling)
 	struct kgem_bo *bo;
 	BoxRec box;
 
-	if (priv->pinned)
+	DBG(("%s: changing tiling %d -> %d for %dx%d pixmap\n",
+	     __FUNCTION__, priv->gpu_bo->tiling, tiling,
+	     pixmap->drawable.width, pixmap->drawable.height));
+
+	if (priv->pinned) {
+		DBG(("%s: can't convert pinned bo\n", __FUNCTION__));
 		return false;
+	}
 
 	bo = kgem_create_2d(&sna->kgem,
 			    pixmap->drawable.width,
 			    pixmap->drawable.height,
 			    pixmap->drawable.bitsPerPixel,
 			    tiling, 0);
-	if (bo == NULL)
+	if (bo == NULL) {
+		DBG(("%s: allocation failed\n", __FUNCTION__));
 		return false;
+	}
 
 	box.x1 = box.y1 = 0;
 	box.x2 = pixmap->drawable.width;
@@ -332,6 +340,7 @@ static bool sna_pixmap_change_tiling(PixmapPtr pixmap, uint32_t tiling)
 				    pixmap, priv->gpu_bo, 0, 0,
 				    pixmap, bo, 0, 0,
 				    &box, 1)) {
+		DBG(("%s: copy failed\n", __FUNCTION__));
 		kgem_bo_destroy(&sna->kgem, bo);
 		return false;
 	}
@@ -1583,6 +1592,7 @@ sna_put_xybitmap_blt(DrawablePtr drawable, GCPtr gc, RegionPtr region,
 		return false;
 
 	if (priv->gpu_bo->tiling == I915_TILING_Y) {
+		DBG(("%s: converting bo from Y-tiling\n", __FUNCTION__));
 		if (!sna_pixmap_change_tiling(pixmap, I915_TILING_X))
 			return false;
 	}
@@ -1703,6 +1713,7 @@ sna_put_xypixmap_blt(DrawablePtr drawable, GCPtr gc, RegionPtr region,
 		return false;
 
 	if (bo->tiling == I915_TILING_Y) {
+		DBG(("%s: converting bo from Y-tiling\n", __FUNCTION__));
 		if (!sna_pixmap_change_tiling(pixmap, I915_TILING_X))
 			return false;
 
@@ -6993,6 +7004,7 @@ sna_poly_fill_rect_stippled_blt(DrawablePtr drawable,
 	if (bo->tiling == I915_TILING_Y) {
 		PixmapPtr pixmap = get_drawable_pixmap(drawable);
 
+		DBG(("%s: converting bo from Y-tiling\n", __FUNCTION__));
 		/* This is cheating, but only the gpu_bo can be tiled */
 		assert(bo == sna_pixmap(pixmap)->gpu_bo);
 
@@ -7305,6 +7317,7 @@ sna_glyph_blt(DrawablePtr drawable, GCPtr gc,
 
 	bo = priv->gpu_bo;
 	if (bo->tiling == I915_TILING_Y) {
+		DBG(("%s: converting bo from Y-tiling\n", __FUNCTION__));
 		if (!sna_pixmap_change_tiling(pixmap, I915_TILING_X)) {
 			DBG(("%s -- fallback, dst uses Y-tiling\n", __FUNCTION__));
 			return false;
@@ -7868,6 +7881,7 @@ sna_reversed_glyph_blt(DrawablePtr drawable, GCPtr gc,
 	uint8_t rop = transparent ? copy_ROP[gc->alu] : ROP_S;
 
 	if (priv->gpu_bo->tiling == I915_TILING_Y) {
+		DBG(("%s: converting bo from Y-tiling\n", __FUNCTION__));
 		if (!sna_pixmap_change_tiling(pixmap, I915_TILING_X)) {
 			DBG(("%s -- fallback, dst uses Y-tiling\n", __FUNCTION__));
 			return false;
@@ -8161,6 +8175,7 @@ sna_push_pixels_solid_blt(GCPtr gc,
 	uint8_t rop = copy_ROP[gc->alu];
 
 	if (priv->gpu_bo->tiling == I915_TILING_Y) {
+		DBG(("%s: converting bo from Y-tiling\n", __FUNCTION__));
 		if (!sna_pixmap_change_tiling(pixmap, I915_TILING_X))
 			return false;
 	}
commit 32bb2c89b8cab92f16af32e7a084bfefa406661d
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Dec 14 16:28:54 2011 +0000

    sna: Check allocation of pixman_image_t
    
    And just fail to perform the copy, clearing the dst instead.
    
    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 001dcec..e10f484 100644
--- a/src/sna/sna_render.c
+++ b/src/sna/sna_render.c
@@ -1006,13 +1006,17 @@ sna_render_picture_fixup(struct sna *sna,
 		src = dst;
 		dst = pixman_image_create_bits(channel->pict_format,
 					       w, h, ptr, pitch);
-
-		pixman_image_composite(PictOpSrc, src, NULL, dst,
-				       0, 0,
-				       0, 0,
-				       0, 0,
-				       w, h);
-		pixman_image_unref(src);
+		if (dst) {
+			pixman_image_composite(PictOpSrc, src, NULL, dst,
+					       0, 0,
+					       0, 0,
+					       0, 0,
+					       w, h);
+			pixman_image_unref(src);
+		} else {
+			memset(ptr, 0, h*pitch);
+			dst = src;
+		}
 	}
 	pixman_image_unref(dst);
 
commit 37c525a11c0fab4e279e80ad24e5cf791239e005
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Dec 14 16:26:46 2011 +0000

    sna: Skip glyphs if we fail to allocate pixel data for them
    
    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 a730006..64bdd05 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -7506,6 +7506,8 @@ static bool sna_set_glyph(CharInfoPtr in, CharInfoPtr out)
 
 	out->metrics = in->metrics;
 	out->bits = malloc(w*h);
+	if (out->bits == NULL)
+		return false;
 
 	src = (uint8_t *)in->bits;
 	dst = (uint8_t *)out->bits;
commit 6a8188bb4dd0eba58e29803566023ad5c3d4d58a
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Dec 14 16:24:54 2011 +0000

    sna: Close any handles after bo allocation failures
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/kgem.c b/src/sna/kgem.c
index 65b600e..fbff051 100644
--- a/src/sna/kgem.c
+++ b/src/sna/kgem.c
@@ -1415,7 +1415,13 @@ struct kgem_bo *kgem_create_linear(struct kgem *kgem, int size)
 		return NULL;
 
 	DBG(("%s: new handle=%d\n", __FUNCTION__, handle));
-	return __kgem_bo_alloc(handle, size);
+	bo = __kgem_bo_alloc(handle, size);
+	if (bo == NULL) {
+		gem_close(kgem->fd, size);
+		return NULL;
+	}
+
+	return bo;
 }
 
 int kgem_choose_tiling(struct kgem *kgem, int tiling, int width, int height, int bpp)
@@ -2600,6 +2606,10 @@ kgem_replace_bo(struct kgem *kgem,
 			return NULL;
 
 		dst = __kgem_bo_alloc(handle, size);
+		if (dst== NULL) {
+			gem_close(kgem->fd, handle);
+			return NULL;
+		}
 	}
 	dst->pitch = pitch;
 	dst->unique_id = kgem_get_unique_id(kgem);


More information about the xorg-commit mailing list