xf86-video-intel: 10 commits - src/intel_dri.c src/intel_shadow.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_glyphs.c src/sna/sna.h src/sna/sna_io.c src/sna/sna_render.c src/sna/sna_trapezoids.c

Chris Wilson ickle at kemper.freedesktop.org
Wed Jan 18 10:52:34 PST 2012


 src/intel_dri.c          |    1 
 src/intel_shadow.c       |   24 +++++++-----------
 src/sna/gen6_render.c    |   12 +++++++--
 src/sna/gen7_render.c    |   10 +++++++
 src/sna/kgem.c           |   30 +++++++++++------------
 src/sna/kgem.h           |    2 +
 src/sna/sna.h            |    5 ---
 src/sna/sna_accel.c      |   60 ++++++++++++++++++++++++++---------------------
 src/sna/sna_glyphs.c     |    5 +--
 src/sna/sna_io.c         |   38 +++++++++++++----------------
 src/sna/sna_render.c     |   19 ++++++++++++++
 src/sna/sna_trapezoids.c |    6 ++--
 12 files changed, 120 insertions(+), 92 deletions(-)

New commits:
commit 76203b70708b8750f52348ea8b9135191e650ff7
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Jan 18 18:36:43 2012 +0000

    sna: Almagamate writes based on the total number of bytes written
    
    Cachelines will only be dirtied for the bytes accessed so a better
    metric would based on the total number of pages brought into the TLB
    and the total number of cachelines used. Base the decision on whether
    to try and amalgamate the upload with others on the number of bytes
    copied rather than the overall extents.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/sna_io.c b/src/sna/sna_io.c
index 046660e..a2e7a59 100644
--- a/src/sna/sna_io.c
+++ b/src/sna/sna_io.c
@@ -396,24 +396,12 @@ static bool upload_inplace(struct kgem *kgem,
 	 * operation.
 	 */
 	if (!bo->map) {
-		BoxRec extents;
-
-		extents = box[0];
-		while (--n) {
+		unsigned int bytes = 0;
+		while (n--) {
+			bytes += (box->x2 - box->x1) * (box->y2 - box->y1);
 			box++;
-			if (box->x1 < extents.x1)
-				extents.x1 = box->x1;
-			if (box->x2 > extents.x2)
-				extents.x2 = box->x2;
-
-			if (box->y1 < extents.y1)
-				extents.y1 = box->y1;
-			if (box->y2 > extents.y2)
-				extents.y2 = box->y2;
 		}
-
-		if ((extents.x2 - extents.x1) * (extents.y2 - extents.y1) * bpp >> 12
-		    < kgem->half_cpu_cache_pages)
+		if (bytes * bpp >> 12 < kgem->half_cpu_cache_pages)
 			return false;
 	}
 
commit 470741e84c813a257897ee69f14500207a2674dc
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Jan 18 18:35:59 2012 +0000

    sna: Debug uploads
    
    All of the asserts and debug options that lead me to believe that the
    tiling was completely screwy for some writes.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/gen6_render.c b/src/sna/gen6_render.c
index 6dfcdf0..7ece952 100644
--- a/src/sna/gen6_render.c
+++ b/src/sna/gen6_render.c
@@ -2423,7 +2423,7 @@ gen6_render_composite(struct sna *sna,
 	if (!gen6_composite_set_target(sna, tmp, dst))
 		return FALSE;
 
-	if (mask == NULL && sna->kgem.mode == KGEM_BLT  &&
+	if (mask == NULL && sna->kgem.mode == KGEM_BLT &&
 	    sna_blt_composite(sna, op,
 			      src, dst,
 			      src_x, src_y,
diff --git a/src/sna/kgem.c b/src/sna/kgem.c
index 0fb244f..b49f92a 100644
--- a/src/sna/kgem.c
+++ b/src/sna/kgem.c
@@ -1139,9 +1139,9 @@ static void kgem_commit(struct kgem *kgem)
 	struct kgem_bo *bo, *next;
 
 	list_for_each_entry_safe(bo, next, &rq->buffers, request) {
-		DBG(("%s: release handle=%d (proxy? %d), dirty? %d flush? %d\n",
+		DBG(("%s: release handle=%d (proxy? %d), dirty? %d flush? %d -> offset=%x\n",
 		     __FUNCTION__, bo->handle, bo->proxy != NULL,
-		     bo->dirty, bo->needs_flush));
+		     bo->dirty, bo->needs_flush, (unsigned)bo->exec->offset));
 
 		assert(!bo->purged);
 		assert(bo->proxy || bo->rq == rq);
@@ -2615,6 +2615,9 @@ void *kgem_bo_map(struct kgem *kgem, struct kgem_bo *bo)
 {
 	void *ptr;
 
+	DBG(("%s: handle=%d, tiling=%d, map=%p, domain=%d\n", __FUNCTION__,
+	     bo->handle, bo->tiling, bo->map, bo->domain));
+
 	assert(!bo->purged);
 	assert(bo->exec == NULL);
 	assert(list_is_empty(&bo->list));
diff --git a/src/sna/sna_io.c b/src/sna/sna_io.c
index 79448c8..046660e 100644
--- a/src/sna/sna_io.c
+++ b/src/sna/sna_io.c
@@ -342,11 +342,10 @@ static void write_boxes_inplace(struct kgem *kgem,
 				struct kgem_bo *bo, int16_t dst_dx, int16_t dst_dy,
 				const BoxRec *box, int n)
 {
-	int dst_pitch = bo->pitch;
-	int src_pitch = stride;
 	void *dst;
 
-	DBG(("%s x %d, tiling=%d\n", __FUNCTION__, n, bo->tiling));
+	DBG(("%s x %d, handle=%d, tiling=%d\n",
+	     __FUNCTION__, n, bo->handle, bo->tiling));
 
 	kgem_bo_submit(kgem, bo);
 
@@ -361,10 +360,19 @@ static void write_boxes_inplace(struct kgem *kgem,
 		     box->x1 + src_dx, box->y1 + src_dy,
 		     box->x1 + dst_dx, box->y1 + dst_dy,
 		     box->x2 - box->x1, box->y2 - box->y1,
-		     bpp, src_pitch, dst_pitch));
+		     bpp, stride, bo->pitch));
+
+		assert(box->x1 + dst_dx >= 0);
+		assert((box->x2 + dst_dx)*bpp <= 8*bo->pitch);
+		assert(box->y1 + dst_dy >= 0);
+		assert((box->y2 + dst_dy)*bo->pitch <= bo->size);
+
+		assert(box->x1 + src_dx >= 0);
+		assert((box->x2 + src_dx)*bpp <= 8*stride);
+		assert(box->y1 + src_dy >= 0);
 
 		memcpy_blt(src, dst, bpp,
-			   src_pitch, dst_pitch,
+			   stride, bo->pitch,
 			   box->x1 + src_dx, box->y1 + src_dy,
 			   box->x1 + dst_dx, box->y1 + dst_dy,
 			   box->x2 - box->x1, box->y2 - box->y1);
diff --git a/src/sna/sna_render.c b/src/sna/sna_render.c
index 7b6661e..fde95f9 100644
--- a/src/sna/sna_render.c
+++ b/src/sna/sna_render.c
@@ -41,6 +41,9 @@
 #define NO_FIXUP 0
 #define NO_EXTRACT 0
 
+#define DBG_FORCE_UPLOAD 0
+#define DBG_NO_CPU_BO 0
+
 CARD32
 sna_format_for_depth(int depth)
 {
@@ -289,6 +292,9 @@ use_cpu_bo(struct sna *sna, PixmapPtr pixmap, const BoxRec *box)
 {
 	struct sna_pixmap *priv;
 
+	if (DBG_NO_CPU_BO)
+		return NULL;
+
 	priv = sna_pixmap_attach(pixmap);
 	if (priv == NULL || priv->cpu_bo == NULL) {
 		DBG(("%s: no cpu bo\n", __FUNCTION__));
@@ -352,12 +358,18 @@ move_to_gpu(PixmapPtr pixmap, const BoxRec *box)
 	struct sna_pixmap *priv;
 	int count, w, h;
 
+	if (DBG_FORCE_UPLOAD > 0)
+		return FALSE;
+
 	if (pixmap->usage_hint) {
 		DBG(("%s: not migrating pixmap due to usage_hint=%d\n",
 		     __FUNCTION__, pixmap->usage_hint));
 		return FALSE;
 	}
 
+	if (DBG_FORCE_UPLOAD < 0)
+		return TRUE;
+
 	w = box->x2 - box->x1;
 	h = box->y2 - box->y1;
 	if (w == pixmap->drawable.width && h == pixmap->drawable.height) {
commit ab387a89cf64ace9f7d7fa52b7743e78b625f47d
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Jan 18 18:32:51 2012 +0000

    sna: Update bo->tiling during search_linear_cache
    
    search_linear_cache() was updated to track the first good match whilst it
    continued to search for a better match. This resulted in the first good
    bo being modified and a record of those modifications lost, in
    particular the change in tiling.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/kgem.c b/src/sna/kgem.c
index f824230..0fb244f 100644
--- a/src/sna/kgem.c
+++ b/src/sna/kgem.c
@@ -1874,6 +1874,8 @@ search_linear_cache(struct kgem *kgem, unsigned int size, unsigned flags)
 			if (gem_set_tiling(kgem->fd, bo->handle,
 					   I915_TILING_NONE, 0) != I915_TILING_NONE)
 				continue;
+
+			bo->tiling = I915_TILING_NONE;
 		}
 
 		if (bo->map) {
@@ -1908,7 +1910,7 @@ search_linear_cache(struct kgem *kgem, unsigned int size, unsigned flags)
 		else
 			kgem_bo_remove_from_inactive(kgem, bo);
 
-		bo->tiling = I915_TILING_NONE;
+		assert(bo->tiling == I915_TILING_NONE);
 		bo->pitch = 0;
 		bo->delta = 0;
 		DBG(("  %s: found handle=%d (size=%d) in linear %s cache\n",
@@ -1921,22 +1923,13 @@ search_linear_cache(struct kgem *kgem, unsigned int size, unsigned flags)
 	}
 
 	if (first) {
-		if (I915_TILING_NONE != first->tiling) {
-			assert(!use_active);
-			if (gem_set_tiling(kgem->fd, first->handle,
-					   I915_TILING_NONE, 0) != I915_TILING_NONE)
-				return NULL;
-
-			if (first->map)
-				kgem_bo_release_map(kgem, first);
-		}
+		assert(first->tiling == I915_TILING_NONE);
 
 		if (use_active)
 			kgem_bo_remove_from_active(kgem, first);
 		else
 			kgem_bo_remove_from_inactive(kgem, first);
 
-		first->tiling = I915_TILING_NONE;
 		first->pitch = 0;
 		first->delta = 0;
 		DBG(("  %s: found handle=%d (size=%d) in linear %s cache\n",
commit 4b893ab0812452238305b29b1beea224219f641d
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Jan 18 16:34:17 2012 +0000

    sna: Remove defunct debugging option
    
    FORCE_GPU_ONLY now has no effect except for marking the initial pixmap
    as all-damaged on the GPU, and so not testing the paths for which it was
    originally introduction.
    
    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 29321a8..0904f0f 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -54,7 +54,6 @@
 #define DBG(x) ErrorF x
 #endif
 
-#define FORCE_GPU_ONLY 0
 #define FORCE_INPLACE 0
 #define FORCE_FALLBACK 0
 #define FORCE_FLUSH 0
@@ -655,11 +654,6 @@ static PixmapPtr sna_create_pixmap(ScreenPtr screen,
 						 width, height, depth,
 						 I915_TILING_Y);
 
-	if (FORCE_GPU_ONLY && width && height)
-		return sna_pixmap_create_scratch(screen,
-						 width, height, depth,
-						 I915_TILING_X);
-
 	if (usage == CREATE_PIXMAP_USAGE_GLYPH_PICTURE ||
 	    !kgem_can_create_2d(&sna->kgem, width, height,
 				BitsPerPixel(depth), I915_TILING_NONE))
commit 965586544a8559b6b6b98c20e14c1266e46bf20d
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Jan 18 16:11:50 2012 +0000

    sna/gen6: Don't assume that a batch mode implies a non-empty batch
    
    Just in case we set a mode then fail to emit any dwords. Sounds
    inefficient and woe betide the culprit when I find it...
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/gen6_render.c b/src/sna/gen6_render.c
index 86ebf9d..6dfcdf0 100644
--- a/src/sna/gen6_render.c
+++ b/src/sna/gen6_render.c
@@ -3881,7 +3881,7 @@ gen6_render_context_switch(struct kgem *kgem,
 	 DBG(("%s: from %d to %d\n", __FUNCTION__, kgem->mode, new_mode));
 
 	if (kgem->mode)
-		_kgem_submit(kgem);
+		kgem_submit(kgem);
 
 	kgem->ring = new_mode;
 }
diff --git a/src/sna/gen7_render.c b/src/sna/gen7_render.c
index e73629d..06066a5 100644
--- a/src/sna/gen7_render.c
+++ b/src/sna/gen7_render.c
@@ -3843,7 +3843,7 @@ gen7_render_context_switch(struct kgem *kgem,
 		return;
 
 	if (kgem->mode)
-		_kgem_submit(kgem);
+		kgem_submit(kgem);
 
 	kgem->ring = new_mode;
 }
commit d2e05750360fb19575f3becd87816184615855bf
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Jan 18 16:08:51 2012 +0000

    sna: Fix some tracking of to-be-flushed dri pixmaps
    
    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 51b3662..29321a8 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -803,6 +803,13 @@ skip_inplace_map:
 				DBG(("%s: discarding busy CPU bo\n", __FUNCTION__));
 				sna_damage_destroy(&priv->cpu_damage);
 				list_del(&priv->list);
+				if (priv->undamaged) {
+					sna_damage_all(&priv->gpu_damage,
+						       pixmap->drawable.width,
+						       pixmap->drawable.height);
+					list_del(&priv->list);
+					priv->undamaged = false;
+				}
 				sna_pixmap_free_cpu(sna, priv);
 			}
 		}
@@ -1063,6 +1070,7 @@ sna_drawable_move_region_to_cpu(DrawablePtr drawable,
 
 				sna_damage_subtract(&priv->cpu_damage, region);
 				if (priv->cpu_damage == NULL) {
+					list_del(&priv->list);
 					sna_damage_all(&priv->gpu_damage,
 						       pixmap->drawable.width,
 						       pixmap->drawable.height);
@@ -1101,6 +1109,7 @@ sna_drawable_move_region_to_cpu(DrawablePtr drawable,
 
 			sna_damage_subtract(&priv->cpu_damage, region);
 			if (priv->cpu_damage == NULL) {
+				list_del(&priv->list);
 				sna_damage_all(&priv->gpu_damage,
 					       pixmap->drawable.width,
 					       pixmap->drawable.height);
@@ -1402,13 +1411,20 @@ sna_pixmap_move_area_to_gpu(PixmapPtr pixmap, BoxPtr box)
 			return false;
 
 		DBG(("%s: created gpu bo\n", __FUNCTION__));
+
+		if (flags & MOVE_WRITE && priv->cpu_damage == NULL) {
+			sna_damage_all(&priv->gpu_damage,
+				       pixmap->drawable.width,
+				       pixmap->drawable.height);
+			goto done;
+		}
 	}
 
 	sna_damage_reduce(&priv->cpu_damage);
-	DBG(("%s: CPU damage? %d\n", __FUNCTION__, priv->cpu_damage != NULL));
-
-	if (priv->cpu_damage == NULL)
+	if (priv->cpu_damage == NULL) {
+		list_del(&priv->list);
 		goto done;
+	}
 
 	if (priv->mapped) {
 		assert(priv->stride);
@@ -1470,8 +1486,6 @@ sna_pixmap_move_area_to_gpu(PixmapPtr pixmap, BoxPtr box)
 					box, 1);
 
 		sna_damage_subtract(&priv->cpu_damage, &r);
-		if (priv->cpu_damage == NULL)
-			list_del(&priv->list);
 		priv->undamaged = true;
 	} else if (sna_damage_intersect(priv->cpu_damage, &r, &i)) {
 		int n = REGION_NUM_RECTS(&i);
@@ -1495,9 +1509,6 @@ sna_pixmap_move_area_to_gpu(PixmapPtr pixmap, BoxPtr box)
 		sna_damage_subtract(&priv->cpu_damage, &r);
 		priv->undamaged = true;
 		RegionUninit(&i);
-
-		if (priv->cpu_damage == NULL)
-			list_del(&priv->list);
 	}
 
 done:
@@ -1807,6 +1818,7 @@ sna_pixmap_force_to_gpu(PixmapPtr pixmap, unsigned flags)
 			sna_damage_all(&priv->gpu_damage,
 				       pixmap->drawable.width,
 				       pixmap->drawable.height);
+			list_del(&priv->list);
 			priv->undamaged = false;
 			DBG(("%s: marking as all-damaged for GPU\n",
 			     __FUNCTION__));
@@ -1870,6 +1882,7 @@ sna_pixmap_move_to_gpu(PixmapPtr pixmap, unsigned flags)
 			sna_damage_all(&priv->gpu_damage,
 				       pixmap->drawable.width,
 				       pixmap->drawable.height);
+			list_del(&priv->list);
 			priv->undamaged = false;
 			DBG(("%s: marking as all-damaged for GPU\n",
 			     __FUNCTION__));
@@ -2242,15 +2255,15 @@ sna_put_zpixmap_blt(DrawablePtr drawable, GCPtr gc, RegionPtr region,
 				     x, y, w, h, bits, stride)) {
 		if (!DAMAGE_IS_ALL(priv->gpu_damage)) {
 			DBG(("%s: marking damage\n", __FUNCTION__));
-			if (region_subsumes_drawable(region, &pixmap->drawable)) {
+			if (region_subsumes_drawable(region, &pixmap->drawable))
 				sna_damage_destroy(&priv->cpu_damage);
-				list_del(&priv->list);
-			} else
+			else
 				sna_damage_subtract(&priv->cpu_damage, region);
 			if (priv->cpu_damage == NULL) {
 				sna_damage_all(&priv->gpu_damage,
 					       pixmap->drawable.width,
 					       pixmap->drawable.height);
+				list_del(&priv->list);
 				priv->undamaged = false;
 			} else
 				sna_damage_add(&priv->gpu_damage, region);
@@ -2285,15 +2298,15 @@ sna_put_zpixmap_blt(DrawablePtr drawable, GCPtr gc, RegionPtr region,
 				if (sna_put_image_upload_blt(drawable, gc, region,
 							     x, y, w, h, bits, stride)) {
 					if (!DAMAGE_IS_ALL(priv->gpu_damage)) {
-						if (region_subsumes_drawable(region, &pixmap->drawable)) {
+						if (region_subsumes_drawable(region, &pixmap->drawable))
 							sna_damage_destroy(&priv->cpu_damage);
-							list_del(&priv->list);
-						} else
+						else
 							sna_damage_subtract(&priv->cpu_damage, region);
 						if (priv->cpu_damage == NULL) {
 							sna_damage_all(&priv->gpu_damage,
 								       pixmap->drawable.width,
 								       pixmap->drawable.height);
+							list_del(&priv->list);
 							priv->undamaged = false;
 						} else
 							sna_damage_add(&priv->gpu_damage, region);
@@ -2313,13 +2326,13 @@ sna_put_zpixmap_blt(DrawablePtr drawable, GCPtr gc, RegionPtr region,
 					} else {
 						sna_damage_destroy(&priv->cpu_damage);
 						priv->undamaged = false;
-						list_del(&priv->list);
 					}
 				}
 				if (priv->undamaged) {
 					sna_damage_all(&priv->gpu_damage,
 						       pixmap->drawable.width,
 						       pixmap->drawable.height);
+					list_del(&priv->list);
 					priv->undamaged = false;
 				}
 				sna_pixmap_free_cpu(sna, priv);
@@ -3041,6 +3054,7 @@ sna_copy_boxes(DrawablePtr src, DrawablePtr dst, GCPtr gc,
 					sna_damage_all(&dst_priv->gpu_damage,
 						       dst_pixmap->drawable.width,
 						       dst_pixmap->drawable.height);
+					list_del(&dst_priv->list);
 					dst_priv->undamaged = false;
 				} else {
 					RegionTranslate(&region, dst_dx, dst_dy);
@@ -3071,6 +3085,7 @@ sna_copy_boxes(DrawablePtr src, DrawablePtr dst, GCPtr gc,
 					sna_damage_all(&dst_priv->gpu_damage,
 						       dst_pixmap->drawable.width,
 						       dst_pixmap->drawable.height);
+					list_del(&dst_priv->list);
 					dst_priv->undamaged = false;
 				} else {
 					RegionTranslate(&region, dst_dx, dst_dy);
@@ -3168,6 +3183,7 @@ sna_copy_boxes(DrawablePtr src, DrawablePtr dst, GCPtr gc,
 					sna_damage_all(&dst_priv->gpu_damage,
 						       dst_pixmap->drawable.width,
 						       dst_pixmap->drawable.height);
+					list_del(&dst_priv->list);
 					dst_priv->undamaged = false;
 				}
 			} else {
@@ -9751,7 +9767,6 @@ sna_accel_flush_callback(CallbackListPtr *list,
 		struct sna_pixmap *priv = list_first_entry(&sna->dirty_pixmaps,
 							   struct sna_pixmap,
 							   list);
-		assert(priv->cpu_damage != NULL);
 		if (!sna_pixmap_move_to_gpu(priv->pixmap, MOVE_READ))
 			list_move(&priv->list, &preserve);
 	}
diff --git a/src/sna/sna_trapezoids.c b/src/sna/sna_trapezoids.c
index 4f5231c..2fd1eaf 100644
--- a/src/sna/sna_trapezoids.c
+++ b/src/sna/sna_trapezoids.c
@@ -3946,6 +3946,7 @@ static void mark_damaged(PixmapPtr pixmap, struct sna_pixmap *priv,
 		sna_damage_all(&priv->gpu_damage,
 			       pixmap->drawable.width,
 			       pixmap->drawable.height);
+		list_del(&priv->list);
 		priv->undamaged = false;
 	} else {
 		sna_damage_add_box(&priv->gpu_damage, box);
commit 1ad5320fd40eaaf0bffcd209bf1eabd9a20e4bf8
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Jan 18 15:39:35 2012 +0000

    sna: Add valgrind markup for tracking CPU mmaps
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/kgem.c b/src/sna/kgem.c
index 1866fcd..f824230 100644
--- a/src/sna/kgem.c
+++ b/src/sna/kgem.c
@@ -859,6 +859,7 @@ static void kgem_bo_release_map(struct kgem *kgem, struct kgem_bo *bo)
 	     __FUNCTION__, type ? "CPU" : "GTT",
 	     bo->handle, kgem->vma[type].count));
 
+	VG(if (type) VALGRIND_FREELIKE_BLOCK(CPU_MAP(bo->map), 0));
 	munmap(CPU_MAP(bo->map), bo->size);
 	bo->map = NULL;
 
@@ -2606,6 +2607,7 @@ static void kgem_trim_vma_cache(struct kgem *kgem, int type, int bucket)
 		assert(bo->map);
 		assert(bo->rq == NULL);
 
+		VG(if (type) VALGRIND_FREELIKE_BLOCK(CPU_MAP(bo->map), 0));
 		munmap(CPU_MAP(bo->map), bo->size);
 		bo->map = NULL;
 		list_del(&bo->vma);
@@ -2707,6 +2709,8 @@ void *kgem_bo_map__cpu(struct kgem *kgem, struct kgem_bo *bo)
 		return NULL;
 	}
 
+	VG(VALGRIND_MALLOCLIKE_BLOCK(mmap_arg.addr_ptr, bo->size, 0, 1));
+
 	DBG(("%s: caching CPU vma for %d\n", __FUNCTION__, bo->handle));
 	bo->map = MAKE_CPU_MAP(mmap_arg.addr_ptr);
 	return (void *)(uintptr_t)mmap_arg.addr_ptr;
commit f3da610eadd1f560812603ab1a72c2e173679689
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Jan 18 12:59:48 2012 +0000

    sna: Prevent switching rings with render disabled
    
    We fudge forced used of the BLT ring unless we install a render backend
    and so we must also prevent the ring from being reset when the GPU is
    idle. Therefore we make handing the ring status a backend function.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/gen6_render.c b/src/sna/gen6_render.c
index 8d3c031..86ebf9d 100644
--- a/src/sna/gen6_render.c
+++ b/src/sna/gen6_render.c
@@ -3886,6 +3886,13 @@ gen6_render_context_switch(struct kgem *kgem,
 	kgem->ring = new_mode;
 }
 
+static void
+gen6_render_retire(struct kgem *kgem)
+{
+	if (kgem->ring && (kgem->has_semaphores || !kgem->need_retire))
+		kgem->ring = kgem->mode;
+}
+
 static void gen6_render_reset(struct sna *sna)
 {
 	sna->render_state.gen6.needs_invariant = TRUE;
@@ -3958,6 +3965,7 @@ Bool gen6_render_init(struct sna *sna)
 		return FALSE;
 
 	sna->kgem.context_switch = gen6_render_context_switch;
+	sna->kgem.retire = gen6_render_retire;
 
 	sna->render.composite = gen6_render_composite;
 #if !NO_COMPOSITE_SPANS
diff --git a/src/sna/gen7_render.c b/src/sna/gen7_render.c
index 75caa6f..e73629d 100644
--- a/src/sna/gen7_render.c
+++ b/src/sna/gen7_render.c
@@ -3848,6 +3848,13 @@ gen7_render_context_switch(struct kgem *kgem,
 	kgem->ring = new_mode;
 }
 
+static void
+gen7_render_retire(struct kgem *kgem)
+{
+	if (kgem->ring && (kgem->has_semaphores || !kgem->need_retire))
+		kgem->ring = kgem->mode;
+}
+
 static void gen7_render_reset(struct sna *sna)
 {
 	sna->render_state.gen7.needs_invariant = TRUE;
@@ -3920,6 +3927,7 @@ Bool gen7_render_init(struct sna *sna)
 		return FALSE;
 
 	sna->kgem.context_switch = gen7_render_context_switch;
+	sna->kgem.retire = gen7_render_retire;
 
 	sna->render.composite = gen7_render_composite;
 #if !NO_COMPOSITE_SPANS
diff --git a/src/sna/kgem.c b/src/sna/kgem.c
index 01521a9..1866fcd 100644
--- a/src/sna/kgem.c
+++ b/src/sna/kgem.c
@@ -1125,10 +1125,10 @@ bool kgem_retire(struct kgem *kgem)
 	}
 
 	kgem->need_retire = !list_is_empty(&kgem->requests);
-	if (kgem->ring && (kgem->has_semaphores || !kgem->need_retire))
-		kgem->ring = kgem->mode;
 	DBG(("%s -- need_retire=%d\n", __FUNCTION__, kgem->need_retire));
 
+	kgem->retire(kgem);
+
 	return retired;
 }
 
diff --git a/src/sna/kgem.h b/src/sna/kgem.h
index 621e3cd..92b7cd6 100644
--- a/src/sna/kgem.h
+++ b/src/sna/kgem.h
@@ -158,6 +158,8 @@ struct kgem {
 	uint32_t partial_buffer_size;
 
 	void (*context_switch)(struct kgem *kgem, int new_mode);
+	void (*retire)(struct kgem *kgem);
+
 	uint32_t batch[4*1024];
 	struct drm_i915_gem_exec_object2 exec[256];
 	struct drm_i915_gem_relocation_entry reloc[384];
diff --git a/src/sna/sna.h b/src/sna/sna.h
index 2f79ac6..247cb46 100644
--- a/src/sna/sna.h
+++ b/src/sna/sna.h
@@ -374,11 +374,6 @@ void sna_dri_close(struct sna *sna, ScreenPtr pScreen);
 extern Bool sna_crtc_on(xf86CrtcPtr crtc);
 int sna_crtc_to_pipe(xf86CrtcPtr crtc);
 
-/* sna_render.c */
-void sna_kgem_reset(struct kgem *kgem);
-void sna_kgem_flush(struct kgem *kgem);
-void sna_kgem_context_switch(struct kgem *kgem, int new_mode);
-
 CARD32 sna_format_for_depth(int depth);
 CARD32 sna_render_format_for_depth(int depth);
 
diff --git a/src/sna/sna_render.c b/src/sna/sna_render.c
index a9a170a..7b6661e 100644
--- a/src/sna/sna_render.c
+++ b/src/sna/sna_render.c
@@ -244,6 +244,12 @@ no_render_context_switch(struct kgem *kgem,
 }
 
 static void
+no_render_retire(struct kgem *kgem)
+{
+	(void)kgem;
+}
+
+static void
 no_render_fini(struct sna *sna)
 {
 	(void)sna;
@@ -273,6 +279,7 @@ void no_render_init(struct sna *sna)
 	render->fini = no_render_fini;
 
 	sna->kgem.context_switch = no_render_context_switch;
+	sna->kgem.retire = no_render_retire;
 	if (sna->kgem.gen >= 60)
 		sna->kgem.ring = KGEM_BLT;
 }
commit 6d31cb2d943be456f4ebaa663275c6a939013d9e
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Jan 18 11:25:30 2012 +0000

    sna: Restore use of shadow pixmaps by default without RENDER support
    
    If we do not have access to an accelerated render backend, only create
    GPU buffers for the scanout and use an accelerated blitter for
    upload/download and operating inplace on the scanout.
    
    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 5fefb81..51b3662 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -623,12 +623,12 @@ static PixmapPtr sna_create_pixmap(ScreenPtr screen,
 {
 	struct sna *sna = to_sna_from_screen(screen);
 	PixmapPtr pixmap;
-	int pad, size;
+	int pad;
 
 	DBG(("%s(%d, %d, %d, usage=%x)\n", __FUNCTION__,
 	     width, height, depth, usage));
 
-	if (wedged(sna))
+	if (wedged(sna) || !sna->have_render)
 		return create_pixmap(sna, screen,
 				     width, height, depth,
 				     usage);
@@ -666,8 +666,7 @@ static PixmapPtr sna_create_pixmap(ScreenPtr screen,
 		return create_pixmap(sna, screen, width, height, depth, usage);
 
 	pad = PixmapBytePad(width, depth);
-	size = pad * height;
-	if (size <= 4096) {
+	if (pad*height <= 4096) {
 		pixmap = create_pixmap(sna, screen,
 				       width, height, depth, usage);
 		if (pixmap == NullPixmap)
diff --git a/src/sna/sna_glyphs.c b/src/sna/sna_glyphs.c
index 6efe801..ee40707 100644
--- a/src/sna/sna_glyphs.c
+++ b/src/sna/sna_glyphs.c
@@ -1224,9 +1224,8 @@ sna_glyphs(CARD8 op,
 	if (FALLBACK || DEBUG_NO_RENDER)
 		goto fallback;
 
-	if (sna->kgem.wedged || !sna->have_render) {
-		DBG(("%s: no render (wedged=%d)\n",
-		     __FUNCTION__, sna->kgem.wedged));
+	if (wedged(sna)) {
+		DBG(("%s: wedged\n", __FUNCTION__));
 		goto fallback;
 	}
 
diff --git a/src/sna/sna_trapezoids.c b/src/sna/sna_trapezoids.c
index d038539..4f5231c 100644
--- a/src/sna/sna_trapezoids.c
+++ b/src/sna/sna_trapezoids.c
@@ -3644,9 +3644,8 @@ sna_composite_trapezoids(CARD8 op,
 	if (NO_ACCEL)
 		goto fallback;
 
-	if (wedged(sna) || !sna->have_render) {
-		DBG(("%s: fallback -- wedged=%d, have_render=%d\n",
-		     __FUNCTION__, sna->kgem.wedged, sna->have_render));
+	if (wedged(sna)) {
+		DBG(("%s: fallback -- wedged\n", __FUNCTION__));
 		goto fallback;
 	}
 
commit 15a150579c3907054e186c68382873efdbadca75
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Jan 18 10:26:33 2012 +0000

    intel: Trivially remove a piece of XAA dependency for shadow
    
    The wolves are gathering at the door baying for the removal of XAA from
    Xorg.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/intel_dri.c b/src/intel_dri.c
index 46c11d5..0c6d45c 100644
--- a/src/intel_dri.c
+++ b/src/intel_dri.c
@@ -56,7 +56,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #include "windowstr.h"
 #include "shadow.h"
-#include "xaarop.h"
 #include "fb.h"
 
 #include "intel.h"
diff --git a/src/intel_shadow.c b/src/intel_shadow.c
index b86530a..393a038 100644
--- a/src/intel_shadow.c
+++ b/src/intel_shadow.c
@@ -30,7 +30,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #endif
 
 #include "xf86.h"
-#include "xaarop.h"
 #include "intel.h"
 #include "i830_reg.h"
 
@@ -101,7 +100,6 @@ static void intel_shadow_memcpy(intel_screen_private *intel)
 void intel_shadow_blt(intel_screen_private *intel)
 {
 	ScrnInfoPtr scrn = intel->scrn;
-	unsigned int dst_pitch;
 	uint32_t blt, br13;
 	RegionPtr region;
 	BoxPtr box;
@@ -113,27 +111,23 @@ void intel_shadow_blt(intel_screen_private *intel)
 		return;
 	}
 
-	dst_pitch = intel->front_pitch;
 
 	blt = XY_SRC_COPY_BLT_CMD;
-	if (intel->cpp == 4)
-		blt |= (XY_SRC_COPY_BLT_WRITE_ALPHA |
-				XY_SRC_COPY_BLT_WRITE_RGB);
-
-	if (INTEL_INFO(intel)->gen >= 40) {
-		if (intel->front_tiling) {
-			dst_pitch >>= 2;
-			blt |= XY_SRC_COPY_BLT_DST_TILED;
-		}
-	}
 
-	br13 = ROP_S << 16 | dst_pitch;
+	br13 = intel->front_pitch;
+	if (intel->front_tiling && INTEL_INFO(intel)->gen >= 40) {
+		br13 >>= 2;
+		blt |= XY_SRC_COPY_BLT_DST_TILED;
+	}
 	switch (intel->cpp) {
 		default:
-		case 4: br13 |= 1 << 25; /* RGB8888 */
+		case 4: blt |=
+			XY_SRC_COPY_BLT_WRITE_ALPHA | XY_SRC_COPY_BLT_WRITE_RGB;
+			br13 |= 1 << 25; /* RGB8888 */
 		case 2: br13 |= 1 << 24; /* RGB565 */
 		case 1: break;
 	}
+	br13 |= 0xcc << 16; /* copy */
 
 	region = DamageRegion(intel->shadow_damage);
 	box = REGION_RECTS(region);


More information about the xorg-commit mailing list